function pieChartSeriesChange(args) { var series = args.model.series; for (var i = 0; i < series.length; i++) { var total = 0; //Calculate total value for (var j = 0; j < series[i].points.length; j++)
{ if (series[i].points[j].visible ) { total += series[i].points[j].y; } } for (j = 0; j < series[i].points.length; j++) series[i].points[j].text = series[i].points[j].x + ':- ' + (series[i].points[j].y / total * 100).toFixed(2) + '%'; } }
ASP.NET MVC: @(Html.EJ().Chart("container") //... .LegendItemClick("pieChartSeriesChange") ) function pieChartSeriesChange(args) { var series = args.model.series; for (var i = 0; i < series.length; i++) { var total = 0; //Calculate total value for (var j = 0; j < series[i].points.length; j++) { if (series[i].points[j]._visibility == "visible" && args.data.legendItem.LegendItem.PointIndex != j) total += series[i].points[j].y; } for (j = 0; j < series[i].points.length; j++) series[i].points[j].text = series[i].points[j].x + ':- ' + (series[i].points[j].y / total * 100).toFixed(2) + '%'; } } |