reactjs / react-chartjs

common react charting components using chart.js
MIT License
2.93k stars 301 forks source link

Horizontal Bar chart #159

Closed openmohan closed 6 years ago

openmohan commented 7 years ago

render(){ var ctx= document.getElementById("test") var myBarChart = new Chart(ctx, { type: 'horizontalBar', data: data, options: options }); } return (

)

Even though I give this , the code in the component get executed before the document gets loaded . So "ctx" will be null . I need to use without Jquery plugin.

ashutoshjha1409 commented 7 years ago

Initialise chart in componentDidMount()

For E.g

componentDidMount(){ var ctx= document.getElementById("test"); var myBarChart = new Chart(ctx, { type: 'horizontalBar', data: data, options: options }); } }

Sorry, can't indent properly

openmohan commented 7 years ago

Thanks @ashutoshjha1409 . Forgot that completely

Jareechang commented 6 years ago

This will be available in react-chartjs 2.0 once we have a stable version. Please see branch chartjs-v2.