Dataview & Charts i.push TypeError

I made some new data view and charts stuff, now all of a sudden tables that once worked fine show an error:

Evaluation Error: TypeError: i.push is not a function
at l$1.diffed (plugin:dataview:15978:1539)
at j$2 (plugin:dataview:15976:6418)
at w$2 (plugin:dataview:15976:2236)
at j$2 (plugin:dataview:15976:6192)
at w$2 (plugin:dataview:15976:2236)
at L$1 (plugin:dataview:15976:7442)
at j$2 (plugin:dataview:15976:6377)
at w$2 (plugin:dataview:15976:2236)
at L$1 (plugin:dataview:15976:7442)
at j$2 (plugin:dataview:15976:6377)

Here’s the query that show’s this error:

dataviewjs  
let OutcomeCount = (dv.pages('"00_Trades"').where(p => p.play == "D_Scenario").length);


let outcomesum = 0;
   for(let i = 0; i < dv.pages('"00_Trades"').where(p => p.play == "D_Scenario").length; i++) {
		if(dv.pages('"00_Trades"').where(p => p.play == "D_Scenario")[i].outcome) {
		outcomesum += dv.pages('"00_Trades"').where(p => p.play == "D_Scenario")[i].outcome;
         }
   }


dv.paragraph("# Total Profit: " + outcomesum + " R")

Funny thing is … it’s only affecting creating tables … does anyone have an idea?

Okay … I found it.

I have another script that stopped the other ones from working:

let cumulativeOutcome = [ TradeOutcome[0] ]
for ( i = 1; i < TradeOutcome.length; i++) {
  cumulativeOutcome[i] = cumulativeOutcome[i-1] + TradeOutcome[i]
}

must be

let cumulativeOutcome = [ TradeOutcome[0] ]
for (let i = 1; i < TradeOutcome.length; i++) {
  cumulativeOutcome[i] = cumulativeOutcome[i-1] + TradeOutcome[I]
}

let

was missing.

Sorry for the omission of let in that for loop. Whilst testing I actually saw that error for a little while, restarted Obsidian and it disappeared and I didn’t think any more of it.

Thought it was connected to some other intermittent issue. Glad you found it, and fixed it.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.