var chart;
var legend;
var selected;
var types = [{
type: "Svätovavrinecké",
percent: 3956,
color: "#e8ce71",
}, {
type: "Dunaj",
percent: 2008,
color: "#e7c445",
}, {
type: "Pinot Noir",
percent: 1874,
color: "#d5bd68",
}, {
type: "Cabernet sauvignon",
percent: 3864,
color: "#ebd791",
}, {
type: "Devín",
percent: 2008,
color: "#e9bb17",
}, {
type: "Tramín červený",
percent: 10542,
color: "#fee382",
}, {
type: "Sauvignon",
percent: 3514,
color: "#e9d89b",
}, {
type: "Pinot Blanc",
percent: 4518,
color: "#ccb666",
}, {
type: "Rizling rýnsky",
percent: 7682,
color: "#ebd791",
}, {
type: "Rizling vlašský",
percent: 9888,
color: "#e4dab7",
}, {
type: "Frankovka modrá",
percent: 3012,
color: "#feefba",
}, {
type: "Alibernet",
percent: 7137,
color: "#bfa239",
}];
function generateChartData() {
var chartData = [];
for (var i = 0; i < types.length; i++) {
if (i == selected) {
for (var x = 0; x < types[i].subs.length; x++) {
chartData.push({
type: types[i].subs[x].type,
percent: types[i].subs[x].percent,
color: types[i].color,
pulled: true
});
}
} else {
chartData.push({
type: types[i].type,
percent: types[i].percent,
color: types[i].color,
id: i
});
}
}
return chartData;
}
AmCharts.makeChart("chartdiv", {
"type": "pie",
"theme": "black",
"defs": {
"filter": [{
"id": "shadow",
"width": "200%",
"height": "200%",
"feOffset": {
"result": "offOut",
"in": "SourceAlpha",
"dx": 0,
"dy": 0
},
"feGaussianBlur": {
"result": "blurOut",
"in": "offOut",
"stdDeviation": 0
},
"feBlend": {
"in": "SourceGraphic",
"in2": "blurOut",
"mode": "normal"
}
}]
},
"dataProvider": generateChartData(),
"labelText": "[[title]]: [[value]] ks",
"balloonText": "[[title]]: [[value]] ks",
"titleField": "type",
"numberFormatter": {
"precision": -1,
"decimalSeparator": ",",
"thousandsSeparator": " "
},
"valueField": "percent",
"outlineColor": "#e5c450",
"outlineAlpha": 0,
"outlineThickness": 3,
"color": "#000",
"innerRadius": 40,
"colorField": "color",
"pulledField": "pulled",
"titles": [{
"text": ""
}],
"listeners": [{
"event": "clickSlice",
"method": function(event) {
var chart = event.chart;
if (event.dataItem.dataContext.id != undefined) {
selected = event.dataItem.dataContext.id;
} else {
selected = undefined;
}
chart.dataProvider = generateChartData();
chart.validateData();
}
}],
"export": {
"enabled": true
}
});