How scale sector in doughnut chartjs on hover?

戏子无情 提交于 2021-02-11 13:54:54

问题


How scale sector in doughnut chartjs on hover? Example:


回答1:


The simplest solution would be to define different borderWidth and hoverBorderWidth on your dataset as follows.

new Chart(document.getElementById('myChart'), {
  type: 'doughnut',
  data: {
    labels: ['red', 'green', 'gray', 'blue'],
    datasets: [{
      label: 'My First dataset',
      backgroundColor: ['red', 'green', 'gray', 'blue'],
      borderColor: 'white',
      data: [3, 4, 5, 3],
      borderWidth: 4,
      hoverBorderWidth: 0,
      borderAlign: 'center'
    }]
  },
  options: {
     responsive:true,
     cutoutPercentage: 65
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
<canvas id="myChart"></canvas>


来源:https://stackoverflow.com/questions/61519920/how-scale-sector-in-doughnut-chartjs-on-hover

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!