100% Stacked Bar chart - assign same colour every time

1 Answer 146 Views
Charts
Karthik
Top achievements
Rank 1
Karthik asked on 12 Dec 2022, 06:41 PM | edited on 12 Dec 2022, 06:42 PM

hi,

I have a 100% Stacked Bar chart that displays various 'States'. I would like to assign same colour to those states even when toggled. For example, green should assigned only to 'Complete' state.  Having 'SeriesColor' at 'kendo-chart' component level doesn't work. Any idea how to achieve this?

Please see stackblitz example in the link below
https://stackblitz.com/edit/angular-10-thmpbt-bfoybs?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html

With Toggle On - green is assigned to 'Complete' state

With toggle off - orange is assigned to Complete state. But I need green to remain for Complete

Regards
Karthik

1 Answer, 1 is accepted

Sort by
1
Accepted
Stoyan
Telerik team
answered on 15 Dec 2022, 12:28 PM

Hi Karthik,

Thanks for the provided information and snapshots.

The reason why the color of the Complete state is changing is because the seriesColors property is assigning only the first HEX color because there is only one state (in this scenario the Complete state) when the "Include Complete" checkbox is ticked off.

To keep the green color for the Complete state when the logic inside onIncludeCompleteStateChangedEvent method executes, create a variable which will hold initially the first three colors for each state and when the checkbox is ticked on / off, modify the variable and pass what colors should it mentain.

I've created a short StackBlitz demo that demonstrates the said above:

https://stackblitz.com/edit/angular-10-thmpbt-bjjjfl?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html

I hope this helps. 

Regards,
Stoyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Karthik
Top achievements
Rank 1
commented on 19 Dec 2022, 02:09 PM

That worked. Thanks Stoyan.

-Karthik

Tags
Charts
Asked by
Karthik
Top achievements
Rank 1
Answers by
Stoyan
Telerik team
Share this question
or