/** * Update the chart with new datasets. This destroys the old chart. * * @param aJSDataVar * The data parameter used to draw the graph. * @return The JS code needed to do so. */ @Nonnull public IHasJSCode getJSUpdateCode (@Nonnull final IJSExpression aJSDataVar) { final JSPackage ret = new JSPackage (); // Cleanup old chart ret.invoke (JSExpr.ref (getJSChartVar ()), "destroy"); // Use new chart ret.assign (JSExpr.ref (getJSChartVar ()), new JSDefinedClass ("Chart")._new () .arg (JSExpr.ref (getCanvasID ()) .invoke ("getContext") .arg ("2d")) .invoke (m_aChart.getJSMethodName ()) .arg (aJSDataVar) .arg (getJSOptions ())); return ret; } }
new JSDefinedClass ("Chart")._new () .arg (aJSCanvas.invoke ("getContext").arg ("2d")) .invoke (m_aChart.getJSMethodName ())