I need to display Grand Total on top of the Htmlchart stacked bars in addition to each stacked bar item value but i do not know how to do that.
I tried to use DefaultLabelValue with "#STSUM" but it is not avilable or i do not know how to use it.
Can you please help me with this?
I have attached the screen shot for the same.
Thanks,
Dhachina
14 Answers, 1 is accepted
In the current version of RadControls it is not possible to display the grand total of the stacked Bar/Column Series. However, this effect can be achieved only if your HtmlChart is databound. You can find below two approaches:
Approach1:
- Hide the labels of all Series, except the last one.
- Create an additional column in your datasource that sums up other columns which are bound to other Series.
- Use the additional column from the datasource to populate labels for the last Series through ClientTemplates.
- Set the Position property of the labels of the last Series to OutsideEnd.
- RadHtmlChart_ColumnSeries_Stacked_GrandTotal1.aspx
- RadHtmlChart_ColumnSeries_Stacked_GrandTotal1.aspx.cs
Approach2:
If you want, however, to keep the labels of other Series as well, you can:
- Create an additional Series.
- Create an additional column in your datasource that is populated with values close to 0 (i.e. 0.001)
- Databind the additional column to the new Series.
- Create another column in your datasource that sums up other columns which are bound to other Series excluding the column with small values close to 0.
- Use this column from the datasource to populate labels for the new Series through ClientTemplates.
- Set the Position property of the labels of the new Series to OutsideEnd.
This approach has two disadvantages:
- The newly created Series will be slightly visible despite their small values.
- If your legend is visible the name of the newly created Series will figure there.
You can find an example in the attached archive:
- RadHtmlChart_ColumnSeries_Stacked_GrandTotal2.aspx
- RadHtmlChart_ColumnSeries_Stacked_GrandTotal2.aspx.cs
All the best,
Danail Vasilev
the Telerik team
Thank you so much for the alternate solutions.
Will this be fixed in next or near future releases?
Thanks,
Dhachina
This is not a bug in the control but rather a feature request. Actually you are the first one to ask about it, so if we receive other requests as well, our developers might consider its implementation in the future.
Kind regards,
Danail Vasilev
the Telerik team
We would like this feature as well. We have exactly the same situation where we want to display the grand total of the stacked bar.
Approach 1 is not feasible because in our case not every stacked bar (a column displaying data for a year) will have data for all the series and setting the visibility of the labels to false for every series but the last, will result in no label if one column doesn't happen to have any data for the last series
Approach 2 is not feasible for exactly the disadvantages described here. It will clutter up the chart and possibly confuse the client to have an item in the legend that is not really an item.
We really hope you can add this.
Thanks in advance!
I have logged this idea as a feature request in our feedback portal here, so that you can monitor, comment or raise its priority by voting on it. If it gets enough votes we might consider its implementation for the future.
You can also find attached a modified version of one of the examples from my previous posts so that now it handles the described unexpected behaviors. Said shortly I have created an additional series with the following settings:
- series items are set with insignificantly small values (e.g. 0.001)
- the name property of the series is not specified, so that it is not visible in the legend
- the color of the series matches the color of the plot area, so that the series items and the legend of the series are not visible
- clienttemplates for the labels of this series is used in order to sum up the grand total and display it
Greetings,
Danail Vasilev
the Telerik team
How do you do this in server side code?
Thanks
Generally the same property and tag names used for the declarative creation can also be used for the programmatic creation of Telerik UI controls.
You can find an example of a RadHtmlChart programmatic creation in this online demo.
Regards,
Danail Vasilev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Actually, we are looking for this feature since a while, appreciate if you can confirm adding it to next release
Generally we receive many requests about features, improvements and fixes regarding 80+ controls. Considering the fact that it is not physically possible to implement the numerous request for all of the controls we let our clients decide which are the most wanted features by voting on them.
Currently, however, this feature has less votes than other ones and therefore it gets a lower priority. If it gets enough votes and then approval from our management it may be implemented for the future.
For the time being I can suggest that you vote on the feedback item and use the example from the Displaying Grand Total In Stacked Series Labels And Pie Series Legend KB article in order to achieve the desired effect.
Regards,
Danail Vasilev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Hello Srinivas,
As the feedback portal (http://feedback.telerik.com/Project/108/Feedback/Details/46952-add-grand-total-labels-for-stacked-column-and-bar-series) states - the feature is not yet implemented. Its status is Approved, meaning that we believe it is a good idea, but it is not Completed, which would mean it is already implemented.
For the time being, you should use the approach from the Knowldege Base article: http://www.telerik.com/support/kb/aspnet-ajax/chart-%28html5%29/details/displaying-grand-total-in-stacked-series-labels-and-pie-series-legend.
Regards,
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Hello,
Has this feature been implemented?
Hello,
As the Feedback portal page states—this feature has not been implemented yet.
Regards,
Telerik
Hello, need a help.
When I create project like here http://www.telerik.com/support/kb/aspnet-ajax/chart-%28html5%29/details/displaying-grand-total-in-stacked-series-labels-and-pie-series-legend
expression like #=dataItem.Cat1Percent + dataItem.Cat2Percent +
dataItem.Cat3Percent + dataItem.Cat4Percent...# calculates double values
wrong.:
2.68+7.61+4.96+2.3+1.98+2.7+1.08+0.56+0.68+0.32+0.32 = 25.189999999999997
O my god, what can I do with it?