rickshaw icon indicating copy to clipboard operation
rickshaw copied to clipboard

Gettings vis.selectAll is not a function when created from within Vue

Open davidsielert opened this issue 7 years ago • 5 comments

Nothing is really spectacular from my vue component code but I'm getting

    at klass.render (rickshaw.js:3603)
    at Rickshaw.Graph.render (rickshaw.js:525)

with this simple creation code..

 this.graph = new Rickshaw.Graph({
        element: document.querySelector(`#VB-${this.id}`), //have to call id like this cause the uuid's can start with an integer
        renderer: 'area',
        stroke: true,
        series: [{
            data: this.data,
            color: this.color,
        }]
    });
    this.graph.render();

davidsielert avatar Feb 09 '18 01:02 davidsielert

This seems to be related to storing the instance on the Vue instance (this) Compare these...

Doesn't work - throws vis.selectAll is not a function

 this.graph = new Rickshaw.Graph({
        element: document.querySelector(`#VB-${this.id}`), //have to call id like this cause the uuid's can start with an integer
        renderer: 'area',
        stroke: true,
        series: [{
            data: this.data,
            color: this.color,
        }]
    });
    this.graph.render();

This code works

var rs1 = new Rickshaw.Graph({
        element: document.querySelector(`#VB-${this.id}`), //have to call id like this cause the uuid's can start with an integer
        renderer: 'area',
        stroke: true,
        series: [{
            data: this.data,
            color: this.color,
        }]
    });
    rs1.render();

But why would where I'm storing the instance variable matter ? I don't understand this..

davidsielert avatar Feb 10 '18 15:02 davidsielert

Hi I am facing same issue, need to declare a Graph object globally, when I create graph object as component member graph not rendering. can you please provide solution for this.

hinguabhishek avatar Mar 21 '18 07:03 hinguabhishek

so... it was in march.. have you found solution?

vinnitu avatar Sep 10 '18 14:09 vinnitu

No

Get Outlook for Androidhttps://aka.ms/ghei36


From: Victor Sklyar [email protected] Sent: Monday, September 10, 2018 8:06:25 PM To: shutterstock/rickshaw Cc: hinguabhishek; Comment Subject: Re: [shutterstock/rickshaw] Gettings vis.selectAll is not a function when created from within Vue (#610)

so... it was in march.. have you found solution?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/shutterstock/rickshaw/issues/610#issuecomment-419935951, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AH_B-u_SmRCAZQLvHvvBC15xFCa8wi_Nks5uZnjpgaJpZM4R_TJ2.

hinguabhishek avatar Sep 11 '18 12:09 hinguabhishek

Found a solution: Vue wraps all data elements in an observer. This override all methods attached to them. In order to solve this issue, create graph as an array: data() { return { graph: [] }, methods: { initGraph() { this.graph[0] = new Rickshaw.Graph({ ... }); this.graph[0].render();

laemtl avatar May 07 '19 15:05 laemtl