ChartJS 图表J中的图例不显示

syqv5f0l  于 2022-11-07  发布在  Chart.js
关注(0)|答案(1)|浏览(214)

图例没有显示在图表JS,我已经阅读了文档和其他人,但什么都没有...只有标签中,你键入了一个短语显示。我知道这是非常简单的东西,但它让我浪费我的时间。my chart
编码:

type: 'bar',
                data: {
                    labels: [{% for elemento1 in mesesEvolucion %}'{{ elemento1 }}',{% endfor %} ],
                    datasets: [{
                            label: 'Evolucion de el último año',
                            data: [{% for elemento1 in elemento.datosGraficaEvolucion %}{{ elemento1.mesX }},{% endfor %} ],
                            backgroundColor: [
                                'rgba(255, 99, 132, 0.2)',
                                'rgba(54, 162, 235, 0.2)',
                                'rgba(255, 206, 86, 0.2)',
                                'rgba(75, 192, 192, 0.2)',
                                'rgba(153, 102, 255, 0.2)',
                                'rgba(255, 159, 64, 0.2)'
                            ],
                            borderColor: [
                                'rgba(255, 99, 132, 1)',
                                '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: {
                    scales: {
                        y: {
                            beginAtZero: true,
                            ticks: {color: 'white'}
                        },
                        x: {
                            beginAtZero: true,
                            ticks: {color: 'white'}
                        }
                    },
                    plugins: {
                        legend: {
                            display: true,
                            labels: {
                                color: 'rgb(255, 255, 255)'
                            }
                        },
                        title: {
                            display: true,
                            text: 'Evolución anual',
                            color: '#FFFFFF',
                            font: {
                                size: '14'
                            }
                        }
                    }
                }
vs3odd8k

vs3odd8k1#

试试看:

plugins: {
    legend: {
      position: "top",
      display: true,
        labels: {
          color: "#0d6dfdb0",
          font: {
            family: "IRANSansWeb" 
          }
        },
        tooltip: {
          bodyFont: {
            family: "IRANSansWeb" 
          },
          titleFont: {
            family: "IRANSansWeb" 
          }
        }

    },
    title: {
      display: true,
      text: "some title",
      color: "rgb(16, 97, 219)",
      font: {
        family: "IRANSansWeb",
      },
    },
  },

相关问题