Hi all,
tldr
How to use plugins in Bootstrap studio?
I am new to the forum but old with bootstrap studio. I have been using this for couple of years and now I can’t figure the issue that I am facing and hopefully someone can help me.
In the past I have been using amCharts on my site but now I chose to move towards chartjs. Current version of the studio also has it implemented as UI tool but I need more and that is why I am using purely javascript.
Now I am facing issue since I can make chart with no issue but I can’t seem to add any plugins for the chart. I just can’t figure it out. I am trying to add zoom and pan functionality for my chart but it won’t happen… GitHub - chartjs/chartjs-plugin-zoom: Zoom and pan plugin for Chart.js
My script is from example
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3]
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
},
plugins: {
zoom: {
// Container for pan options
pan: {
// Boolean to enable panning
enabled: true,
// Panning directions. Remove the appropriate direction to disable
// Eg. 'y' would only allow panning in the y direction
mode: 'xy'
},
// Container for zoom options
zoom: {
// Boolean to enable zooming
enabled: true,
// Zooming directions. Remove the appropriate direction to disable
// Eg. 'y' would only allow zooming in the y direction
mode: 'xy',
}
}
}
}
});
And I am trying to initialize the zoom plugin prior the script with
Chart.plugins.register({
id: 'chartjs-plugin-zoom'
// ...
});
I can see the chart just fine but I can’t pan or zoom the cart! Here is codepen for the script
So please, how can I use plugins for charts in Bootstrap studio?
TIA,
Heikki