Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs react ChartList中的onDraw事件_Reactjs_Events_Chartist.js - Fatal编程技术网

Reactjs react ChartList中的onDraw事件

Reactjs react ChartList中的onDraw事件,reactjs,events,chartist.js,Reactjs,Events,Chartist.js,在另一个论坛中,我发现了这段代码,它对我很有用: var chart = new Chartist.Bar('.ct-chart', { labels: ['Test', 'Long test', 'Very long test'], series: [[1, 5, 3]] }); // Uncomment this line to test rendering without foreign objects //chart.supportsForeignObject = false;

在另一个论坛中,我发现了这段代码,它对我很有用:

var chart = new Chartist.Bar('.ct-chart', {
  labels: ['Test', 'Long test', 'Very long test'],
  series: [[1, 5, 3]]
});

// Uncomment this line to test rendering without foreign objects
//chart.supportsForeignObject = false;

chart.on('draw', function(event) {
  // If the draw event is for labels on the x-axis
  if(event.type === 'label' && event.axis.units.pos === 'x') {
    // If foreign object is NOT supported, we need to fallback to text-anchor and event.width / 2 offset.
    if(!chart.supportsForeignObject) {
      event.element.attr({
        x: event.x + event.width / 2,
        'text-anchor': 'middle'
      });
    }
  }
});
用它解决的特殊问题并不重要。我的问题是,在使用react ChartList时,我没有使用
new ChartList.Bar
来声明新的ChartList组件:

<ChartistGraph
          data={graphData}
          options={graphOptions}
          type={type}
/>

因此,我无法像示例中那样对onDraw事件做出反应。 是否可以将函数绑定到onDraw事件?我试过这样的方法:

<ChartistGraph
          onDraw={e => onDrawHandler(e)}
          data={graphData}
          options={graphOptions}
          type={type}
/>
onDrawHandler(e)}
数据={graphData}
选项={graphOptions}
类型={type}
/>

这不起作用。

使用
侦听器
道具:

<ChartistGraph
    listener={{
        draw: e => onDrawHandler(e)
    }}
    data={graphData}
    options={graphOptions}
    type={type}
/>
onDrawHandler(e)
}}
数据={graphData}
选项={graphOptions}
类型={type}
/>

请参阅:

有人能告诉我如何在reactjs中的窗口调整和onclick事件中阻止图表一次又一次地重新绘制吗?