Closed ZakariaHili closed 7 years ago
If what you're working with is using a canvas, I'm afraid it won't work. There is no support for that in this library, it's just a lightweight DOM shim really. Sorry about that!
Thank you for your reply, but I found another solution without react faux dom, Here's the solution for person who faced the same issue (To avoid asking the same question)
import React from 'react';
import Chart from 'chart.js';
import ReactDOM from 'react-dom';
class ChartComponent extends React.Component {
componentDidMount() {
this.initializeChart(this.props.config);
}
initializeChart(options) {
let el = ReactDOM.findDOMNode(this.refs.chart);
let ctx = el.getContext("2d");
let chart = new Chart(ctx, options);
}
render() {
return (<canvas ref="chart" height="400px" />);
}
}
```export default ChartComponent;
Hi, I want to use ReadtFauxDom with chartJS, but the chartJS doesn't render anything(FauxDom is empty), I think this pb is due to the fact that ReactFauxDOM.element('canvas').getContext('2d') doesn't existe (I am not sure)
What do you think ?
here the code:
NB: I'm using
"chart.js": "^2.5.0", "react-faux-dom": "^3.0.1"