From 7df0adc5ab57df127a8f12a5680fb0309f9f9bf6 Mon Sep 17 00:00:00 2001 From: Sebastian Rodriguez Date: Thu, 28 Nov 2024 13:29:40 -0300 Subject: [PATCH] Use generic parent type 'VisualizationDataSpec' to fix parsing errors with some dashboards --- .../SingleValueLabelsVisualizationBase.cs | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Reveal.Sdk.Dom/Visualizations/SingleValueLabelsVisualizationBase.cs b/src/Reveal.Sdk.Dom/Visualizations/SingleValueLabelsVisualizationBase.cs index bfeb42fb..9bceb6c7 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/SingleValueLabelsVisualizationBase.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/SingleValueLabelsVisualizationBase.cs @@ -12,12 +12,38 @@ public abstract class SingleValueLabelsVisualizationBase : Visualizat protected SingleValueLabelsVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } [JsonIgnore] - public List Labels { get { return VisualizationDataSpec.Rows; } } + public List Labels { + get + { + if (VisualizationDataSpec is SingleValueLabelsVisualizationDataSpec vizSpec) + { + return vizSpec.Rows; + } + else + { + return new List(); + } + } + } [JsonIgnore] - public List Values { get { return VisualizationDataSpec.Value; } } + public List Values { + get + { + if (VisualizationDataSpec is SingleValueLabelsVisualizationDataSpec vizSpec) + { + return vizSpec.Value; + } + else + { + return new List(); + } + } + } + + //Some visualizations can be assigned a CategoryVisualizationDataSpec instead of a SingleValueLabelsVisualizationDataSpec [JsonProperty(Order = 7)] - SingleValueLabelsVisualizationDataSpec VisualizationDataSpec { get; set; } = new SingleValueLabelsVisualizationDataSpec(); + VisualizationDataSpec VisualizationDataSpec { get; set; } = new SingleValueLabelsVisualizationDataSpec(); } } \ No newline at end of file