Search code examples
angularwebpackjhipsterwebpack-2html-webpack-plugin

How to use chart.js with jhipster project


So i want to try out Chat.js with the following project.

https://github.com/mraible/jhipster4-demo

So i researched and came across the following http://valor-software.com/ng2-charts/

So i installed ng-2 charts. ng2-charts required chart.js so I also installed chart.js and i can see it under node_modules of jhipster4-demo project.

ng2 chart says

Embedding Chart.js in application is mandatory!

<script src="node_modules/chart.js/src/chart.js"></script>

How to do the above mandatory step in jhipster4-demo project ? Since i am not a webpack expert not sure how to do this.


Solution

  • Import your libs into src/main/webapp/app/vendor.ts:

    import 'chart.js/src/chart.js';
    

    This is what is explained in the "Managing dependencies" section of the README.md file also generated in Matt Raible's demo application.