4949 </ScrollPanel >
5050 </SplitterPanel >
5151 <SplitterPanel :size =" 75" >
52- <GraphPanelWidget :key =" interactiveModeEnabled ? 'hidden-graph-panel' : 'visible-graph-panel'" :plots = " standardPlots " />
52+ <GraphPanelWidget :key =" interactiveModeEnabled ? 'hidden-graph-panel' : 'visible-graph-panel'" :data = " standardData " />
5353 </SplitterPanel >
5454 </Splitter >
5555 </SplitterPanel >
8888 v-for =" (_plot, index) in (uiJson as any).output.plots"
8989 :key =" `plot_${index}`"
9090 :style =" { height: `calc((100% - 0.5 * ${(uiJson as any).output.plots.length - 1}rem) / ${(uiJson as any).output.plots.length})` }"
91- :plots = " interactivePlots [index] || [{ x: { data: [] }, y: { data: [] } }] "
91+ :data = " interactiveData [index] || { xValues: [], yValues: [] }"
9292 />
9393 </div >
9494 </div >
@@ -110,7 +110,7 @@ import * as vueCommon from '../../common/vueCommon';
110110import * as locApi from ' ../../libopencor/locApi' ;
111111import * as locSedApi from ' ../../libopencor/locSedApi' ;
112112
113- import type { IGraphPanelPlot } from ' ../widgets/GraphPanelWidget.vue' ;
113+ import type { IGraphPanelData , IGraphPanelPlotAdditionalTrace } from ' ../widgets/GraphPanelWidget.vue' ;
114114
115115const props = defineProps <{
116116 file: locApi .File ;
@@ -174,12 +174,10 @@ const standardInstanceTask = standardInstance.task(0);
174174const standardParameters = vue .ref <string []>([]);
175175const standardXParameter = vue .ref (standardInstanceTask .voiName ());
176176const standardYParameter = vue .ref (standardInstanceTask .stateName (0 ));
177- const standardPlots = vue .ref <IGraphPanelPlot []>([
178- {
179- x: { data: [] },
180- y: { data: [] }
181- }
182- ]);
177+ const standardData = vue .ref <IGraphPanelData >({
178+ xValues: [],
179+ yValues: []
180+ });
183181const standardConsoleContents = vue .ref <string >(` <b>${props .file .path ()}</b> ` );
184182
185183populateParameters (standardParameters , standardInstanceTask );
@@ -206,16 +204,10 @@ const xInfo = vue.computed(() => locCommon.simulationDataInfo(standardInstanceTa
206204const yInfo = vue .computed (() => locCommon .simulationDataInfo (standardInstanceTask , standardYParameter .value ));
207205
208206function updatePlot() {
209- standardPlots .value = [
210- {
211- x: {
212- data: locCommon .simulationData (standardInstanceTask , xInfo .value )
213- },
214- y: {
215- data: locCommon .simulationData (standardInstanceTask , yInfo .value )
216- }
217- }
218- ];
207+ standardData .value = {
208+ xValues: locCommon .simulationData (standardInstanceTask , xInfo .value ),
209+ yValues: locCommon .simulationData (standardInstanceTask , yInfo .value )
210+ };
219211}
220212
221213// Interactive mode.
@@ -225,14 +217,7 @@ const interactiveInstance = interactiveDocument.instantiate();
225217const interactiveInstanceTask = interactiveInstance .task (0 );
226218const interactiveMath = mathjs .create (mathjs .all ?? {}, {});
227219const interactiveModel = interactiveDocument .model (0 );
228- const interactivePlots = vue .ref <IGraphPanelPlot [][]>([
229- [
230- {
231- x: { data: [] },
232- y: { data: [] }
233- }
234- ]
235- ]);
220+ const interactiveData = vue .ref <IGraphPanelData []>([]);
236221const interactiveUiJsonIssues = vue .ref <locApi .IIssue []>(
237222 interactiveModeAvailable .value ? locApi .uiJsonIssues (props .uiJson ) : []
238223);
@@ -318,7 +303,6 @@ function updateInteractiveSimulation() {
318303 const componentVariableNames = parameter .name .split (' /' );
319304
320305 interactiveModel .addChange (
321- // @ts-expect-error (we trust that we have a valid component and variable name)
322306 componentVariableNames [0 ],
323307 componentVariableNames [1 ],
324308 String (evaluateValue (parameter .value ))
@@ -340,42 +324,26 @@ function updateInteractiveSimulation() {
340324 const parser = interactiveMath .parser ();
341325
342326 props .uiJson .output .data .forEach ((data : locApi .IUiJsonOutputData ) => {
343- // @ts-expect-error (we trust that we have some valid information)
344327 parser .set (data .id , locCommon .simulationData (interactiveInstanceTask , interactiveIdToInfo [data .id ]));
345328 });
346329
347- interactivePlots .value = props .uiJson .output .plots .map ((plot : locApi .IUiJsonOutputPlot ) => {
348- // Default trace.
349-
350- let res = [
351- {
352- x: {
353- data: parser .evaluate (plot .xValue ),
354- axisTitle: plot .xAxisTitle
355- },
356- y: {
357- data: parser .evaluate (plot .yValue ),
358- axisTitle: plot .yAxisTitle
359- }
360- }
361- ];
362-
363- // Additional traces.
330+ interactiveData .value = props .uiJson .output .plots .map ((plot : locApi .IUiJsonOutputPlot ) => {
331+ let additionalTraces: IGraphPanelPlotAdditionalTrace [] = [];
364332
365333 plot .additionalTraces ?.forEach ((additionalTrace : locApi .IUiJsonOutputPlotAdditionalTrace ) => {
366- res .push ({
367- x: {
368- data: parser .evaluate (additionalTrace .xValue ),
369- axisTitle: plot .xAxisTitle
370- },
371- y: {
372- data: parser .evaluate (additionalTrace .yValue ),
373- axisTitle: plot .yAxisTitle
374- }
334+ additionalTraces .push ({
335+ xValues: parser .evaluate (additionalTrace .xValue ),
336+ yValues: parser .evaluate (additionalTrace .yValue )
375337 });
376338 });
377339
378- return res ;
340+ return {
341+ xAxisTitle: plot .xAxisTitle ,
342+ xValues: parser .evaluate (plot .xValue ),
343+ yAxisTitle: plot .yAxisTitle ,
344+ yValues: parser .evaluate (plot .yValue ),
345+ additionalTraces: additionalTraces
346+ };
379347 });
380348}
381349
0 commit comments