Display total above Stacked Column chart

Hi

Is there any way to display the sum of all the values in a Stacked Column Chart above the column? I'm aware of the showCumulativeValues attribute, but I want the individual values to be displayed non-cummulatively.


Thanks.


5 Replies

YG Yuvaraj Gajaraj Syncfusion Team January 28, 2022 05:00 PM UTC

Hi keith leng, 
 
Greetings from Syncfusion. We have analyzed your query and we have created the workaround to achieve your requirement. In this sample it will render a data label at the top of the stack column series, and it would be the sum of all value in the stack. We have attached the sample below for your reference. 
 
  
If this is not your case, kindly provide more information on the query but I want the individual values to be displayed non-cummulatively and if possible, share screenshots for your requirement.  
 
Regards, 
Yuvaraj. 



KL keith leng February 2, 2022 07:17 AM UTC

Hi,

Thanks for your reply. Sorry for my late reply. What I'm looking for is values on each individual part of the stack and also a total at the top. 


Snag_3499ce66.png



YG Yuvaraj Gajaraj Syncfusion Team February 3, 2022 03:50 PM UTC

Hi Keith, 
 
Thanks for the information. The label at the top of stacked column can be achieved using the annotation feature. Using the annotation, we can place the custom widgets in the chart. We have created a sample in which we have found the sum of y-values and displayed at top of column using annotation. We have attached the sample below for your reference. 
 
Code snippet: 
SfCartesianChart( 
  annotations: getAnnotation(), 
  // Other required properties 
) 
 
List<CartesianChartAnnotation> getAnnotation() { 
   //............ 
    return annotations; 
  } 
 
  
 
Hope this will help you. 
 
Regards, 
Yuvaraj. 



KL keith leng February 11, 2022 07:25 AM UTC

Hi,

Thanks for the example. I have a couple of problems when I apply it to my chart.  The x-axis on my chart is DateTime.  Only alternate days are printed on the x-axis. I'm not sure if this intended behavior or a problem with my code. Either way, for the columns where there is no date displayed on the x-axis, the cumulative value is displayed at the origin (top left corner) of the chart, not above the columns. Secondly, the cumulative values which are displayed, are a  little too low and overwrite the top of the chart.


syncfusionCumulative.jpg 






YG Yuvaraj Gajaraj Syncfusion Team February 14, 2022 05:53 PM UTC

Hi Keith, 
 
We have analyzed your scenario, and the reported issue is not reproduced at our end. We have attached the sample, which was used in the testing phase. Here we have used the date time values for the x-axis, however the annotation gets render properly. Since we are not aware of the exact scenario, kindly reproduce the reported issue with the attached sample using your data source and get back to us. It will be more helpful to us to provide a solution sooner. 
 
  
Regards, 
Yuvaraj. 


Loader.
Up arrow icon