Skip to content

Commit

Permalink
Select only relavant variables for the chart (#4881)
Browse files Browse the repository at this point in the history
  • Loading branch information
jryu01 authored Sep 20, 2024
1 parent 39213a1 commit de0a46b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ const preparedCharts = computed(() => {
const result = runResults.value[selectedRunId.value];
const resultSummary = runResultsSummary.value[selectedRunId.value];
const reverseMap: Record<string, string> = {};
Object.keys(pyciemssMap).forEach((key) => {
reverseMap[`${pyciemssMap[key]}_mean`] = key;
Expand Down
8 changes: 6 additions & 2 deletions packages/client/hmi-client/src/services/charts.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit de0a46b

Please sign in to comment.