This is a migrated thread and some comments may be shown as answers.

How to show aggregate values of bars

3 Answers 184 Views
Charts
This is a migrated thread and some comments may be shown as answers.
lu
Top achievements
Rank 1
lu asked on 29 May 2018, 03:32 AM

Hello Telerik Team,

I have an issue with showing the aggregate value in bar charts.

Could I show the aggregate values of bars like the attachment shows?

The attachment used another UI and I want to replace it with kendo UI.

Thank you!

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 30 May 2018, 02:36 PM
Hello Lu,

You can achieve this if you use a label template for your series that are placed on the top of the stack and bind the template to the stackValue template variable.
seriesDefaults: {
  type: "column",
  stack: true
},
series: [{
  field: "a",
  name: "a"
},{
  field: "b",
  name: "b"
},{
  field: "c",
  name: "c",
  labels: {
      template: "#= stackValue #",
      visible: true
  }
}]

This article shows such an example:
Show Total for Stacked Series

Regards,
Tsvetina
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Saeed
Top achievements
Rank 1
answered on 18 Nov 2019, 08:11 AM

Hi,

this works if the last series exists in every bar but what if only the second series defined or the first one is presented? how can i display the "stackValue" without relying on the last series?

 

thanks!

0
Tsvetomir
Telerik team
answered on 19 Nov 2019, 11:19 AM

Hi Saeed,

My name is Tsvetomir and I will be covering for my colleague Tsvetina.

In general, the most straightforward way to tackle the issue is to always have all of the series. For the ones that you would like to not show, I can recommend setting a value of 0. Visually only 2 series would be shown. However, the label would be shown as if a third series was present.

Alternatively, you would have to set the labels template for each of the series declarations and check which one should be used. For instance, if the third series is present, do not render labels for the other ones.

I recommend that you utilize the first approach. However, in case additional clarifications are needed, feel free to contact me back.

 

Kind regards,
Tsvetomir
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Charts
Asked by
lu
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Saeed
Top achievements
Rank 1
Tsvetomir
Telerik team
Share this question
or