dpkang
Posts: 6
Joined: Tue Feb 02, 2021 6:32 am

Legend symbol border add permanent

A border is added to the legend symbol and it is initialized at the x coordinate or update.
I would like to know how to add a border permanently.

http://jsfiddle.net/4k5Lpqjx/


Take good care of me.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Legend symbol border add permanent

Hello dpkang!

We appreciate you reaching out to us!

As far as I know, there is no API option that could add a border to the legend symbol, so I guess modifying the attributes of the symbol is the best way to achieve that (lines 21 and 22 in your demo).

Code: Select all

function(chart) {
    var series = chart.series;
    $.each(series, function(i,ser) {
      $(ser.legendSymbol.element).attr('stroke-width','1');
      $(ser.legendSymbol.element).attr('stroke','black');
    });
  });


Best regards!
Dominik Chudy
Highcharts Developer
dpkang
Posts: 6
Joined: Tue Feb 02, 2021 6:32 am

Re: Legend symbol border add permanent

When you use getSvg, the property value disappears.

Is there any way to make sure it doesn't disappear from this part?

Best regards!
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Legend symbol border add permanent

Hi again!

As far as I know, there shouldn't be a problem to change a part of the SVG element of the chart and then use getSVG method on the whole chart (https://api.highcharts.com/class-refere ... art#getSVG)

Could you reproduce this problem? How do you use getSVG method? In your demo, there's no getSVG method. :-)

Best regards!
Dominik Chudy
Highcharts Developer
dpkang
Posts: 6
Joined: Tue Feb 02, 2021 6:32 am

Re: Legend symbol border add permanent

http://jsfiddle.net/Lnmtqakj/

'1' After button click
It disappears when I do svg.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Legend symbol border add permanent

Hi again!

getSVG() method creates a new chart that is fully based on the config of the chart it's being built from. So when the way we added the border before wasn't visible for getSVG() method. In this case, we need to change the core code, so the border will be applied when we use getSVG().

Simplified demo: https://jsfiddle.net/BlackLabel/mvanzseL/

Best regards!
Dominik Chudy
Highcharts Developer

Return to “Highcharts Stock”