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

[Solved] line chart tooltip show percentage of total

1 Answer 899 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Roy
Top achievements
Rank 1
Roy asked on 21 Oct 2014, 02:51 PM
Is there a way I can show a percentage of the total on the tooltip for a line chart that shows volume. For stacked column 100% I could do this by "#=kendo.toString(percentage, 'p0')#".
$("#chart").kendoChart({
                legend: {
                    position: "bottom"
                },
                seriesDefaults: {
                    type: "line",
                },
                series: [{
                    name: "Brintellix",
                    data: [44,    1245,    1566,    861]
                },{
                    name: "Cymbalta",
                    data: [31827,    25843,    21786,    20043]
                },{
                    name: "Fetzima",
                    data: [78,    256,    1647,    8070]
                },{
                    name: "Pristiq",
                    data: [8207,    11025,    6365,    6646]
                }],
                valueAxis: {
                    line: {
                        visible: false
                    }
                },
                categoryAxis: {
                    categories: ["SEP 13", "OCT 13", "NOV 13", "DEC 13"],
                    majorGridLines: {
                        visible: false
                    }
                },
                tooltip: {
                    visible: true,
                    template: "#= series.name #: #= value #"
                }
            });

1 Answer, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 23 Oct 2014, 12:42 PM
Hi Roy,

Currently there is no such feature available for the Kendo UI Line Chart. But you can calculate the point percentage in your chart's data then you need to pass it to the chart's dataSource like in this online example.

Your point object should look like:
{
   value: 44,
   percentage: // your calculated value
}
Your tooltip template should look like:
template: "#= dataItem.percentage #"

I hope this helps.

Regards,
Hristo Germanov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Charts
Asked by
Roy
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Share this question
or