javascript - How to convert a div to a canvas using ReactJS? -


xcharts js uses css classes converted html 5 canvas once javascript interpreted.

i wondering if reactjs knows how handle such type of component?

when write <div> containing class canvas conversion inside render method, react return <div> , not canvas containing chart.

here code:

render: function(){   if (!this.state.data) {     return <div>loading...</div>;   }   return(     <div classname="col-lg-3 col-sm-6 col-xs-6 col-xxs-12">       <div classname="smallstat box">         <div classname="boxchart-overlay red">        <!-- div underneath should convert canvas -->        <div classname="boxchart">5,6,7,2,0,4,2,4,8,2,3,3,2</div>          </div>           <span classname="title">transactions</span>         <span classname="value">{this.state.data.globalpnl}</span>       </div>     </div>   ); } 

this expected result <div>

<canvas class="flot-overlay"     style="direction: ltr; position: absolute; left: 0px; top: 0px; width: 619px; height: 300px;"     width="1238" height="600"> </canvas> 

am missing something?

according xchart docs need make call initialize chart:

var mychart = new xchart('bar', data, '#mychart'); 

if you're doing this, have verified element exists in dom @ point in time chart being initialized? might try initializing chart in componentdidupdate


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -