@@ -15,6 +15,7 @@ import CmkHtml from '@/components/CmkHtml.vue'
1515import CmkIcon from ' @/components/CmkIcon'
1616
1717import type {
18+ AverageScatterplotContent ,
1819 CombinedGraphContent ,
1920 PerformanceGraphContent ,
2021 SingleTimeseriesContent
@@ -29,7 +30,12 @@ type DiscoveredGraph = components['schemas']['ApiDiscoveredGraph']
2930const { _t } = usei18n ()
3031const props =
3132 defineProps <
32- ContentProps < PerformanceGraphContent | SingleTimeseriesContent | CombinedGraphContent >
33+ ContentProps <
34+ | PerformanceGraphContent
35+ | SingleTimeseriesContent
36+ | CombinedGraphContent
37+ | AverageScatterplotContent
38+ >
3339 > ()
3440
3541const shell = ref <DiscoveredGraph | null >(null )
@@ -59,6 +65,12 @@ const resolveTimeseriesColor = (color: SingleTimeseriesContent['color']): string
5965 return color === ' default_theme' ? DEFAULT_THEME_COLOR : color
6066}
6167
68+ const resolveScatterplotColor = (
69+ color : AverageScatterplotContent [' metric_color' ]
70+ ): string | null => {
71+ return color === ' default' ? null : color
72+ }
73+
6274type GraphDiscovery =
6375 | { graphs: DiscoveredGraph []; no_data_message? : string | null }
6476 | { error: string }
@@ -115,6 +127,22 @@ const discoverGraphs = async (): Promise<GraphDiscovery> => {
115127 }
116128 })
117129 )
130+ case ' average_scatterplot' :
131+ return unwrap (
132+ await client .POST (
133+ ' /domain-types/graph/actions/discover_average_scatterplot_graphs/invoke' ,
134+ {
135+ params: { header: { ' Content-Type' : ' application/json' } },
136+ body: {
137+ context: props .effective_filter_context .filters ,
138+ metric: content .metric ,
139+ metric_color: resolveScatterplotColor (content .metric_color ),
140+ average_color: resolveScatterplotColor (content .average_color ),
141+ median_color: resolveScatterplotColor (content .median_color )
142+ }
143+ }
144+ )
145+ )
118146 default :
119147 staticAssertNever (content )
120148 return { graphs: [] }
@@ -167,6 +195,12 @@ const discoveryKey = computed(() => {
167195 graph_template: content .graph_template ,
168196 context: props .effective_filter_context .filters
169197 }
198+ case ' average_scatterplot' :
199+ return {
200+ metric: content .metric ,
201+ colors: [content .metric_color , content .average_color , content .median_color ],
202+ context: props .effective_filter_context .filters
203+ }
170204 default :
171205 staticAssertNever (content )
172206 return {}
@@ -178,8 +212,18 @@ watch(
178212 () => void loadGraph ()
179213)
180214
181- const showLegend = computed (() => props .content .graph_render_options ?.show_legend ?? false )
182- const showTimestamp = computed (() => props .content .graph_render_options ?.show_graph_time ?? false )
215+ // The figure-based average scatterplot has neither graph render options nor the graph
216+ // contents' timerange field (its range lives in time_range).
217+ const graphRenderOptions = computed (() => {
218+ const content = props .content
219+ return ' graph_render_options' in content ? content .graph_render_options : undefined
220+ })
221+ const timerange = computed (() => {
222+ const content = props .content
223+ return content .type === ' average_scatterplot' ? content .time_range : content .timerange
224+ })
225+ const showLegend = computed (() => graphRenderOptions .value ?.show_legend ?? false )
226+ const showTimestamp = computed (() => graphRenderOptions .value ?.show_graph_time ?? false )
183227const combinationMode = computed (() => {
184228 const content = props .content
185229 return content .type === ' combined_graph' ? content .presentation : null
@@ -217,7 +261,7 @@ onMounted(() => {
217261 v-else-if =" shell "
218262 :graph-type =" shell .graph_type "
219263 :internal =" shell .internal "
220- :timerange =" content . timerange "
264+ :timerange =" timerange "
221265 :combination-mode =" combinationMode "
222266 :show-legend =" showLegend "
223267 :show-timestamp =" showTimestamp "
0 commit comments