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

Legend does not display for Column chart

4 Answers 118 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Ande2013
Top achievements
Rank 1
Ande2013 asked on 01 Jul 2013, 01:30 PM
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

Sort by
0
Iliana Dyankova
Telerik team
answered on 02 Jul 2013, 08:16 AM
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:

  • 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(" ") ).
  Regards,
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.
0
Iliana Dyankova
Telerik team
answered on 04 Jul 2013, 10:12 AM
Hello Andreas,

Thank you for the feedback - I forwarded it to the corresponding team. 

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