I have a object that I create two instances of:
var generalGraph = new graph(generalFunnel)
generalGraph.draw("#conversion");
var invoicingGraph = new graph(invoicingFunnel)
invoicingGraph.draw("#invoicing")
Here is the object (note that this is highly simplified to make it easier to understand) the comments are the console-outputs.
graph = function(funnel){
this.funnel = funnel.conversions
mySelf = this
this.draw = function(selector){
console.log(mySelf.funnel)
//generalGraph ["Användare", "Påbörjat Onboarding", "Skapat oganisation", "Skapat användare", "Kom tillbaka", "Köpt"]
//invoicingGraph ["Användare", "Påbörjat Onboarding", "Skapat oganisation", "Kom tillbaka", "Köpt"]
nv.addGraph(function() {
console.log(mySelf.funnel)
//generalGraph ["Användare", "Påbörjat Onboarding", "Skapat oganisation", "Kom tillbaka", "Köpt"]
//invoicingGraph ["Användare", "Påbörjat Onboarding", "Skapat oganisation", "Kom tillbaka", "Köpt"]
});
}
}
For some reason, when I do generalGraph.draw
, it uses the funnel from invoicingFunnel
. Why? And how can I stop it from happening?