Javascript examples for highcharts:Pie Chart
active data label in Pie Chart
<html> <head> <title>Highcharts Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .data-label-selected>span { color: red !important; } </style> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <script src="https://code.highcharts.com/modules/export-data.js"></script> <div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div> <script type="text/javascript"> Highcharts.chart('container', { chart: {//ww w . ja va 2 s. c om plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie', events: { render: function() { this.series[0].points[0].dataLabel.addClass('data-label-selected'); } } }, title: { text: 'Browser market shares in January, 2018' }, tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { useHTML: true, enabled: true, format: '<b>{point.name}</b>: {point.percentage:.1f} %', style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' } } } }, series: [{ name: 'Brands', colorByPoint: true, point: { events: { select: function() { var points = this.series.points; Highcharts.each(points, function(p) { if (p.dataLabel.hasClass('data-label-selected')) { p.dataLabel.removeClass('data-label-selected'); } }); this.dataLabel.addClass('data-label-selected'); } } }, data: [{ name: 'Chrome', y: 11.41, sliced: true, selected: true }, { name: 'Internet Explorer', y: 11.84 }, { name: 'Firefox', y: 10.85 }, { name: 'Edge', y: 4.67 }, { name: 'Safari', y: 4.18 }, { name: 'Sogou Explorer', y: 1.64 }, { name: 'Opera', y: 1.6 }, { name: 'QQ', y: 1.2 }, { name: 'Other', y: 2.61 }] }] }); </script> </body> </html>