Chart.js - Styling Legend

后端 未结 5 905
耶瑟儿~
耶瑟儿~ 2021-01-07 17:29

I\'m making a chart with chart.js and I\'m trying to figure out how I can change the label/legend styling. I want to remove the rectangle part and instead use a circle. I\'v

5条回答
  •  忘掉有多难
    2021-01-07 17:39

    Use usePointStyle:true

    var ctx = document.getElementById("myChart");
    var myChart = new Chart(ctx, {
    type: 'line',
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: 'Link One',
            data: [1, 2, 3, 2, 1, 1.5, 1],
            backgroundColor: [
                '#D3E4F3'
            ],
            borderColor: [
                '#D3E4F3',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        legend: {
            display: true,
          position: 'bottom',
            labels: {
                fontColor: '#333',
                usePointStyle:true
            }
        }
    }
    

    });

提交回复
热议问题