yyshah
Posts: 6
Joined: Tue Jan 25, 2022 8:35 pm

Gantt chart legend based on a <key> within data

Hello,

I am trying to create a custom legend based on a certain field.

In below example, the event data has a "status" field for each event which can be active / inactive. https://jsfiddle.net/YameenYasin/hnopLwtb/57/
Is there a way we can creeate a legend based on status field -- Active / InActive without altering the order in which the data is displayed ?


Thanks
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Gantt chart legend based on a <key> within data

Hello,

Welcome to our forum and thanks for contacting us with your question!

You can break it down into two series, active and inactive users.
Demo: https://jsfiddle.net/BlackLabel/fmsxe3nq/

Let me know if that was what you were looking for!
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
yyshah
Posts: 6
Joined: Tue Jan 25, 2022 8:35 pm

Re: Gantt chart legend based on a <key> within data

Thanks for your response.

Is there a way we can preserve the initial sort order ?
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Gantt chart legend based on a <key> within data

Hi,

Yes, it is possible using the data.y property, but first you need to define categories for the yAxis.

Demo: https://jsfiddle.net/BlackLabel/r0hbwd8z/
API: https://api.highcharts.com/gantt/series.gantt.data.y

Feel free to ask any further questions!
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
yyshah
Posts: 6
Joined: Tue Jan 25, 2022 8:35 pm

Re: Gantt chart legend based on a <key> within data

Thanks for your response. This is exactly what i was looking for. Appreciate it
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Gantt chart legend based on a <key> within data

You're welcome! In case of any further questions, feel free to contact us again.

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Gantt”