From de0a46be9ca18e187c1b8dd454c38abd313bd153 Mon Sep 17 00:00:00 2001 From: Jaehwan Ryu Date: Fri, 20 Sep 2024 14:44:37 -0400 Subject: [PATCH] Select only relavant variables for the chart (#4881) --- .../simulate-ciemss/tera-simulate-ciemss-drilldown.vue | 1 - packages/client/hmi-client/src/services/charts.ts | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/simulate-ciemss/tera-simulate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/simulate-ciemss/tera-simulate-ciemss-drilldown.vue index 4c55c379e1..031543f554 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/simulate-ciemss/tera-simulate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/simulate-ciemss/tera-simulate-ciemss-drilldown.vue @@ -354,7 +354,6 @@ const preparedCharts = computed(() => { const result = runResults.value[selectedRunId.value]; const resultSummary = runResultsSummary.value[selectedRunId.value]; - const reverseMap: Record = {}; Object.keys(pyciemssMap).forEach((key) => { reverseMap[`${pyciemssMap[key]}_mean`] = key; diff --git a/packages/client/hmi-client/src/services/charts.ts b/packages/client/hmi-client/src/services/charts.ts index 47df499cc2..a3ce8be937 100644 --- a/packages/client/hmi-client/src/services/charts.ts +++ b/packages/client/hmi-client/src/services/charts.ts @@ -1,5 +1,5 @@ import { percentile } from '@/utils/math'; -import { isEmpty } from 'lodash'; +import { isEmpty, pick } from 'lodash'; import { VisualizationSpec } from 'vega-embed'; import { v4 as uuidv4 } from 'uuid'; import { ChartAnnotation, Intervention } from '@/types/Types'; @@ -398,8 +398,12 @@ export function createForecastChart( // Helper function to capture common layer structure const newLayer = (layer: ForecastChartLayer, markType: string) => { + const selectedFields = layer.variables.concat([layer.timeField]); + if (layer.groupField) selectedFields.push(layer.groupField); + + const data = Array.isArray(layer.data) ? { values: layer.data.map((d) => pick(d, selectedFields)) } : layer.data; const header = { - data: Array.isArray(layer.data) ? { values: layer.data } : layer.data, + data, transform: [ { fold: layer.variables,