1

I have stock chart and first legend's item is OHLC which is displayed like this:

o:60.11, h:70.11, l:40.11, c:50.11

other legend's items are short like this

55.11

If I want to legend items not overlap, I need to set legend.valueWidth or legend.spacing as long as is needed for to the first item not overlap the second. Than other items has the same space which is not needed and sometime legend is on two rows.

What I want to achieve is that every legend item will have only space it needs or to set extraspace for first item.

koubin
  • 579
  • 5
  • 9
  • 30

3 Answers3

1

Keep your legend div separate from chart div and then add legend div to chart

chart.addLegend(legend, "legenddiv");
Harry
  • 87,580
  • 25
  • 202
  • 214
LHH
  • 3,233
  • 1
  • 20
  • 27
0

Try reducing "labelWidth" and "valueWidth" to fit just the content : source

Community
  • 1
  • 1
saber tabatabaee yazdi
  • 4,404
  • 3
  • 42
  • 58
0

Use this property : markerLabelGap markerLabelGap : Number Space between legend marker and legend text, in pixels.

Sample amchart:

 var chart = AmCharts.makeChart("chartdiv", {

            "type": "serial", "theme": "light",
            "legend": {
                "equalWidths": false,/*نمایش آیتم ها در یک سطر  */
                "pulled":true,
                "align": "left",
               
                "position": "bottom",
             
                "markerType": "circle",
              
                "labelText": "[[title]]",             
                "rollOverGraphAlpha":80,
                "markerLabelGap": 80,//تعیین فاصله بین مارکر و لیبل ها در لجند
              
                "textClickEnabled": true
            },
             ...

See More Properties: https://docs.amcharts.com/javascriptstockchart/LegendSettings