As the title tells, I want to use chart.js with date-fns adapter without node.js.
I downloaded npm package manager and installed in my project folder.
In my HTML File with my chart.js chart I imported the script:
<script type="text/javascript" src="node\node_modules\chartjs-adapter-date-fns\dist\chartjs-adapter-date-fns.bundle.js"></script>
Everything is working so far and my chart is displayed and formated with date-fns. But now I want to use the localization feature of date-fns and want the chart for example in german.
chart.js documentation tells me to use following code (https://github.com/chartjs/chartjs-adapter-date-fns):
// import date-fns locale:
import {de} from 'date-fns/locale';
// scale options:
{
adapters: {
date: {
locale: de
}
}
}
I dont understand how/where I can import the module or what is the correct syntax. I just simply want to a js script and no environtment.
"import {de} from 'date-fns/locale';
After putting this in my HTML file / chart.js code, leaving the "import code" the chart is not showing up and the browser tells me following error message:
uncaught ReferenceError: de is not defined
at (index):313:21
Also really hard to find could tutorials etc. Chart.js & date-fns documentation require a lot of knowledge and are not very helpfull. So anyone can give me a clue how to import "locale".