Change size of legend symbol

北战南征 提交于 2019-12-11 08:06:37

问题


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

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.


回答1:


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/




回答2:


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




回答3:


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;
        }
    },
/////


来源:https://stackoverflow.com/questions/46406947/change-size-of-legend-symbol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!