ChartJS如何改善移动的自来水区

wmtdaxz3  于 2023-06-22  发布在  Chart.js
关注(0)|答案(1)|浏览(169)

我的一些用户提到很难点击图表点来查看其工具提示数据。有没有办法增加可点击点的面积?

envsm3lx

envsm3lx1#

您可以将pointHitRadius设置为更大的数字:

const options = {
  type: 'line',
  data: {
    labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
    datasets: [{
        label: '# of Votes',
        data: [12, 19, 3, 5, 2, 3],
        pointHitRadius: 25
      },
      {
        label: '# of Points',
        data: [7, 11, 5, 8, 3, 7],
        pointHitRadius: 25
      }
    ]
  },
  options: {}
}

const ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.2.0/chart.umd.js"></script>

<body>
  <canvas id="chartJSContainer" width="600" height="400"></canvas>
</body>

相关问题