Donut with radial gradient
A demo of amCharts 3, an older version, no longer developed. For a new project, start from the amCharts 5 demos.
Using property gradientRatio you can achieve any gradient you want. This particular chart uses the following gradient ratio: [-0.4, -0.4, -0.4, -0.4, -0.4, -0.4, 0, 0.1, 0.2, 0.1, 0, -0.2, -0.5]
Negative value means the color will be darker than the original, and positive number means the color will be lighter. gradientRatio array can be of any length you want, depending on a gradient you want to achieve.
Pie chart also supports linear gradient. To enable it set gradientType to linear. However, radial gradients would look much better.
Open in:
Code
JavaScript
var chart = AmCharts.makeChart("chartdiv", {
"type": "pie",
"theme":"light",
"innerRadius": "40%",
"gradientRatio": [-0.4, -0.4, -0.4, -0.4, -0.4, -0.4, 0, 0.1, 0.2, 0.1, 0, -0.2, -0.5],
"dataProvider": [{
"country": "Lithuania",
"litres": 501.9
}, {
"country": "Czech Republic",
"litres": 301.9
}, {
"country": "Ireland",
"litres": 201.1
}, {
"country": "Germany",
"litres": 165.8
}, {
"country": "Australia",
"litres": 139.9
}, {
"country": "Austria",
"litres": 128.3
}],
"balloonText": "[[value]]",
"valueField": "litres",
"titleField": "country",
"balloon": {
"drop": true,
"adjustBorderColor": false,
"color": "#FFFFFF",
"fontSize": 16
},
"export": {
"enabled": true
}
});
HTML
<div id="chartdiv"></div>
CSS
#chartdiv {
width : 100%;
height : 500px;
font-size : 11px;
}
Resources
https://www.amcharts.com/lib/3/amcharts.js
https://www.amcharts.com/lib/3/pie.js
https://www.amcharts.com/lib/3/themes/patterns.js
https://www.amcharts.com/lib/3/themes/light.js
https://www.amcharts.com/lib/3/plugins/export/export.min.js
https://www.amcharts.com/lib/3/plugins/export/export.css
All in one page
<!-- Resources -->
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/pie.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/patterns.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css">
<!-- Chart code -->
<script>
var chart = AmCharts.makeChart("chartdiv", {
"type": "pie",
"theme":"light",
"innerRadius": "40%",
"gradientRatio": [-0.4, -0.4, -0.4, -0.4, -0.4, -0.4, 0, 0.1, 0.2, 0.1, 0, -0.2, -0.5],
"dataProvider": [{
"country": "Lithuania",
"litres": 501.9
}, {
"country": "Czech Republic",
"litres": 301.9
}, {
"country": "Ireland",
"litres": 201.1
}, {
"country": "Germany",
"litres": 165.8
}, {
"country": "Australia",
"litres": 139.9
}, {
"country": "Austria",
"litres": 128.3
}],
"balloonText": "[[value]]",
"valueField": "litres",
"titleField": "country",
"balloon": {
"drop": true,
"adjustBorderColor": false,
"color": "#FFFFFF",
"fontSize": 16
},
"export": {
"enabled": true
}
});
</script>
<!-- HTML -->
<div id="chartdiv"></div>