Legend does not display for Column chart

5 posts, 0 answers
  1. Ande2013
    Ande2013 avatar
    17 posts
    Member since:
    Jun 2013

    Posted 01 Jul 2013 Link to this post

    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.
  2. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 02 Jul 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Ande2013
    Ande2013 avatar
    17 posts
    Member since:
    Jun 2013

    Posted 03 Jul 2013 Link to this post

    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;
    }
  5. Ande2013
    Ande2013 avatar
    17 posts
    Member since:
    Jun 2013

    Posted 03 Jul 2013 Link to this post

    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.
  6. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 04 Jul 2013 Link to this post

    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!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready