Kendo DataViz - Columns values always Black

336 Views Asked by At

I want to display a kendo Chart with colums and to do so, I use this razor code :

@(Html.Kendo().Chart(results)
  .Name("line-chart")
  .Title("The chart based on lines")
  .SeriesDefaults(sd=>sd.Line().Markers(false))
  .Legend(l=>l.Position(ChartLegendPosition.Bottom))
  .ChartArea(ca=>ca.Background("transparent"))
  .Series(series =>
      {
          series.Column(
              point => point.Pluie,
              date => date.Date,
              null)
                .Axis("Pluie")
                .Name("Pluie")
                .Gap(0)
                .Stack(true)
                .Highlight(true)
                .Color("Red");
      })
  .ValueAxis(v =>
      {
            v.Numeric("Pluie").Min(0).Max(25);
      })
  .CategoryAxis(c=>c.Labels(l=>l.Visible(false)))
  .Tooltip(t=>t.Visible(true).Template("Value : #=value# Date : #=category#")))

Everything works well, exept one thing. My bars have to be red, and they are always black, even if I put this : "Color("Red");" to my razor code.

Is anyone having the same issue ?

1

There are 1 best solutions below

0
On

You need to put the colour inside series.Column as the second parameter, eg:

.Series(series =>
  {
      series.Column(
          m => m.Value,
          m => m.Colour,
          m => m.Category,
          m => m.Note
      )
  }

Or in a separate part of the factory:

 .SeriesColors(new string[] {"#20BDFF", "#84DAFF", "#FFCD8A", "#FE9915", "#FF6633"})