How to use react-chartjs in html file

686 views Asked by At

Can anyone know how use react-chartjs?

I have import the module and dependent modules

But still get

"Uncaught ReferenceError: Line is not defined"

Here is my sample code of html file

The most examples I found is to use another .js file to import it

Is that the only way to use react-chartjs?

<!DOCTYPE html>
<html>
  <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react-dom.min.js"></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js'></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/react-chartjs/0.8.0/react-chartjs.min.js'></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.1/babel.min.js"></script>
  </head>
  <body>
    <script type="text/jsx">
    class Test extends React.Component {
        render() {
            var DayData = {
                labels : ['a','b'],
                datasets : [
                    {
                    data : [1,2]
                    }
                ]
            };
            var options={
                responsive: false};
            return (
                <div>
                    <Line id='b' name='a' data={DayData} redraw/> 
                </div>
            );
        }
    }
    ReactDOM.render(
        <Test/>,
        document.getElementById('Test')
    );
    </script>
    <div id="Test">Test</div>
  </body>
</html>

0

There are 0 answers