Redraw chart on click
See original GitHub issueHow can I redraw my chart on click? My template has options to display the width of a column on toggling a button, however the chart is not updating, only if I resize the browser will it redraw.
Here’s my code:
<script>
var chart = new Chartist.Line('#chart', {
labels: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
series: [
[12, 12, 12, 13, 14, 16, 18, 20, 21, 20, 22, 22],
[14, 14, 15, 16, 15, 17, 17, 18, 18, 19, 20, 21],
[16, 16, 17, 18, 19, 20, 22, 23, 22, 21, 21, 23]
]
}, {
low: 12,
showArea: true,
fullWidth: true,
axisX: {
//showGrid: false
},
axisY: {
offset: 30,
onlyInteger: true,
labelInterpolationFnc: function (value) {
return '$' + value + 'k';
}
},
plugins: [
Chartist.plugins.tooltip(),
Chartist.plugins.legend({
legendNames: ['Investments', 'Returns', 'Interest'],
})
]
});
chart.on('draw', function (data) {
if (data.type === 'line' || data.type === 'area') {
data.element.animate({
d: {
begin: 500 * data.index,
dur: 500,
from: data.path.clone().scale(1, 0).translate(0, data.chartRect.height()).stringify(),
to: data.path.clone().stringify(),
easing: Chartist.Svg.Easing.easeOutQuint
}
});
}
});
</script>
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
Google chart redraw onclick - Stack Overflow
I can't seem to find a way to pass new data in the chart on a click event. I got it working so...
Read more >chart.events.redraw | highcharts API Reference
Information on the clicked spot can be found through event. ... Fires when the chart is redrawn, either after a call to chart.redraw()...
Read more >How to use the redraw method of chart? | jQuery - ejChart
The redraw method is used to dynamically refresh the chart content and redraw the chart based on the updated values. Refer to the...
Read more >Updating Charts - Chart.js
It's pretty common to want to update charts after they've been created. When the chart data or options are changed, Chart.js will animate...
Read more >Onclick Button Change Chart Type in Chart JS - YouTube
In this video we will explore how to use buttons with onclick function to change the chart type. We will explore why the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
[solved] added setTimeout and is working now.
Hi gionkunz,
Actually I have 3 charts on the page so How can i use the chart.update() function to update all charts. currently its update the last chart only. I am using id base charts , any more solution ?
Thanks