How to change Chartjs type dynamically
See original GitHub issueExpected Behavior
I wanna to define a vue component that include vue-chartjs
. I want to define prop as chart-type
that can be Line, Bar, etc like below code. In extend property I just add one chart type. What should I do? Do yo have any alternative solutions?
<my-chart chart-type="Line" :chart-data="datacollection" :option="options"></my-chart>
Thanks
Environment
- vue.js version: 2.5.*
- vue-chart.js version: 3.4.2
- npm version: 6.4.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Chart.js: Dynamic Changing of Chart Type (Line to Bar as ...
Chart.js modifies the config object you pass in. Because of that you can not just change 'config.type'. You could go into the modified...
Read more >Updating Charts - Chart.js
Scales can be updated separately without changing other options. To update the scales, pass in an object containing all the customization ...
Read more >ChartJS - change chart type and randomize data - CodePen
Created this to showcase an easy way to change your ChartJS chart type through a select dropdown (hint: you need to destroy the...
Read more >Dynamic swapping of chart.js - Laracasts
However, nothing changes when I do this. The line chart remains even though I destroy() the chart, change it's type, then re-create it....
Read more >Overview – Updating chart options - CanvasJS.com
Creating dynamic charts · <!DOCTYPE HTML> · <html> · <head> · <script type = "text/javascript" > · window.onload = function () { ·...
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
it is not possible.
It does not reset on data changes and it does update the data dynamically in the chart. About that charts are not interchangeable that is kind of true indeed, if you make a pie chart from your line it is a useless chart but if you use the change to make a bar chart from a line (my use case) than it is a valid option since the data and setup is the same for both chart types.
So while it is not an ideal solution it is the closest to what satisfied my needs and maybe for others too