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"
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); ");
orwindow["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"