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

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

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

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

v7pvogib

v7pvogib1#

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

  1. const data = {
  2. labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
  3. datasets: [
  4. {
  5. data: [1000000, 900000, 800000, 750000, 700000, 650000, 600000],
  6. color: "#008484",
  7. backgroundColor: "#A5E1D2",
  8. pointBorderColor: "#007B5E",
  9. pointBackgroundColor: "#ffffff",
  10. borderColor: "#008484",
  11. fill: 1,
  12. borderWidth: 3,
  13. pointRadius: 5,
  14. pointHoverRadius: 5,
  15. pointBorderRadius: 5,
  16. order: 1
  17. },
  18. {
  19. data: [800000, 700000, 600000, 550000, 500000, 450000, 400000],
  20. color: "#002E2E",
  21. backgroundColor: "#A5E1D2",
  22. pointBorderColor: "#002E2E",
  23. pointBackgroundColor: "#ffffff",
  24. borderColor: "#002E2E",
  25. fill: 1,
  26. borderWidth: 3,
  27. pointRadius: 5,
  28. pointHoverRadius: 5,
  29. pointBorderRadius: 5
  30. }
  31. ]
  32. };

checkout codesandbox

展开查看全部

相关问题