Set kendo-chart-series-item color

1 Answer 2316 Views
General Discussions
Aleksandr
Top achievements
Rank 1
Aleksandr asked on 28 Jun 2018, 03:14 AM

How could I change default color for a bar/column based on its value?

 

I was thinking that I could use "color" property of the kendo-chart-series-item (https://www.telerik.com/kendo-angular-ui/components/charts/api/SeriesItemComponent/)

"<kendo-chart-series-item type="column" [data]="data?.ColumnData?.slice(1)" axis="secondAxis" name="Packs" [color]="checkColor($point)">"

public checkColor(point) {
    console.log("Point:", point);
}

However when code runs "point" is undefined.

 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 Jun 2018, 09:00 AM
Hi,

The input should be set to a function reference in order for the function to be called for each point - example.

Regards,
Daniel
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
David
Top achievements
Rank 1
commented on 01 May 2019, 09:37 PM

Hi 

Is there a way to dynamically assign the chart series color based on a color array?  I want to assign each bar a color i define in my data ... the issue I have is the  function reference does not have access to "this" context ... 
In my sample 
    https://stackblitz.com/edit/angular-2m4hhy?file=app/app.component.ts

I want to return the color based on the index of my color array, like my attachment, using :
    return this.colors[point.index];

Daniel
Telerik team
commented on 03 May 2019, 10:23 AM

Hi,

You can use lambda function or bind the function context to access the component - update example.

Regards,
Daniel
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
David
Top achievements
Rank 1
commented on 06 May 2019, 06:44 PM

Thank you Daniel
Tags
General Discussions
Asked by
Aleksandr
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or