Has anyone successfully used chartjs-adapter-luxon and luxon to do what I’m trying to do? (or maybe there’s a different way to solve this problem?)
I built a chart using the Chart.js plugin which I documented in this thread.
The y-axis is a numeric value while the x-axis is categorical (meaning the dates do not proportionally correspond to the tick marks and, in fact, there may be two of the same dates next to each other). The x values are strings in ISO date format (e.g. “2025-01-31”).
What I’d like, instead, is for the x-axis to display the month (like January-2025, then February-2025, etc) and for the points to land proportional to the date value. For example, a point with x value “2025-01-03” would be closer to the January-2025 tick mark than a point with x value of “2025-01-31”.
I am trying to figure this out using luxon and chartjs-adapter-luxon but it’s currently not working and I believe it’s because WeWeb may not be registering the chartjs-adapter-luxon date adapter (see error below)
What I’ve tried so far:
- Using the NPM plugin to install luxon and chartjs-adapter-luxon
- Using the instructions discussed on Convert Your Custom Tags to WeWeb Actions to create a workflow that loads the custom JavaScript from that website
- Forcing the adapter manually using Custom Code > Head:
<script>
window.addEventListener("load", () => {
if (window.Chart && window.luxon && window['chartjs-adapter-luxon']) {
Chart._adapters._date = window['chartjs-adapter-luxon'];
console.log("Manually registered Luxon adapter with Chart.js");
}
});
</script>