@@ -18,10 +18,21 @@ func IsReservedPlotName(name string) bool {
1818 return true
1919 }
2020 return slices .ContainsFunc (registry , func (pd description ) bool {
21- return pd .name == name
21+ return nameFromLayout ( pd .layout ) == name
2222 })
2323}
2424
25+ func nameFromLayout (layout any ) string {
26+ switch layout := layout .(type ) {
27+ case Scatter :
28+ return layout .Name
29+ case Heatmap :
30+ return layout .Name
31+ default :
32+ panic (fmt .Sprintf ("unknown plot layout type %T" , layout ))
33+ }
34+ }
35+
2536// getvalues extracts, from a sample of runtime metrics, a slice with all
2637// the metrics necessary for a single plot.
2738type getvalues func (time.Time , []metrics.Sample ) any
@@ -78,26 +89,11 @@ func (pl *List) enabledPlots() []runtimePlot {
7889 continue
7990 }
8091
81- switch layout := plot .layout .(type ) {
82- case Scatter :
83- layout .Name = plot .name
84- layout .Tags = plot .tags
85- plots = append (plots , runtimePlot {
86- name : plot .name ,
87- getvals : plot .getvalues (),
88- layout : layout ,
89- })
90- case Heatmap :
91- layout .Name = plot .name
92- layout .Tags = plot .tags
93- plots = append (plots , runtimePlot {
94- name : plot .name ,
95- getvals : plot .getvalues (),
96- layout : layout ,
97- })
98- default :
99- panic (fmt .Sprintf ("unknown plot layout type %T" , layout ))
100- }
92+ plots = append (plots , runtimePlot {
93+ name : nameFromLayout (plot .layout ),
94+ getvals : plot .getvalues (),
95+ layout : plot .layout ,
96+ })
10197 }
10298
10399 return plots
0 commit comments