Highcharts: Make the legend symbol a square or rectangle

前端 未结 7 1969
盖世英雄少女心
盖世英雄少女心 2020-12-16 15:20

I am trying to Make the legend symbol a square or rectangle for a line graph. Example

\"enter

7条回答
  •  抹茶落季
    2020-12-16 15:56

    You can make a fake series as follows and provider marker to it.

    $(function () {
    var chart = new Highcharts.Chart({
        chart: {
        renderTo: 'container',
        type: 'line',
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },
    
        plotOptions: {
            series: {
                marker: {
                    enabled: true
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
    
            //borderWidth: 0
        },
    
        series: [{
    
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
            showInLegend : false,
    
    
            marker:{enabled:false}
    
        },{
            name : "testing",
            data : {},
            marker : {symbol : 'square',radius : 12 }
        }
                ]
    });
    });
    

    Working demo : DEMO

提交回复
热议问题