Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show dynamic intervention description in drilldown #6597

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,25 @@
</AccordionTab>
<AccordionTab header="Charts">
<ul class="flex flex-column gap-2">
<li v-for="appliedTo in Object.keys(groupedOutputParameters)" :key="appliedTo">
<vega-chart
expandable
:are-embed-actions-visible="false"
:visualization-spec="preparedCharts[appliedTo]"
/>
<span class="flex pb-6">
<label class="pr-2 text-sm">Show this chart on node thumbnail</label>
<Checkbox
v-model="selectedCharts"
:input-id="appliedTo"
:name="appliedTo"
:value="appliedTo"
@change="onSelectChartChange"
<li v-for="appliedTo in displayedInterventions" :key="appliedTo">
<h5>{{ appliedTo }}</h5>
<template v-if="preparedCharts[appliedTo]">
<vega-chart
expandable
:are-embed-actions-visible="false"
:visualization-spec="preparedCharts[appliedTo]"
/>
</span>
<span class="flex pb-6">
<label class="pr-2 text-sm">Show this chart on node thumbnail</label>
<Checkbox
v-model="selectedCharts"
:input-id="appliedTo"
:name="appliedTo"
:value="appliedTo"
@change="onSelectChartChange"
/>
</span>
</template>
<ul>
<li
class="pb-2"
Expand All @@ -187,7 +190,7 @@
</p>
</li>
</ul>
<p v-else-if="!isEmpty(intervention.dynamicInterventions)">
<p v-if="!isEmpty(intervention.dynamicInterventions)">
Set {{ intervention.dynamicInterventions[0].type }} {{ appliedTo }} to
{{ intervention.dynamicInterventions[0].value }} when the
{{ intervention.dynamicInterventions[0].parameter }}
Expand Down Expand Up @@ -292,6 +295,24 @@ interface BasicKnobs {
transientInterventionPolicy: InterventionPolicy;
}

/*
This is a super-set of prepared charts. We only display static interventions in the charts right now,
but we also want the option to display the desciptions of dynamic interventions in the drilldown.
*/
const displayedInterventions = computed(() => {
// we want a set of the appliedTo interventions in the drilldown
const selectedInterventionSet: Set<string> = new Set();
knobs.value.transientInterventionPolicy.interventions.forEach((intervention) => {
intervention.staticInterventions.forEach((staticIntervention) => {
selectedInterventionSet.add(staticIntervention.appliedTo);
});
intervention.dynamicInterventions.forEach((dynamicIntervention) => {
selectedInterventionSet.add(dynamicIntervention.appliedTo);
});
});
return selectedInterventionSet;
});

const knobs = ref<BasicKnobs>({
transientInterventionPolicy: {
name: '',
Expand Down Expand Up @@ -396,21 +417,21 @@ const stateOptions = computed(() => {
}));
});

const groupedOutputParameters = computed(() =>
groupBy(flattenInterventionData(knobs.value.transientInterventionPolicy.interventions), 'appliedTo')
);

const preparedCharts = computed(() =>
_.mapValues(groupedOutputParameters.value, (interventions, key) =>
const preparedCharts = computed(() => {
const groupedOutputParameters = groupBy(
flattenInterventionData(knobs.value.transientInterventionPolicy.interventions),
'appliedTo'
);
return _.mapValues(groupedOutputParameters, (interventions, key) =>
createInterventionChart(interventions, {
title: key,
width: 400,
height: 200,
xAxisTitle: 'Time',
yAxisTitle: 'Value'
})
)
);
);
});

const getInterventionsAppliedTo = (appliedTo: string) =>
knobs.value.transientInterventionPolicy.interventions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
<div v-if="displayedInterventions.length > 0" class="intervention-summary">
<div v-for="(intervention, index) in displayedInterventions" :key="index">
<p class="name">{{ intervention.name }}</p>
<div>
Starting at time step
<span class="semi-bold">{{ intervention.staticInterventions[0].timestep }},</span>
</div>
<div class="body" v-if="intervention.staticInterventions.length > 0">
<p
v-for="staticIntervention in intervention.staticInterventions"
:key="staticIntervention.type + staticIntervention.appliedTo"
>
Set {{ staticIntervention.type }} <span class="semi-bold">{{ staticIntervention.appliedTo }}</span> to
<span class="semi-bold">{{ staticIntervention.value }}</span>
</p>
</div>
<template v-if="intervention.staticInterventions.length > 0">
<div>
Starting at time step
<span class="semi-bold">{{ intervention.staticInterventions[0].timestep }},</span>
</div>
<div class="body">
<p
v-for="staticIntervention in intervention.staticInterventions"
:key="staticIntervention.type + staticIntervention.appliedTo"
>
Set {{ staticIntervention.type }} <span class="semi-bold">{{ staticIntervention.appliedTo }}</span> to
<span class="semi-bold">{{ staticIntervention.value }}</span>
</p>
</div>
</template>
<div class="body" v-if="intervention.dynamicInterventions.length > 0">
<p
v-for="dynamicIntervention in intervention.dynamicInterventions"
Expand Down
Loading