Change size of legend symbol

2019-07-25 15:07发布

How do I change the size of the symbols in the legend? Right now they look like this:

enter image description here

I would like them to be squares approximately the same size as the titles. After looking at the docs, I thought changing symbolHeight, symbolRadius and symbolWidth would do the trick, but it doesn't. In fact these parameters don't change anything at all, as far as I can see.

3条回答
劫难
2楼-- · 2019-07-25 15:28

If you are using line series, you need change its legend symbol to column series legend symbol. Then you can use symbolHeight, symbolWidth and symbolRadius properties.

API Reference:
http://api.highcharts.com/highcharts/legend.symbolHeight
http://api.highcharts.com/highcharts/legend.symbolWidth
http://api.highcharts.com/highcharts/legend.symbolRadius

Example:
http://jsfiddle.net/x2vk088m/

查看更多
放我归山
3楼-- · 2019-07-25 15:35

No working demo provided using official spline-plot-bands demo

You can use css to achieve the requirement

.highcharts-legend-item path{
  stroke-width:10
}

fiddle demo

查看更多
虎瘦雄心在
4楼-- · 2019-07-25 15:39

Just use symbolHeight, symbolWidth in your config...

Something like this:

 ////////
    legend: {
        align: 'left',
        rtl: false,
        verticalAlign: 'top',
        useHTML: true,
        itemStyle: {
            'cursor': 'default',
            'font-weight': 'normal'
        },
        symbolWidth: 10, <<<<<//HERE
        symbolHeight: 2, <<<<<//HERE
        symbolRadius: 0, //creating square legend,
        labelFormatter: function() {
          return this.name;
        }
    },
/////
查看更多
登录 后发表回答