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

Change labels after or during render

1 Answer 107 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 26 Apr 2021, 11:33 PM

Hi,

 

I have a similar post here https://www.telerik.com/forums/ideas-for-visualisation where we discuss the problem but the crux of the matter is that we want to be able to change the labels on a stacked bar chart after the render process.  Does anyone know if this is possible?

1 Answer, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 29 Apr 2021, 07:10 PM

Hello Andrew,

There are a few label configurations in regards to the Kendo UI Stacked Bar Chart, so I have created a Progress Kendo UI Dojo where when the user presses a button, the labels will change using their templates in the legend, categoryAxis, valueAxis, and series.  

    $("#btnChange").kendoButton({
      click: function(e){

        //Reference the Kendo UI Chart
        var chart = $("#chart").data("kendoChart");

        //Change Legend labels
        chart.options.legend.labels.template = "Legend: #: text #";

        //Change ValueAxis Labels
        chart.options.valueAxis.labels.template = "ValueAxis: #: value #";

        //Change CategoryAxis Labels
        chart.options.categoryAxis.labels.template = "CategoryAxis: #: value #";

        //Change series.labels values in stack
        chart.options.seriesDefaults.labels.template = "Series: #: value #";

        //Repaints chart with newly loaded data
        chart.redraw();
      }
    });

There are other options for changing the labels like color, background, and border.  For example, the seriesDefaults.labels has a number of related properties which can be modified. 

I hope this information helps!  Please let me know if you have any questions regarding the label changes.

Regards,
Patrick
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Tags
Charts
Asked by
Andrew
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Share this question
or