Sum of stacked column series in datalabels

I have a stacked column chart with two series:

http://jsplayground.syncfusion.com/pyj4p4ce

I'd like to show in the marker.dataLabel of the second series (Planned, in grey), the value of the sum of the two series (Value of Actual + Value of Planned).
(In the example you can find in the playground link, the values are all equal to 6)
5+1=6
3.2+2.8=6
2.7+3.3=6
....


How can I do?

1 Reply

SK Saravana Kumar Kanagavel Syncfusion Team October 24, 2017 11:35 AM UTC

Hi Marco, 
 
Thanks for contacting Syncfusion Support. 
 
We have analyzed your query and achieved your requirement by using “displayTextRendering” event. 
 
[JS] 
$("#food-chart").ejChart( 
{ 
     displayTextRendering:"onDataLabelRendering", 
   }); 
 
function onDataLabelRendering(sender){ 
      if(sender.data.seriesIndex == 1){ 
          var yValue = 0; 
         for(var i=0;i<sender.model.series.length;i++){ 
            yValue += sender.model.series[i].points[sender.data.pointIndex].y; 
         } 
        sender.data.text = yValue.toString(); 
       } 
    } 
     
 
In the above code , we are triggering the displayTextRendering event. In the event, we have displayed the total value of series through data label text on second series. 
 
And we have modified the sample link from the below 
 
 
Pleased find the output of the sample below 
 
 
 
Please let us know if you have any concern. 
 
Regards, 
Saravana Kumar K. 


Loader.
Up arrow icon