Chartjs:2个线系列React图之间的颜色填充重叠

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

当在2个线序列之间填充颜色时,填充颜色与点重叠。

https://codesandbox.io/s/react-chartjs-2-line-chart-example-forked-5ruj86
我在版本3.6.0中遇到此问题。

v7pvogib

v7pvogib1#

只需将order属性添加到第一个数据集即可。文档

const data = {
  labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
  datasets: [
    {
      data: [1000000, 900000, 800000, 750000, 700000, 650000, 600000],
      color: "#008484",
      backgroundColor: "#A5E1D2",
      pointBorderColor: "#007B5E",
      pointBackgroundColor: "#ffffff",
      borderColor: "#008484",
      fill: 1,
      borderWidth: 3,
      pointRadius: 5,
      pointHoverRadius: 5,
      pointBorderRadius: 5,
      order: 1
    },
    {
      data: [800000, 700000, 600000, 550000, 500000, 450000, 400000],
      color: "#002E2E",
      backgroundColor: "#A5E1D2",
      pointBorderColor: "#002E2E",
      pointBackgroundColor: "#ffffff",
      borderColor: "#002E2E",
      fill: 1,
      borderWidth: 3,
      pointRadius: 5,
      pointHoverRadius: 5,
      pointBorderRadius: 5
    }
  ]
};

checkout codesandbox

相关问题