* ---------------------------------------
* 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/
* ---------------------------------------
var chart = am4core . create ( " chartdiv " , am4charts . PieChart );
country: " The Netherlands " ,
// Add and configure Series
var pieSeries = chart . series . push ( new am4charts . PieSeries ());
pieSeries . dataFields . value = " litres " ;
pieSeries . dataFields . category = " country " ;
pieSeries . slices . template . states . getKey ( " active " ) . properties . shiftRadius = 0 ;
pieSeries . slices . template . tooltipText = "" ;
pieSeries . slices . template . alwaysShowTooltip = true ;
pieSeries . slices . template . events . on ( " hit " , function ( ev ) {
currentSlice . tooltip . hide ();
currentSlice = ev . target ;
currentSlice . tooltipText = " {category}: {value.percent.formatNumber('#.#')}% ({value.value}) " ;
currentSlice . invalidate ();
currentSlice . showTooltip ();
// Set up page click event to close open tooltip
am4core . getInteraction () . body . events . on ( " hit " , function ( ev ) {
currentSlice . tooltip . hide ();