Facing issues in using chartjs react library in fdk cli

I am using Chartjs react library cdn link in index.html and using HorizontalBar component in js file.

<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js"></script>

I am rendering the HorizontalBar component in the following way in one of the js file.

render() {
    return (
          <HorizontalBar   
    );
  }

but it is showing the following error

I would like to know how we can include or use the HorizontalBar component as it is a part of react-chartjs lib

1 Like

@Rashmi7653 - Welcome to the community :tada:

Although I lack some React skills, I have requested one of our relavant teams to get back to you with your query. Hoping that it might help you make some progress please refer to this sample app

Just to clarify, Can you confirm if this works as fine without CLI ?

3 Likes

I referred this sample app and built the application and yes it works fine without cli.

1 Like

hey @Rashmi7653,

if my understanding is correct, you can make chart.js work with the CDN version of the react but with the CLI version, the chart.js doesn’t work?

1 Like

In react app chart.js is working fine and I used the cdn version of react chart.js and tried to build it in cli, but it is not working in cli.

@Rashmi7653,

It might be due to the reason that the interface exposed by chart.js are not loaded when the react app loads, could you try loading the chart.js CDN using useEffect() hook after the app loads.

1 Like

okay thank you… i will try once.