Skip to content Skip to sidebar Skip to footer

How To Import Chartist In React Component?

I am trying to use charts from chartist.js link: https://gionkunz.github.io/chartist-js/examples.html#simple-line-chart When I try to use them in my code I am getting Chartist to d

Solution 1:

Run

npm install react-chartist --save

One more thing, you need to install chartist also as it is the dependency

npm install chartist --save.

Then you will be able to import Chartist into your application.

import chartistGraph from"react-chartist";

Here is the link how it can be implemented in codesandbox. codesandbox Link

Follow this link for the implementation Link

Solution 2:

You can import ChartistGraph from 'react-chartist' as:

importChartistGraphfrom'react-chartist';

or

varChartistGraph = require('react-chartist')

Also, 'react-chartist' doesn't include the css files for Chartist, so if you want to add the styles then add this in your index.html file:

<linkrel="stylesheet"href="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.css"><scriptsrc="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.js</script>

Or you can install 'chartist' package

 npm install chartist

See this link for decription

Post a Comment for "How To Import Chartist In React Component?"