Hey guys, I’m trying to use ApexCharts following some tutorials I saw about other custom charts but is not working. Anybody knows how can I do this? Thank you in advance.
Something I’m trying to figure out right now is how to update the dataset of the chart with a function? I tried the one on the documentation but doesn’t update the dataset, remains the same.
function updateChartById(chartId, newOptions) {
// Get the chart instance by its ID
var chart = ApexCharts.getChartByID(chartId);
if (chart) {
// Update the chart if found
chart.updateOptions(newOptions, true, true);
console.log('Chart updated successfully');
} else {
console.error('Chart not found with ID:', chartId);
}
}
// Usage:
updateChartById("chart", variables['7210b5d5-d881-43ae-97f1-798e86825712']);
Calling the Weweb masters here @dorilama@raydeck do you guys know what would be the best way to achieve this? the chart creation is working, but I’m not able to update the dataset
If you want to update the chart each time the data changes. You need to wrap it in a reusable component and call your update function (redraw it) on variable change. There is an event for that, within the reusable component. You can even set the desired variable you want to listen to.
Ahh got it, so instead of having the action on page load, I would have it on component mount, so I can reset the component every time the data changes?