nagix / chartjs-plugin-style

Chart.js plugin for more styling options
MIT License
67 stars 19 forks source link

Make the module exportable #7

Closed koprivajakub closed 5 years ago

koprivajakub commented 5 years ago

Is there a way how to import your code into a react application without use of HTML <script> tag? I would like to use it in my application that is written in the react, but I am using the native chartjs on one page. I would like to have the option like with chartjs-plugin-datalabels that it will register itself once the module is imported:

import Chart from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels.js';

and in case I need I can unregister it via:

Chart.plugins.unregister(ChartPluginStyle);
nagix commented 5 years ago

To enable this plugin, just import it like this.

import 'chartjs-plugin-style';

But nothing is explicitly exported currently, I will update the code.

nagix commented 5 years ago

I realize that there is no need to unregister the plugin because it doesn't affect the default appearance unless you specify any options unlike chartjs-plugin-datalabels. So, I believe importing the plugin as shown above is just enough.

koprivajakub commented 5 years ago

Yes, you are right. The import work, sorry for the opened issue. I will keep it up to you if you want to close the issue or make the code exportable. Maybe you might want to at least update the documentation that is clear how to import the plugin 👍

nagix commented 5 years ago

Yes, the documentation definitely needs to be updated. Thanks for the feedback!