You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a dashboard for various production lines (obtained from a DB)
The code adds appropriate DIV's in a forEach called function. <div id="ChartTrend${MyLine}" class="ct-chart" style="width: 99%; height: 90%; "></div>
Then tries to put in a chart (no real data yet) eval("var ChartTrend" + MyLine + " = new Chartist.Line('#ChartTrend' + MyLine ,dummydata , optionsLine); ");
or window["ChartTrend" + MyLine] = new Chartist.Line('#ChartTrend' + MyLine,dummydata,optionsLine);
In debugger, i see the ChartTrend1-8 div created. Only ChartTrend9 (the last) actually displays the chart with dummy data
console.log(document.getElementById(ChartTrend${MyLine}).children ); shows chart with data created for each line though.
Then once above is working, go get data and fill it in async function like below,
window['ChartTrend' + MyLine].update(chartdata);
but i get
"Uncaught TypeError: window[("ChartTrend" + MyLine)].update is not a function"
The text was updated successfully, but these errors were encountered:
sll1966
changed the title
Only last chart updated from eval statement
Update dynamically referenced chart div
Jul 15, 2022
I have a dashboard for various production lines (obtained from a DB)
The code adds appropriate DIV's in a forEach called function.
<div id="ChartTrend${MyLine}" class="ct-chart" style="width: 99%; height: 90%; "></div>
Then tries to put in a chart (no real data yet)
eval("var ChartTrend" + MyLine + " = new Chartist.Line('#ChartTrend' + MyLine ,dummydata , optionsLine); ");
or
window["ChartTrend" + MyLine] = new Chartist.Line('#ChartTrend' + MyLine,dummydata,optionsLine);
In debugger, i see the ChartTrend1-8 div created.
Only ChartTrend9 (the last) actually displays the chart with dummy data
console.log(document.getElementById(
ChartTrend${MyLine}
).children ); shows chart with data created for each line though.Then once above is working, go get data and fill it in async function like below,
window['ChartTrend' + MyLine].update(chartdata);
but i get
"Uncaught TypeError: window[("ChartTrend" + MyLine)].update is not a function"
The text was updated successfully, but these errors were encountered: