Kendo-angular: How to set specific colors for line chart

Created on 19 Jul 2017  路  3Comments  路  Source: telerik/kendo-angular

How can I set specific colors for line chart?

Series component's color input is only applied to the points but colorField input does not work with line chart.

Here is a plnkr using color input:
http://plnkr.co/edit/bx4lTJLNz2ZCr7JLhqt7?p=preview

My goal is to set specific color for the whole line but not only the points.

Bug charts

Most helpful comment

Thanks for reporting this issue. The workaround for the moment is to use a hashmap instead of function, see plunkr:

<kendo-chart-series-item *ngFor="let d of data" ... [color]="seriesColors[d.name]">
export class AppComponent {
  seriesColors = {
    'a' : '#0000ff',
    'b' : '#00ff00',
    'c' : '#ff0000'
  }
}

All 3 comments

Thanks for reporting this issue. The workaround for the moment is to use a hashmap instead of function, see plunkr:

<kendo-chart-series-item *ngFor="let d of data" ... [color]="seriesColors[d.name]">
export class AppComponent {
  seriesColors = {
    'a' : '#0000ff',
    'b' : '#00ff00',
    'c' : '#ff0000'
  }
}

We discussed this issue and came to the conclusion that the current behavior is correct. The line is considered a single entity and can only have a single color, set statically.

What happens in this case is that marker.color is aliased to color and is evaluated per-point. This can be confusing and should be addressed in the docs.

Thanks for reporting this issue. The workaround for the moment is to use a hashmap instead of function, see plunkr:

<kendo-chart-series-item *ngFor="let d of data" ... [color]="seriesColors[d.name]">
export class AppComponent {
  seriesColors = {
    'a' : '#0000ff',
    'b' : '#00ff00',
    'c' : '#ff0000'
  }
}

Workaround works perfect.

Was this page helpful?
0 / 5 - 0 ratings