casillas
casillas

Reputation: 16793

Legend Label Customizaton not working in Model Controller

Based on the following implementation, I could able to customize legend labels, it works when I put in my viewcontroller

series: [{
 field: "value",
 name :"#= group.items[0].fname || group.items[1].fname#" 
}],

However, when I put in my model view controller, then it does not work.

chart.setDataSource(theDataSource);
chart.options.series.name = "#= group.items[0].fname || group.items[1].fname#"
chart.refresh();

Upvotes: 1

Views: 81

Answers (1)

ezanker
ezanker

Reputation: 24738

When you update the options property, you need to call refresh() when you are done (http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#fields-options):

chart.refresh();

You could also try using the setOptions method (http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#methods-setOptions):

var chart = $("#chart").data("kendoChart");
chart.setOptions({ 
    series: [{
        field: "value",
        name :"#= group.items[0].fname || group.items[1].fname#" 
    }] 
});

The following approach should work,

change the following line of code

chart.options.series.name = "#= group.items[0].fname || group.items[1].fname#"

to

chart.options.series[0].name = "#= group.items[0].fname || group.items[1].fname#"; 

Upvotes: 3

Related Questions