question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue-ChartJS - Circular structure to JSON

See original GitHub issue

Expected 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:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
aperturelesscommented, Aug 6, 2018

Well it seems that this error only occurs if you’re trying to output the datacollection in your template

 <div id="app">
    {{dataCollection}}
    <line-chart :chart-data="dataCollection" :height="100"></line-chart>
    <input v-model="test">
  </div>

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.

1reaction
agribozcommented, Jan 11, 2019

the reason is _meta object. i will show you an example of it

example

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found