I have a column chart which does not show the legend even though I have set legend.Visible to true. If I uncomment the .Group line commented in the code below, then the legend starts showing, but unfortunately it displays the default colors rather than those I have customised with m => m.UiColor
Sorry I am getting "Invalid post content." when trying to paste the code in this post so I have attached it as an image.
4 Answers, 1 is accepted
0
Hi Andreas,
I have already answered to the same question in your other thread, however I am pasting my reply here too:
Thank you for provided your Chart's configuration. Up to your scenarios:
Iliana Nikolova
Telerik
I have already answered to the same question in your other thread, however I am pasting my reply here too:
Thank you for provided your Chart's configuration. Up to your scenarios:
- Grouped Chart - by design the colorField is intended to set color to a single point in the series (like in this online demo), not to the entire series. Please note the legend's color matches the series color. Hence in order to achieve the expected result you should set colors to the series through theseries.color (like here) or the seriesColors (like in this online demo). Another option is to set the color manually via the options:
Copy Code
@(Html.Kendo().Chart(Model)
//....
.Name(
"chart"
)
.Events(ev=>ev.DataBound(
"onDb"
))
)
<script>
function
onDb(){
var
chart = $(
"#chart"
).data(
"kendoChart"
);
chart.options.series[0].color = chart.options.series[0].data[0].UiColor;
//....
}
</script>
- Non-grouped chart - by design the Chart's legend shows the series' names. In the provided code snippet the series.name is (""). Hence in order to display the legend you should specify the series' name (for example .Name(" ") ).
Iliana Nikolova
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ande2013
Top achievements
Rank 1
answered on 03 Jul 2013, 02:52 PM
Thanks, the JavaScript code you posted has worked
for
(
var
i = 0; i < chart.options.series.length; i++) {
chart.options.series[i].color = chart.options.series[i].data[0].UiColor;
}
0
Ande2013
Top achievements
Rank 1
answered on 03 Jul 2013, 02:56 PM
still having issues with the forum though, I am now trying to click 'Mark as answered' above and getting
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
0
Hello Andreas,
Iliana Nikolova
Telerik
Thank you for the feedback - I forwarded it to the corresponding team.
Iliana Nikolova
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!