and1lea
Posts: 3
Joined: Wed Aug 03, 2022 11:57 am

Do it posible show legend of Gantt chart based on data values

Tue Aug 16, 2022 8:37 am

Hi all,

Do it posible show legend of Gantt chart based on data values? Because I have only one serie and I need a legend for every object in data.
Serie example:
series: [
{
type: 'gantt',
data: [{
y: 0,
start: Date.UTC(2018, 1, 2, 15, 30, 15),
end: Date.UTC(2018, 1, 2, 15, 33, 10),
name: 'StandBy',
},
...
{
y: 0,
start: Date.UTC(2018, 1, 2, 15, 33, 16),
end: Date.UTC(2018, 1, 2, 15, 38, 19),
name: 'Complete',
}
}]
]

User avatar
michal.f
Posts: 745
Joined: Thu Aug 12, 2021 12:04 pm

Re: Do it posible show legend of Gantt chart based on data values

Wed Aug 17, 2022 9:25 am

Hello,

You could split series, so each point will have its own series. Name series the same as point name.

And in order for the data symbols of the legend elements to be displayed correctly, you can use a wrap to that, based on the custom legendColor property in a given series, will set the appropriate color.

Demo: https://jsfiddle.net/BlackLabel/1h78yzwb/
More about Extending Highcharts: https://www.highcharts.com/docs/extendi ... highcharts

Let me know if you have any further questions!
Best regards!
Michał Filipiec
Highcharts Developer

and1lea
Posts: 3
Joined: Wed Aug 03, 2022 11:57 am

Re: Do it posible show legend of Gantt chart based on data values

Fri Aug 19, 2022 8:36 am

michal.f wrote:
Wed Aug 17, 2022 9:25 am
Hello,

You could split series, so each point will have its own series. Name series the same as point name.

And in order for the data symbols of the legend elements to be displayed correctly, you can use a wrap to that, based on the custom legendColor property in a given series, will set the appropriate color.

Demo: https://jsfiddle.net/BlackLabel/1h78yzwb/
More about Extending Highcharts: https://www.highcharts.com/docs/extendi ... highcharts

Let me know if you have any further questions!
Best regards!
Hi Michał,

Thank you for your answer

Actually that is not what I expected, because I need a inline graph, so that means that here should be only one serie.

pawelys
Posts: 962
Joined: Wed Sep 02, 2020 10:37 am

Re: Do it posible show legend of Gantt chart based on data values

Mon Aug 22, 2022 9:08 am

Hi! If what @michal.f suggested doesn't work for you, The Tooltip has a formatter function, which allows you to format each point differently.
Here is an example: https://jsfiddle.net/BlackLabel/1h78yzwb/1/

Let me know if that works for you!
Kind regards,
Paweł Lysy
Highcharts Developer

Return to “Highcharts Gantt”