ecem
Posts: 6
Joined: Mon Feb 08, 2021 11:07 pm

Network Graph Legend Problem

Hello, I am having a problem with creating a legend to a network graph. I want to have more than one series in the legend but I couldn't find any reference regarding this. I have a network graph and I assigned four different colours to the nodes manually. When I enable the legend, series1 appears below the graph. By clicking it I can turn on and off the whole graph. But this is not what I want. I have four colours (categories) and I want to have a legend according to these. Thank you in advance. I would appreciate your help.
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Network Graph Legend Problem

Hi,
Welcome to our forum and thanks for contacting us with your question.

You can choose options showInLegend: true to show series in legend and on the example I show you how to add another series as object.

Live demo:
https://jsfiddle.net/BlackLabel/c9uqthgm/

API References:
https://api.highcharts.com/highcharts/s ... owInLegend

Let me know if this solution helps you.
Best regards.
Sebastian Hajdus
Highcharts Developer
ecem
Posts: 6
Joined: Mon Feb 08, 2021 11:07 pm

Re: Network Graph Legend Problem

Hello Sebastian,

Thank you for your quick reply!

I looked at your demo but it will not work for me. Because I want to have only one network graph (connected leaves). And I want to have a legend for four colours that I assigned to my network graph. Is this possible? Thank you for your time.

Kind Regards
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Network Graph Legend Problem

Hi,

Could you explain what do you mean?
And I want to have a legend for four colors that I assigned to my network graph

You can also share your example on the online code editor that we can work on it and better understand your case.

Best regards.
Sebastian Hajdus
Highcharts Developer
ecem
Posts: 6
Joined: Mon Feb 08, 2021 11:07 pm

Re: Network Graph Legend Problem

Hi,

I have a network graph where I manually assigned colours to nodes. And I want to create a legend for these colours. I have only one series. When I use showInLegend: true, it shows only one item in the legend.

Is it possible to have a custom legend? Without creating other series?

Thank you,

Kind Regards.
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Network Graph Legend Problem

Hi,

Do you want to show each point with different colors on the legend, yes?
Could you show me your network graph on a simplified example?

For eddit legend you can try use legend.labelFormatter.
https://api.highcharts.com/highcharts/l ... lFormatter

I'm waiting for news from you.
Best regards.
Sebastian Hajdus
Highcharts Developer
Kingsley
Posts: 1
Joined: Sun Nov 28, 2021 6:58 am

Re: Network Graph Legend Problem

HII i have the same issues, can i ask do you able to solve that?
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Network Graph Legend Problem

Hello Kingsley,

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

Solutions suggested by my colleague sebastian.h are still viable, if you want to show all series in your legend then you should assign them with showInLegend: true option. If you want to edit default legend labels then you should use legend.labelFormatter callback. If you want to edit legend even further then you will most likely have to create your own custom legend, but it really depends on what exactly do you want to achieve. Please check these docs for all available options thoroughly: https://api.highcharts.com/highcharts/legend.

I could tell some more specific solution but first I need you to provide me with simplified demo of your chart and more details about your expected results. You can start here:https://jsfiddle.net/BlackLabel/g96kt8jo/

Regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Usage”