AMcharts4 donut
donut with slice pulled
by amcharts
HTML
<script src="https://cdn.amcharts.com/lib/4/core.js"></script>
<script src="https://cdn.amcharts.com/lib/4/charts.js"></script>
<script src="https://cdn.amcharts.com/lib/4/themes/material.js"></script>
<div id="chartdiv"></div>
CSS
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
#chartdiv {
width: 100%;
height: 500px;
}
JavaScript
/**
* ---------------------------------------
* This demo was created using amCharts 4.
*
* For more information visit:
* https://www.amcharts.com/
*
* Documentation is available at:
* https://www.amcharts.com/docs/v4/
* ---------------------------------------
*/
// Themes begin
//am4core.useTheme(am4themes_material);
// Themes end
/**
* Define data for each year
*/
var chartData = [{
"label": "praveen",
"value": 10,
"color": "#E1A3B3"
},
{
"label": "p1",
"value": 20,
"color": "#E1A3B3"
},
{
"label": "p2",
"value": 70,
"color": "#E1A3B3"
}
];
// Create chart instance
var chart = am4core.create("chartdiv", am4charts.PieChart);
// Add data
chart.data = [{
"label": "xxx",
"value": 10,
"color": "#E1A3B3"
},
{
"label": "p1",
"value": 20,
"color": "#E1A3B3"
},
{
"label": "p2",
"value": 70,
"color": "#E1A3B3"
}
];
// Add label
chart.innerRadius = am4core.percent(40);
chart.radius = am4core.percent(60);
//var label = chart.seriesContainer.createChild(am4core.Label);
//label.text = "1995";
//label.horizontalCenter = "middle";
//label.verticalCenter = "middle";
//label.fontSize = 50;
//label.color=red;
// Add and configure Series
var pieSeries = chart.series.push(new am4charts.PieSeries());
pieSeries.dataFields.value = "value";
pieSeries.dataFields.category = "label";
pieSeries.slices.template.readerTitle = "{category}: {value.percent.formatNumber('#.#')}% ({value.value})";
chart.responsive.enabled = true;
//pieSeries.slices.template.tooltipText = "praveen tooltip";
//pieSeries.labels.template.disabled = true;
//pieSeries.ticks.template.disabled = true;
// Disable tooltips
chart.legend = new am4charts.Legend();