var chart;
var legend;
var selected;
var types = [{
type: "Veltlínske zelené",
percent: 4580,
color: "#e8ce71",
}, {
type: "Chardonnay",
percent: 4162,
color: "#e7c445",
}, {
type: "Muškát moravský",
percent: 3623,
color: "#d5bd68",
}, {
type: "Frankovka modrá",
percent: 14894,
color: "#ebd791",
}];
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",
"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"
}
}]
},
"theme": "black",
"numberFormatter": {
"precision": -1,
"decimalSeparator": ",",
"thousandsSeparator": " "
},
"dataProvider": generateChartData(),
"labelText": "[[title]]: [[value]] ks",
"balloonText": "[[title]]: [[value]] ks",
"titleField": "type",
"valueField": "percent",
"outlineColor": "#e5c450",
"innerRadius": 40,
"outlineAlpha": 0,
"outlineThickness": 3,
"color": "#000",
"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
}
});