• <small id='qorDB'></small><noframes id='qorDB'>

    <i id='qorDB'><tr id='qorDB'><dt id='qorDB'><q id='qorDB'><span id='qorDB'><b id='qorDB'><form id='qorDB'><ins id='qorDB'></ins><ul id='qorDB'></ul><sub id='qorDB'></sub></form><legend id='qorDB'></legend><bdo id='qorDB'><pre id='qorDB'><center id='qorDB'></center></pre></bdo></b><th id='qorDB'></th></span></q></dt></tr></i><div id='qorDB'><tfoot id='qorDB'></tfoot><dl id='qorDB'><fieldset id='qorDB'></fieldset></dl></div>
    <legend id='qorDB'><style id='qorDB'><dir id='qorDB'><q id='qorDB'></q></dir></style></legend>
      <tfoot id='qorDB'></tfoot>
        • <bdo id='qorDB'></bdo><ul id='qorDB'></ul>

        如何将光标样式更改为悬停在图表点上的指针?

        时间:2023-11-02
        <tfoot id='foNUl'></tfoot>

          <bdo id='foNUl'></bdo><ul id='foNUl'></ul>

            1. <legend id='foNUl'><style id='foNUl'><dir id='foNUl'><q id='foNUl'></q></dir></style></legend>

              <i id='foNUl'><tr id='foNUl'><dt id='foNUl'><q id='foNUl'><span id='foNUl'><b id='foNUl'><form id='foNUl'><ins id='foNUl'></ins><ul id='foNUl'></ul><sub id='foNUl'></sub></form><legend id='foNUl'></legend><bdo id='foNUl'><pre id='foNUl'><center id='foNUl'></center></pre></bdo></b><th id='foNUl'></th></span></q></dt></tr></i><div id='foNUl'><tfoot id='foNUl'></tfoot><dl id='foNUl'><fieldset id='foNUl'></fieldset></dl></div>

              • <small id='foNUl'></small><noframes id='foNUl'>

                    <tbody id='foNUl'></tbody>
                  本文介绍了如何将光标样式更改为悬停在图表点上的指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 chart.js v.2.库,当用户将鼠标悬停在图表点上时,我试图将光标样式更改为指针".(我将把它与条形图、饼图、折线图一起使用).在charts.js v.2 中似乎应该支持这个选项.但我在任何地方都找不到一个例子.

                  I am using chart.js v.2. library and I am trying to change the cursor style to 'pointer' when the user is hovering over points of chart. (I am going to use this with bar, pie, line charts). It seems that there should be support for this option in charts.js v.2. but I can't find an example anywhere.

                  我没有提到我正在使用带有 react 的图表,更具体地说,我正在使用这个 react 包装器.

                  I did not mention that I was using chart with react, to be more specific I am using this react wrapper.

                  我正在导入例如图表线 import { Line } from 'react-chartjs-2';

                  I am importing e.g. chart Line import { Line } from 'react-chartjs-2';

                  class ChartTimelineChart extends Component {
                  
                  
                  
                  constructor(props){
                      super(props);
                  
                      this.options = {
                         responsive: true,
                         maintainAspectRatio: false,
                         animation: {
                              easing:  'easeOutCirc',
                              duration: 1000
                        },
                        pointStyle : 'circle',
                              scales: {
                                   xAxes: [{
                                       display: true,
                                       gridLines: {display: false},
                                       scaleLabel: {display: true}
                                  }],
                                  yAxes: [{
                                      display: true,
                                      gridLines: {display: false},
                                      ticks: {beginAtZero:true},
                                      scaleLabel: {display: true}
                                 }]
                             },
                        tooltips: {
                          displayColors: false
                        },
                        legend: false
                      };
                  
                  
                     searchChart(elem, props, data) {
                      //Something... 
                     }
                  
                    render(){
                  
                      return (
                          (this.props.selectedYears.length)
                          ? (  <div>
                            <Line data={this.props.selectedYearsData}
                                  redraw={true}
                                  options={this.options}
                                  getElementAtEvent={elem => this.searchChart(elem, this.props, this.props.selectedYearsData)} />
                          </div>)
                          : <Line data={{datasets: [], labels: []}}
                                  redraw={true}
                                  options={this.options} />
                      )
                    }
                  };
                  

                  推荐答案

                  对于 Chart.js 2.x,我使用这种方法.只需在选项中添加:

                  With Chart.js 2.x I use this approach. Just add this in the options:

                  onHover: (event, chartElement) => {
                      event.target.style.cursor = chartElement[0] ? 'pointer' : 'default';
                  }
                  

                  希望对你有帮助.

                  这篇关于如何将光标样式更改为悬停在图表点上的指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Chart.js t.ticks.map 不是函数 下一篇:具有区域范围的 Chart.js 折线图

                  相关文章

                    1. <tfoot id='1eG4G'></tfoot><legend id='1eG4G'><style id='1eG4G'><dir id='1eG4G'><q id='1eG4G'></q></dir></style></legend>
                      <i id='1eG4G'><tr id='1eG4G'><dt id='1eG4G'><q id='1eG4G'><span id='1eG4G'><b id='1eG4G'><form id='1eG4G'><ins id='1eG4G'></ins><ul id='1eG4G'></ul><sub id='1eG4G'></sub></form><legend id='1eG4G'></legend><bdo id='1eG4G'><pre id='1eG4G'><center id='1eG4G'></center></pre></bdo></b><th id='1eG4G'></th></span></q></dt></tr></i><div id='1eG4G'><tfoot id='1eG4G'></tfoot><dl id='1eG4G'><fieldset id='1eG4G'></fieldset></dl></div>
                    2. <small id='1eG4G'></small><noframes id='1eG4G'>

                        <bdo id='1eG4G'></bdo><ul id='1eG4G'></ul>