Vue-ChartJS - Circular structure to JSON
See original GitHub issueExpected Behavior
Change any v-model without error
Actual Behavior
i’m using Vue-Chartjs lib, and i’m trying to make a line chart. Well, i have done it with this code below, it works! The graph is drawed. But when i change the value of any variable inside my Vue Data
(Like this test
input, in the example.). It evals this error in console. I think it is because of VueChartJS, because if i remove the graph, everything works well.
TypeError: Converting circular structure to JSON
line.js
import {Line, mixins} from 'vue-chartjs'
const { reactiveProp } = mixins
export default {
extends: Line,
mixins: [reactiveProp],
props: ['options'],
mounted() {
this.renderChart(this.chartData, this.options);
}
}
dashboard.vue
<line-chart :chart-data="dataCollection" :height="100"></line-chart>
<input v-model="test">
import LineChart from './line-chart.js';
export default {
components: {LineChart},
data: () => ({
dataCollection: {},
test: "some input"
}),
created () {
this.dataCollection: {
"labels": ["0:00", "1:00", "2:00", "3:00", "4:00", "5:00"],
"datasets": [{
"label": "Test",
"backgroundColor": "#00CC6A",
"borderColor": "#00CC6A",
"data": [0, 23, 51.75, 27, 34, 12]
}]
}
}
}
What am i doing wrong?
Thanks!! =)
Environment
- vue.js version: 2.5.13
- vue-chart.js version: 3.3.1
- npm version: 5.6.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Vue-ChartJS - Circular structure to JSON - Stack Overflow
I guess the problem according to your sandbox, is that you are trying to output the datacollection in the template.
Read more >[Solved]-Vue-ChartJS - Circular structure to JSON-Vue.js
Coding example for the question Vue-ChartJS - Circular structure to JSON-Vue.js.
Read more >Vuechartjs Circular Structure To Json - ADocLib
TypeError: Converting circular structure to JSON occurs when you try to reference your variable name within the JSON object.The code above will give...
Read more >Table.js:200 Uncaught TypeError: Converting circular structure to ...
I run into this issue, because i was sending as response the full response of another api call instead of just the data...
Read more >“Converting circular structure to JSON” Exception in JavaScript
So we have to remove the circular references before converting the object to JSON. Fix for the above code: let obj = {};...
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
Well it seems that this error only occurs if you’re trying to output the datacollection in your template
If you remove the output
{{ dataCollection }}
it seems fine.https://codesandbox.io/s/0q3p8n6lxw
So I guess this is not related to
vue-chartjs
. More to some vue internals.the reason is _meta object. i will show you an example of it
example