diff --git a/e2e/Sandbox/Dashboards/Jason - AB Sales.rdash b/e2e/Sandbox/Dashboards/Jason - AB Sales.rdash new file mode 100644 index 00000000..58564cd4 Binary files /dev/null and b/e2e/Sandbox/Dashboards/Jason - AB Sales.rdash differ diff --git a/e2e/Sandbox/Factories/ManufacturingDashboard.cs b/e2e/Sandbox/Factories/ManufacturingDashboard.cs index e433e375..f4559d6b 100644 --- a/e2e/Sandbox/Factories/ManufacturingDashboard.cs +++ b/e2e/Sandbox/Factories/ManufacturingDashboard.cs @@ -1,336 +1,336 @@ -using Reveal.Sdk.Dom; -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Filters; -using Reveal.Sdk.Dom.Visualizations; -using Sandbox.Helpers; -using System.Linq; - -namespace Sandbox.Factories -{ - internal class ManufacturingDashboard - { - internal static RdashDocument CreateDashboard() - { - var excelDataSourceItem = DataSourceFactory.GetManufacturingDataSourceItem(); - - var document = new RdashDocument("Manufacturing") - { - Title = "Manufacturing", - Theme = Theme.RockyMountain, - Description = "I created this in code", - UseAutoLayout = false, - }; - - document.Visualizations.Add(CreateIndicatorVisualization("Productivity", "Overall Plant Productivity ", excelDataSourceItem, true)); - document.Visualizations.Add(CreateIndicatorVisualization("Units Lost", "Units Lost", excelDataSourceItem)); - document.Visualizations.Add(CreateLineChartVisualization(excelDataSourceItem)); - document.Visualizations.Add(CreateColumnChartVisualization(excelDataSourceItem)); - document.Visualizations.Add(CreateDoughnutChartVisualization(excelDataSourceItem)); - document.Visualizations.Add(CreateCircularGaugeVisualization(excelDataSourceItem)); - document.Visualizations.Add(CreateCircularGaugeVisualization2(excelDataSourceItem)); - document.Visualizations.Add(CreateColumnChartVisualization2(excelDataSourceItem)); - - return document; - } - - private static Visualization CreateIndicatorVisualization(string title, string field, DataSourceItem excelDataSourceItem, bool avg = false) - { - var visualization = new KpiTimeVisualization(excelDataSourceItem) - { - Title = title, - ColumnSpan = 10, - RowSpan = 22, - }; - - visualization.Date = new DimensionColumn() - { - DataField = new DateDataField("Date") - }; - - NumberDataField dataField = new NumberDataField(field); - if (avg) - { - dataField.AggregationType = AggregationType.Avg; - dataField.Formatting = new NumberFormatting() - { - FormatType = NumberFormattingType.Percent, - DecimalDigits = 0, - ShowGroupingSeparator = true, - ApplyMkFormat = true - }; - } - - visualization.Values.Add(new MeasureColumn() - { - DataField = dataField - }); - - return visualization; - } - - private static Visualization CreateLineChartVisualization(DataSourceItem excelDataSourceItem) - { - var visualization = new LineChartVisualization(excelDataSourceItem) - { - Title = "Cost of Labor vs Revenue", - ColumnSpan = 40, - RowSpan = 22, - }; - - var field = visualization.DataDefinition.Fields.Where(x => x.FieldName == "Date").First() as DateField; - field.DataFilter = new DateTimeFilter() - { - FilterType = FilterType.FilterByRule, - DateFiscalYearStartMonth = 0, - DisplayInLocalTimeZone = false, - RuleType = DateRuleType.LastYear - }; - - visualization.Labels.Add(new DimensionColumn() - { - DataField = new DateDataField("Date") - { - AggregationType = DateAggregationType.Month - } - }); - - visualization.Values.Add(new MeasureColumn() - { - DataField = new NumberDataField("Cost of Labor ") - { - Formatting = new NumberFormatting() - { - FormatType = NumberFormattingType.Currency, - DecimalDigits = 0, - ShowGroupingSeparator = true, - } - } - }); - visualization.Values.Add(new MeasureColumn() - { - DataField = new NumberDataField("Revenue") - { - Formatting = new NumberFormatting() - { - FormatType = NumberFormattingType.Currency, - DecimalDigits = 0, - ShowGroupingSeparator = true, - } - } - }); - - return visualization; - } - - private static Visualization CreateColumnChartVisualization(DataSourceItem excelDataSourceItem) - { - var visualization = new ColumnChartVisualization(excelDataSourceItem) - { - Title = "Units Produced By Line", - ColumnSpan = 19, - RowSpan = 38 - }; - - var field = visualization.DataDefinition.Fields.Where(x => x.FieldName == "Date").First() as DateField; - field.DataFilter = new DateTimeFilter() - { - FilterType = FilterType.FilterByRule, - DateFiscalYearStartMonth = 0, - DisplayInLocalTimeZone = false, - RuleType = DateRuleType.LastMonth - }; - - visualization.Labels.Add(new DimensionColumn() - { - DataField = new TextDataField("Line") - }); - - visualization.Values.Add(new MeasureColumn() - { - DataField = new NumberDataField("Units Produced") - { - Sorting = SortingType.Desc, - Formatting = new NumberFormatting() - { - DecimalDigits = 0, - ShowGroupingSeparator = true, - } - } - }); - - return visualization; - } - - private static Visualization CreateDoughnutChartVisualization(DataSourceItem excelDataSourceItem) - { - var visualization = new DoughnutChartVisualization(excelDataSourceItem) - { - Title = "Operators Available by Function", - ColumnSpan = 21, - RowSpan = 38, - }; - - var field = visualization.DataDefinition.Fields.Where(x => x.FieldName == "Date").First() as DateField; - field.DataFilter = new DateTimeFilter() - { - FilterType = FilterType.FilterByRule, - DateFiscalYearStartMonth = 0, - DisplayInLocalTimeZone = false, - RuleType = DateRuleType.LastMonth - }; - - visualization.Labels.Add(new DimensionColumn() - { - DataField = new TextDataField("Operators by Function") - }); - - visualization.Values.Add(new MeasureColumn() - { - DataField = new NumberDataField("Operators Available ") - { - Sorting = SortingType.Asc, - Formatting = new NumberFormatting() - { - DecimalDigits = 0, - ShowGroupingSeparator = true - } - } - }); - - return visualization; - } - - private static Visualization CreateCircularGaugeVisualization(DataSourceItem excelDataSourceItem) - { - var visualization = new CircularGaugeVisualization(excelDataSourceItem) - { - Title = "Line 2 Efficiency", - ColumnSpan = 20, - RowSpan = 19 - }; - - var field = visualization.DataDefinition.Fields.Where(x => x.FieldName == "Line").First() as TextField; - field.DataFilter = new TextFilter() - { - FilterType = FilterType.SelectedValues, - SelectedValues = new System.Collections.Generic.List() - { - new FilterValue() { Name = "Line 5", Value = "Line 5"}, - new FilterValue() { Name = "Line 2", Value = "Line 2"} - } - }; - - visualization.Settings.Minimum = new Bound() { Value = 0.0, ValueType = BoundValueType.NumberValue }; - visualization.Settings.Maximum = new Bound() { Value = 1.0, ValueType = BoundValueType.NumberValue }; - visualization.Settings.UpperBand.Value = 100.0; - visualization.Settings.MiddleBand.Value = 0.0; - - visualization.Values.Add(new MeasureColumn() - { - DataField = new NumberDataField("Efficiency") - { - AggregationType = AggregationType.Avg, - Formatting = new NumberFormatting() - { - FormatType = NumberFormattingType.Percent, - DecimalDigits = 2, - ShowGroupingSeparator = false, - ApplyMkFormat = true, - } - } - }); - - visualization.Label = new DimensionColumn() - { - DataField = new TextDataField("Line") - }; - - return visualization; - } - - private static Visualization CreateCircularGaugeVisualization2(DataSourceItem excelDataSourceItem) - { - var visualization = new CircularGaugeVisualization(excelDataSourceItem) - { - Title = "Line 1 Efficiency", - ColumnSpan = 20, - RowSpan = 19 - }; - - var field = visualization.DataDefinition.Fields.Where(x => x.FieldName == "Line").First() as TextField; - field.DataFilter = new TextFilter() - { - FilterType = FilterType.SelectedValues, - SelectedValues = new System.Collections.Generic.List() - { - new FilterValue() { Name = "Line 1", Value = "Line 1"} - } - }; - - visualization.Settings.Minimum = new Bound() { Value = 0.0, ValueType = BoundValueType.NumberValue }; - visualization.Settings.Maximum = new Bound() { Value = 1.0, ValueType = BoundValueType.NumberValue }; - visualization.Settings.UpperBand.Value = 100.0; - visualization.Settings.MiddleBand.Value = 0.0; - - visualization.Values.Add(new MeasureColumn() - { - DataField = new NumberDataField("Efficiency") - { - AggregationType = AggregationType.Max, - Formatting = new NumberFormatting() - { - FormatType = NumberFormattingType.Percent, - DecimalDigits = 2, - ShowGroupingSeparator = false, - ApplyMkFormat = true, - } - } - }); - - visualization.Label = new DimensionColumn() - { - DataField = new TextDataField("Line") - }; - - return visualization; - } - - private static Visualization CreateColumnChartVisualization2(DataSourceItem excelDataSourceItem) - { - var visualization = new ColumnChartVisualization(excelDataSourceItem) - { - Title = "Orders In vs Orders Shipped", - ColumnSpan = 60, - RowSpan = 32 - }; - - var field = visualization.DataDefinition.Fields.Where(x => x.FieldName == "Date").First() as DateField; - field.DataFilter = new DateTimeFilter() - { - FilterType = FilterType.FilterByRule, - DateFiscalYearStartMonth = 0, - DisplayInLocalTimeZone = false, - RuleType = DateRuleType.LastYear - }; - - visualization.Labels.Add(new DimensionColumn() - { - DataField = new DateDataField("Date") - { - AggregationType = DateAggregationType.Month - } - }); - - visualization.Values.Add(new MeasureColumn() - { - DataField = new NumberDataField("Orders In") - }); - visualization.Values.Add(new MeasureColumn() - { - DataField = new NumberDataField("Orders Shipped ") - }); - - return visualization; - } - } -} +using Reveal.Sdk.Dom; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Filters; +using Reveal.Sdk.Dom.Visualizations; +using Sandbox.Helpers; +using System.Linq; + +namespace Sandbox.Factories +{ + internal class ManufacturingDashboard + { + internal static RdashDocument CreateDashboard() + { + var excelDataSourceItem = DataSourceFactory.GetManufacturingDataSourceItem(); + + var document = new RdashDocument("Manufacturing") + { + Title = "Manufacturing", + Theme = Theme.RockyMountain, + Description = "I created this in code", + UseAutoLayout = false, + }; + + document.Visualizations.Add(CreateIndicatorVisualization("Productivity", "Overall Plant Productivity ", excelDataSourceItem, true)); + document.Visualizations.Add(CreateIndicatorVisualization("Units Lost", "Units Lost", excelDataSourceItem)); + document.Visualizations.Add(CreateLineChartVisualization(excelDataSourceItem)); + document.Visualizations.Add(CreateColumnChartVisualization(excelDataSourceItem)); + document.Visualizations.Add(CreateDoughnutChartVisualization(excelDataSourceItem)); + document.Visualizations.Add(CreateCircularGaugeVisualization(excelDataSourceItem)); + document.Visualizations.Add(CreateCircularGaugeVisualization2(excelDataSourceItem)); + document.Visualizations.Add(CreateColumnChartVisualization2(excelDataSourceItem)); + + return document; + } + + private static Visualization CreateIndicatorVisualization(string title, string field, DataSourceItem excelDataSourceItem, bool avg = false) + { + var visualization = new KpiTimeVisualization(excelDataSourceItem) + { + Title = title, + ColumnSpan = 10, + RowSpan = 22, + }; + + visualization.Date = new DimensionColumn() + { + DataField = new DateDataField("Date") + }; + + NumberDataField dataField = new NumberDataField(field); + if (avg) + { + dataField.AggregationType = AggregationType.Avg; + dataField.Formatting = new NumberFormatting() + { + FormatType = NumberFormattingType.Percent, + DecimalDigits = 0, + ShowGroupingSeparator = true, + ApplyMkFormat = true + }; + } + + visualization.Values.Add(new MeasureColumn() + { + DataField = dataField + }); + + return visualization; + } + + private static Visualization CreateLineChartVisualization(DataSourceItem excelDataSourceItem) + { + var visualization = new LineChartVisualization(excelDataSourceItem) + { + Title = "Cost of Labor vs Revenue", + ColumnSpan = 40, + RowSpan = 22, + }; + + var field = visualization.DataDefinition.AsTabular().Fields.Where(x => x.FieldName == "Date").First() as DateField; + field.DataFilter = new DateTimeFilter() + { + FilterType = FilterType.FilterByRule, + DateFiscalYearStartMonth = 0, + DisplayInLocalTimeZone = false, + RuleType = DateRuleType.LastYear + }; + + visualization.Labels.Add(new DimensionColumn() + { + DataField = new DateDataField("Date") + { + AggregationType = DateAggregationType.Month + } + }); + + visualization.Values.Add(new MeasureColumn() + { + DataField = new NumberDataField("Cost of Labor ") + { + Formatting = new NumberFormatting() + { + FormatType = NumberFormattingType.Currency, + DecimalDigits = 0, + ShowGroupingSeparator = true, + } + } + }); + visualization.Values.Add(new MeasureColumn() + { + DataField = new NumberDataField("Revenue") + { + Formatting = new NumberFormatting() + { + FormatType = NumberFormattingType.Currency, + DecimalDigits = 0, + ShowGroupingSeparator = true, + } + } + }); + + return visualization; + } + + private static Visualization CreateColumnChartVisualization(DataSourceItem excelDataSourceItem) + { + var visualization = new ColumnChartVisualization(excelDataSourceItem) + { + Title = "Units Produced By Line", + ColumnSpan = 19, + RowSpan = 38 + }; + + var field = visualization.DataDefinition.AsTabular().Fields.Where(x => x.FieldName == "Date").First() as DateField; + field.DataFilter = new DateTimeFilter() + { + FilterType = FilterType.FilterByRule, + DateFiscalYearStartMonth = 0, + DisplayInLocalTimeZone = false, + RuleType = DateRuleType.LastMonth + }; + + visualization.Labels.Add(new DimensionColumn() + { + DataField = new TextDataField("Line") + }); + + visualization.Values.Add(new MeasureColumn() + { + DataField = new NumberDataField("Units Produced") + { + Sorting = SortingType.Desc, + Formatting = new NumberFormatting() + { + DecimalDigits = 0, + ShowGroupingSeparator = true, + } + } + }); + + return visualization; + } + + private static Visualization CreateDoughnutChartVisualization(DataSourceItem excelDataSourceItem) + { + var visualization = new DoughnutChartVisualization(excelDataSourceItem) + { + Title = "Operators Available by Function", + ColumnSpan = 21, + RowSpan = 38, + }; + + var field = visualization.DataDefinition.AsTabular().Fields.Where(x => x.FieldName == "Date").First() as DateField; + field.DataFilter = new DateTimeFilter() + { + FilterType = FilterType.FilterByRule, + DateFiscalYearStartMonth = 0, + DisplayInLocalTimeZone = false, + RuleType = DateRuleType.LastMonth + }; + + visualization.Labels.Add(new DimensionColumn() + { + DataField = new TextDataField("Operators by Function") + }); + + visualization.Values.Add(new MeasureColumn() + { + DataField = new NumberDataField("Operators Available ") + { + Sorting = SortingType.Asc, + Formatting = new NumberFormatting() + { + DecimalDigits = 0, + ShowGroupingSeparator = true + } + } + }); + + return visualization; + } + + private static Visualization CreateCircularGaugeVisualization(DataSourceItem excelDataSourceItem) + { + var visualization = new CircularGaugeVisualization(excelDataSourceItem) + { + Title = "Line 2 Efficiency", + ColumnSpan = 20, + RowSpan = 19 + }; + + var field = visualization.DataDefinition.AsTabular().Fields.Where(x => x.FieldName == "Line").First() as TextField; + field.DataFilter = new TextFilter() + { + FilterType = FilterType.SelectedValues, + SelectedValues = new System.Collections.Generic.List() + { + new FilterValue() { Name = "Line 5", Value = "Line 5"}, + new FilterValue() { Name = "Line 2", Value = "Line 2"} + } + }; + + visualization.Settings.Minimum = new Bound() { Value = 0.0, ValueType = BoundValueType.NumberValue }; + visualization.Settings.Maximum = new Bound() { Value = 1.0, ValueType = BoundValueType.NumberValue }; + visualization.Settings.UpperBand.Value = 100.0; + visualization.Settings.MiddleBand.Value = 0.0; + + visualization.Values.Add(new MeasureColumn() + { + DataField = new NumberDataField("Efficiency") + { + AggregationType = AggregationType.Avg, + Formatting = new NumberFormatting() + { + FormatType = NumberFormattingType.Percent, + DecimalDigits = 2, + ShowGroupingSeparator = false, + ApplyMkFormat = true, + } + } + }); + + visualization.Label = new DimensionColumn() + { + DataField = new TextDataField("Line") + }; + + return visualization; + } + + private static Visualization CreateCircularGaugeVisualization2(DataSourceItem excelDataSourceItem) + { + var visualization = new CircularGaugeVisualization(excelDataSourceItem) + { + Title = "Line 1 Efficiency", + ColumnSpan = 20, + RowSpan = 19 + }; + + var field = visualization.DataDefinition.AsTabular().Fields.Where(x => x.FieldName == "Line").First() as TextField; + field.DataFilter = new TextFilter() + { + FilterType = FilterType.SelectedValues, + SelectedValues = new System.Collections.Generic.List() + { + new FilterValue() { Name = "Line 1", Value = "Line 1"} + } + }; + + visualization.Settings.Minimum = new Bound() { Value = 0.0, ValueType = BoundValueType.NumberValue }; + visualization.Settings.Maximum = new Bound() { Value = 1.0, ValueType = BoundValueType.NumberValue }; + visualization.Settings.UpperBand.Value = 100.0; + visualization.Settings.MiddleBand.Value = 0.0; + + visualization.Values.Add(new MeasureColumn() + { + DataField = new NumberDataField("Efficiency") + { + AggregationType = AggregationType.Max, + Formatting = new NumberFormatting() + { + FormatType = NumberFormattingType.Percent, + DecimalDigits = 2, + ShowGroupingSeparator = false, + ApplyMkFormat = true, + } + } + }); + + visualization.Label = new DimensionColumn() + { + DataField = new TextDataField("Line") + }; + + return visualization; + } + + private static Visualization CreateColumnChartVisualization2(DataSourceItem excelDataSourceItem) + { + var visualization = new ColumnChartVisualization(excelDataSourceItem) + { + Title = "Orders In vs Orders Shipped", + ColumnSpan = 60, + RowSpan = 32 + }; + + var field = visualization.DataDefinition.AsTabular().Fields.Where(x => x.FieldName == "Date").First() as DateField; + field.DataFilter = new DateTimeFilter() + { + FilterType = FilterType.FilterByRule, + DateFiscalYearStartMonth = 0, + DisplayInLocalTimeZone = false, + RuleType = DateRuleType.LastYear + }; + + visualization.Labels.Add(new DimensionColumn() + { + DataField = new DateDataField("Date") + { + AggregationType = DateAggregationType.Month + } + }); + + visualization.Values.Add(new MeasureColumn() + { + DataField = new NumberDataField("Orders In") + }); + visualization.Values.Add(new MeasureColumn() + { + DataField = new NumberDataField("Orders Shipped ") + }); + + return visualization; + } + } +} diff --git a/e2e/Sandbox/Factories/SalesDashboard.cs b/e2e/Sandbox/Factories/SalesDashboard.cs index 7a396d79..841f3f0d 100644 --- a/e2e/Sandbox/Factories/SalesDashboard.cs +++ b/e2e/Sandbox/Factories/SalesDashboard.cs @@ -1,193 +1,193 @@ -using Reveal.Sdk.Dom; -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Filters; -using Reveal.Sdk.Dom.Visualizations; -using Sandbox.Helpers; -using System.Linq; - -namespace Sandbox.Factories -{ - internal class SalesDashboard - { - internal static RdashDocument CreateDashboard() - { - var excelDataSourceItem = DataSourceFactory.GetSalesDataSourceItem(); - - var document = new RdashDocument() - { - Title = "Sales", - Description = "I created this in code", - UseAutoLayout = false, - }; - - document.Filters.Add(new DashboardDateFilter() - { - Title = "My Date Filter" - }); - - var territoryFilter = new DashboardDataFilter(excelDataSourceItem) - { - Title = "Territory", - SelectedFieldName = "Territory", - AllowMultipleSelection = true, - AllowEmptySelection = true - }; - document.Filters.Add(territoryFilter); - - var globalDateFilterBinding = new DashboardDateFilterBinding("Date"); - var territoryFilterBinding = new DashboardDataFilterBinding(territoryFilter); - - document.Visualizations.Add(CreateKpiTargetVisualization(excelDataSourceItem, territoryFilterBinding)); - document.Visualizations.Add(CreateSplineAreaChartVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); - document.Visualizations.Add(CreateStackedColumnChartVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); - document.Visualizations.Add(CreateIndicatorVisualization(excelDataSourceItem, territoryFilterBinding)); - document.Visualizations.Add(CreateSparklineVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); - document.Visualizations.Add(CreateBarChartVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); - document.Visualizations.Add(CreateColumnChartVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); - document.Visualizations.Add(CreateGaugeVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); - - return document; - } - - private static Visualization CreateKpiTargetVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) - { - return new KpiTargetVisualization("Sales", excelDataSourceItem) - .SetDate("Date") - .SetValue(new NumberDataField("Pipepline") - { - FieldLabel = "Actual Sales", - AggregationType = AggregationType.Sum, - Formatting = new NumberFormatting() - { - FormatType = NumberFormattingType.Currency, - DecimalDigits = 0, - ShowGroupingSeparator = true, - CurrencySymbol = "$", - NegativeFormat = NegativeFormatType.MinusSign, - ApplyMkFormat = true, - } - }) - .SetTarget("Forecasted") - .AddFilterBindings(filterBindings) - .SetPosition(20, 11); - } - - private static Visualization CreateSplineAreaChartVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) - { - return new SplineAreaChartVisualization("New vs Renewal Sales", excelDataSourceItem) - .SetLabel(new DateDataField("Date") { AggregationType = DateAggregationType.Month }) - .SetValues("New Sales", "Renewal Sales ") - .AddFilterBindings(filterBindings) - .SetPosition(39, 31); - } - - private static Visualization CreateStackedColumnChartVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) - { - return new StackedColumnChartVisualization("Sales by Product", excelDataSourceItem) - .SetLabel("Product") - .SetValues("New Sales", "Renewal Sales ") - .AddFilterBindings(filterBindings) - .SetPosition(39, 18); - } - - private static Visualization CreateIndicatorVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) - { - return new KpiTimeVisualization("Total Opportunities", excelDataSourceItem) - .SetDate(new DateDataField("Date") { AggregationType = DateAggregationType.Year }) - .SetValue("Total Opportunites") - .AddFilterBindings(filterBindings) - .SetPosition(19, 11); - } - - private static Visualization CreateSparklineVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) - { - return new SparklineVisualization("New Seats by Product", excelDataSourceItem) - .SetDate(new DateDataField("Date") { AggregationType = DateAggregationType.Month }) - .SetValue(new NumberDataField("New Seats") - { - Formatting = new NumberFormatting() - { - FormatType = NumberFormattingType.Number, - DecimalDigits = 0, - ShowGroupingSeparator = true, - CurrencySymbol = "$", - NegativeFormat = NegativeFormatType.MinusSign, - ApplyMkFormat = false, - } - }) - .SetCategory("Product") - .ConfigureSettings(settings => - { - settings.TextFieldAlignment = Alignment.Left; - settings.NumericFieldAlignment = Alignment.Left; - settings.DateFieldAlignment = Alignment.Left; - settings.AggregationType = SparklineAggregationType.Months; - }) - .AddFilterBindings(filterBindings) - .SetPosition(30, 31); - } - - private static Visualization CreateBarChartVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) - { - return new BarChartVisualization("Sales", excelDataSourceItem) - .SetLabel("Employee") - .SetValue(new NumberDataField("Pipepline") - { - Sorting = SortingType.Asc, - Formatting = new NumberFormatting() - { - FormatType = NumberFormattingType.Currency, - DecimalDigits = 0, - ShowGroupingSeparator = true, - ApplyMkFormat = true, - } - }) - .AddFilterBindings(filterBindings) - .SetPosition(43, 29); - } - - private static Visualization CreateColumnChartVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) - { - return new ColumnChartVisualization("", excelDataSourceItem) - .SetLabel(new DateDataField("Date") { AggregationType = DateAggregationType.Month }) - .SetValues("Leads", "Hot Leads") - .AddFilterBindings(filterBindings) - .SetPosition(46, 31); - } - - private static Visualization CreateGaugeVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) - { - var visualization = new BulletGraphVisualization("Quotas by Sales Rep", excelDataSourceItem) - .SetLabel("Employee") - .SetValue(new NumberDataField("Quota") - { - Formatting = new NumberFormatting() - { - FormatType = NumberFormattingType.Percent, - DecimalDigits = 2, - ShowGroupingSeparator = false, - ApplyMkFormat = true, - } - }) - .ConfigureSettings(settings => - { - settings.Minimum = new Bound() { Value = 0.8 }; - settings.Maximum = new Bound() { Value = 2.0 }; - - settings.ValueComparisonType = ValueComparisonType.Number; - settings.UpperBand.Value = 100.0; - settings.MiddleBand.Value = 80.0; - }) - .AddDataFilter("Quota", new NumberFilter() - { - FilterType = FilterType.FilterByRule, - RuleType = NumberRuleType.TopItems, - Value = 10.0 - }) - .AddFilterBindings(filterBindings) - .SetPosition(33, 29); - - return visualization; - } - } +using Reveal.Sdk.Dom; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Filters; +using Reveal.Sdk.Dom.Visualizations; +using Sandbox.Helpers; +using System.Linq; + +namespace Sandbox.Factories +{ + internal class SalesDashboard + { + internal static RdashDocument CreateDashboard() + { + var excelDataSourceItem = DataSourceFactory.GetSalesDataSourceItem(); + + var document = new RdashDocument() + { + Title = "Sales", + Description = "I created this in code", + UseAutoLayout = false, + }; + + document.Filters.Add(new DashboardDateFilter() + { + Title = "My Date Filter" + }); + + var territoryFilter = new DashboardDataFilter(excelDataSourceItem) + { + Title = "Territory", + SelectedFieldName = "Territory", + AllowMultipleSelection = true, + AllowEmptySelection = true + }; + document.Filters.Add(territoryFilter); + + var globalDateFilterBinding = new DashboardDateFilterBinding("Date"); + var territoryFilterBinding = new DashboardDataFilterBinding(territoryFilter); + + document.Visualizations.Add(CreateKpiTargetVisualization(excelDataSourceItem, territoryFilterBinding)); + document.Visualizations.Add(CreateSplineAreaChartVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); + document.Visualizations.Add(CreateStackedColumnChartVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); + document.Visualizations.Add(CreateIndicatorVisualization(excelDataSourceItem, territoryFilterBinding)); + document.Visualizations.Add(CreateSparklineVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); + document.Visualizations.Add(CreateBarChartVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); + document.Visualizations.Add(CreateColumnChartVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); + document.Visualizations.Add(CreateGaugeVisualization(excelDataSourceItem, globalDateFilterBinding, territoryFilterBinding)); + + return document; + } + + private static Visualization CreateKpiTargetVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) + { + return new KpiTargetVisualization("Sales", excelDataSourceItem) + .SetDate("Date") + .SetValue(new NumberDataField("Pipepline") + { + FieldLabel = "Actual Sales", + AggregationType = AggregationType.Sum, + Formatting = new NumberFormatting() + { + FormatType = NumberFormattingType.Currency, + DecimalDigits = 0, + ShowGroupingSeparator = true, + CurrencySymbol = "$", + NegativeFormat = NegativeFormatType.MinusSign, + ApplyMkFormat = true, + } + }) + .SetTarget("Forecasted") + .AddFilterBindings(filterBindings) + .SetPosition(20, 11); + } + + private static Visualization CreateSplineAreaChartVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) + { + return new SplineAreaChartVisualization("New vs Renewal Sales", excelDataSourceItem) + .SetLabel(new DateDataField("Date") { AggregationType = DateAggregationType.Month }) + .SetValues("New Sales", "Renewal Sales ") + .AddFilterBindings(filterBindings) + .SetPosition(39, 31); + } + + private static Visualization CreateStackedColumnChartVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) + { + return new StackedColumnChartVisualization("Sales by Product", excelDataSourceItem) + .SetLabel("Product") + .SetValues("New Sales", "Renewal Sales ") + .AddFilterBindings(filterBindings) + .SetPosition(39, 18); + } + + private static Visualization CreateIndicatorVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) + { + return new KpiTimeVisualization("Total Opportunities", excelDataSourceItem) + .SetDate(new DateDataField("Date") { AggregationType = DateAggregationType.Year }) + .SetValue("Total Opportunites") + .AddFilterBindings(filterBindings) + .SetPosition(19, 11); + } + + private static Visualization CreateSparklineVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) + { + return new SparklineVisualization("New Seats by Product", excelDataSourceItem) + .SetDate(new DateDataField("Date") { AggregationType = DateAggregationType.Month }) + .SetValue(new NumberDataField("New Seats") + { + Formatting = new NumberFormatting() + { + FormatType = NumberFormattingType.Number, + DecimalDigits = 0, + ShowGroupingSeparator = true, + CurrencySymbol = "$", + NegativeFormat = NegativeFormatType.MinusSign, + ApplyMkFormat = false, + } + }) + .SetCategory("Product") + .ConfigureSettings(settings => + { + settings.TextFieldAlignment = Alignment.Left; + settings.NumericFieldAlignment = Alignment.Left; + settings.DateFieldAlignment = Alignment.Left; + settings.AggregationType = SparklineAggregationType.Months; + }) + .AddFilterBindings(filterBindings) + .SetPosition(30, 31); + } + + private static Visualization CreateBarChartVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) + { + return new BarChartVisualization("Sales", excelDataSourceItem) + .SetLabel("Employee") + .SetValue(new NumberDataField("Pipepline") + { + Sorting = SortingType.Asc, + Formatting = new NumberFormatting() + { + FormatType = NumberFormattingType.Currency, + DecimalDigits = 0, + ShowGroupingSeparator = true, + ApplyMkFormat = true, + } + }) + .AddFilterBindings(filterBindings) + .SetPosition(43, 29); + } + + private static Visualization CreateColumnChartVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) + { + return new ColumnChartVisualization("", excelDataSourceItem) + .SetLabel(new DateDataField("Date") { AggregationType = DateAggregationType.Month }) + .SetValues("Leads", "Hot Leads") + .AddFilterBindings(filterBindings) + .SetPosition(46, 31); + } + + private static Visualization CreateGaugeVisualization(DataSourceItem excelDataSourceItem, params Binding[] filterBindings) + { + var visualization = new BulletGraphVisualization("Quotas by Sales Rep", excelDataSourceItem) + .SetLabel("Employee") + .SetValue(new NumberDataField("Quota") + { + Formatting = new NumberFormatting() + { + FormatType = NumberFormattingType.Percent, + DecimalDigits = 2, + ShowGroupingSeparator = false, + ApplyMkFormat = true, + } + }) + .ConfigureSettings(settings => + { + settings.Minimum = new Bound() { Value = 0.8 }; + settings.Maximum = new Bound() { Value = 2.0 }; + + settings.ValueComparisonType = ValueComparisonType.Number; + settings.UpperBand.Value = 100.0; + settings.MiddleBand.Value = 80.0; + }) + .AddDataFilter("Quota", new NumberFilter() + { + FilterType = FilterType.FilterByRule, + RuleType = NumberRuleType.TopItems, + Value = 10.0 + }) + .AddFilterBindings(filterBindings) + .SetPosition(33, 29); + + return visualization; + } + } } \ No newline at end of file diff --git a/e2e/Sandbox/MainWindow.xaml.cs b/e2e/Sandbox/MainWindow.xaml.cs index 4e7e326d..2b3626a3 100644 --- a/e2e/Sandbox/MainWindow.xaml.cs +++ b/e2e/Sandbox/MainWindow.xaml.cs @@ -1,97 +1,99 @@ -using Reveal.Sdk; -using Reveal.Sdk.Dom; -using Sandbox.Factories; -using Sandbox.Helpers; -using System; -using System.IO; -using System.Windows; - -namespace Sandbox -{ - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow : Window - { - static readonly string _dashboardFilePath = Path.Combine(Environment.CurrentDirectory, "Dashboards"); - - readonly string _readFilePath = Path.Combine(_dashboardFilePath, DashboardFileNames.Marketing); - - readonly string _saveJsonToPath = Path.Combine(_dashboardFilePath, "MyDashboard.json"); - readonly string _saveRdashToPath = Path.Combine(_dashboardFilePath, DashboardFileNames.MyDashboard); - - public MainWindow() - { - InitializeComponent(); - - //RevealSdkSettings.EnableNewCharts = true; - RevealSdkSettings.AuthenticationProvider = new AuthenticationProvider(); - - _revealView.LinkedDashboardProvider = (string dashboardId, string linkTitle) => - { - var path = Path.Combine(_dashboardFilePath, $"{dashboardId}.rdash"); - if (File.Exists(path)) - return new RVDashboard(path); - - return null; - }; - - _revealView.DashboardSelectorRequested += RevealView_DashboardSelectorRequested; - } - - private void RevealView_DashboardSelectorRequested(object sender, DashboardSelectorRequestedEventArgs e) - { - e.Callback("Campaigns"); - } - - private async void RevealView_SaveDashboard(object sender, DashboardSaveEventArgs e) - { - //var json = _revealView.Dashboard.ExportToJson(); - var path = Path.Combine(Environment.CurrentDirectory, $"Dashboards/{e.Name}.rdash"); - var data = await e.Serialize(); - var json = _revealView.Dashboard.ExportToJson(); - using (var output = File.Open(path, FileMode.Open)) - { - output.Write(data, 0, data.Length); - } - - e.SaveFinished(); - } - - private void Load_Dashboard(object sender, RoutedEventArgs e) - { - _revealView.Dashboard = new RVDashboard(_readFilePath); - } - - private void Clear_Dashboard(object sender, RoutedEventArgs e) - { - _revealView.Dashboard = new RVDashboard(); - } - - private async void Read_Dashboard(object sender, RoutedEventArgs e) - { - var document = RdashDocument.Load(_readFilePath); - var json = document.ToJsonString(); - _revealView.Dashboard = await RVDashboard.LoadFromJsonAsync(json); - } - - private async void Create_Dashboard(object sender, RoutedEventArgs e) - { - //var document = MarketingDashboard.CreateDashboard(); - //var document = SalesDashboard.CreateDashboard(); - //var document = CampaignsDashboard.CreateDashboard(); - //var document = HealthcareDashboard.CreateDashboard(); - //var document = ManufacturingDashboard.CreateDashboard(); - var document = CustomDashboard.CreateDashboard(); - //var document = RestDataSourceDashboards.CreateDashboard(); - //var document = SqlServerDataSourceDashboards.CreateDashboard(); - //var document = DashboardLinkingDashboard.CreateDashboard(); - - //document.Save(_saveRdashToPath); - - var json = document.ToJsonString(); - //json.Save(_saveJsonToPath); - _revealView.Dashboard = await RVDashboard.LoadFromJsonAsync(json); - } - } -} +using Reveal.Sdk; +using Reveal.Sdk.Dom; +using Sandbox.Factories; +using Sandbox.Helpers; +using System; +using System.IO; +using System.Windows; + +namespace Sandbox +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + static readonly string _dashboardFilePath = Path.Combine(Environment.CurrentDirectory, "Dashboards"); + + //readonly string _readFilePath = Path.Combine(_dashboardFilePath, DashboardFileNames.Marketing); + //readonly string _readFilePath = Path.Combine(_dashboardFilePath, "Jason - AB Sales.rdash"); + readonly string _readFilePath = Path.Combine(_dashboardFilePath, "JB - New Infragistics Scorecard Test.rdash"); + + readonly string _saveJsonToPath = Path.Combine(_dashboardFilePath, "MyDashboard.json"); + readonly string _saveRdashToPath = Path.Combine(_dashboardFilePath, DashboardFileNames.MyDashboard); + + public MainWindow() + { + InitializeComponent(); + + //RevealSdkSettings.EnableNewCharts = true; + RevealSdkSettings.AuthenticationProvider = new AuthenticationProvider(); + + _revealView.LinkedDashboardProvider = (string dashboardId, string linkTitle) => + { + var path = Path.Combine(_dashboardFilePath, $"{dashboardId}.rdash"); + if (File.Exists(path)) + return new RVDashboard(path); + + return null; + }; + + _revealView.DashboardSelectorRequested += RevealView_DashboardSelectorRequested; + } + + private void RevealView_DashboardSelectorRequested(object sender, DashboardSelectorRequestedEventArgs e) + { + e.Callback("Campaigns"); + } + + private async void RevealView_SaveDashboard(object sender, DashboardSaveEventArgs e) + { + //var json = _revealView.Dashboard.ExportToJson(); + var path = Path.Combine(Environment.CurrentDirectory, $"Dashboards/{e.Name}.rdash"); + var data = await e.Serialize(); + var json = _revealView.Dashboard.ExportToJson(); + using (var output = File.Open(path, FileMode.Open)) + { + output.Write(data, 0, data.Length); + } + + e.SaveFinished(); + } + + private void Load_Dashboard(object sender, RoutedEventArgs e) + { + _revealView.Dashboard = new RVDashboard(_readFilePath); + } + + private void Clear_Dashboard(object sender, RoutedEventArgs e) + { + _revealView.Dashboard = new RVDashboard(); + } + + private async void Read_Dashboard(object sender, RoutedEventArgs e) + { + var document = RdashDocument.Load(_readFilePath); + var json = document.ToJsonString(); + _revealView.Dashboard = await RVDashboard.LoadFromJsonAsync(json); + } + + private async void Create_Dashboard(object sender, RoutedEventArgs e) + { + //var document = MarketingDashboard.CreateDashboard(); + //var document = SalesDashboard.CreateDashboard(); + //var document = CampaignsDashboard.CreateDashboard(); + //var document = HealthcareDashboard.CreateDashboard(); + //var document = ManufacturingDashboard.CreateDashboard(); + var document = CustomDashboard.CreateDashboard(); + //var document = RestDataSourceDashboards.CreateDashboard(); + //var document = SqlServerDataSourceDashboards.CreateDashboard(); + //var document = DashboardLinkingDashboard.CreateDashboard(); + + //document.Save(_saveRdashToPath); + + var json = document.ToJsonString(); + //json.Save(_saveJsonToPath); + _revealView.Dashboard = await RVDashboard.LoadFromJsonAsync(json); + } + } +} diff --git a/e2e/Sandbox/Sandbox.csproj b/e2e/Sandbox/Sandbox.csproj index f12fb97a..75ae0d8a 100644 --- a/e2e/Sandbox/Sandbox.csproj +++ b/e2e/Sandbox/Sandbox.csproj @@ -22,6 +22,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/src/Reveal.Sdk.Dom/Core/Constants/SchemaTypeNames.cs b/src/Reveal.Sdk.Dom/Core/Constants/SchemaTypeNames.cs index abcb2a5a..701c84f1 100644 --- a/src/Reveal.Sdk.Dom/Core/Constants/SchemaTypeNames.cs +++ b/src/Reveal.Sdk.Dom/Core/Constants/SchemaTypeNames.cs @@ -1,91 +1,97 @@ -using System; - -namespace Reveal.Sdk.Dom.Core.Constants -{ - //these constants are needed in order to map existing json Schema names to new API names, otherwise we could just generate them in code - internal class SchemaTypeNames - { - //***************** DataSourcs ******************* - internal const string DataSourceType = "DataSourceType"; - internal const string DataSourceItemType = "DataSourceItemType"; - - //***************** FILTERS ******************* - internal const string DateGlobalFilterType = "DateGlobalFilterType"; - internal const string TabularGlobalFilterType = "TabularGlobalFilterType"; - internal const string NumberFilterType = "NumberFilterType"; - internal const string DateTimeFilterType = "DateTimeFilterType"; - internal const string StringFilterType = "StringFilterType"; - internal const string TimeFilterType = "TimeFilterType"; - internal const string XmlaDateFilterType = "XmlaDateFilterType"; - internal const string XmlaRegularFilterType = "XmlaRegularFilterType"; - internal const string XmlaStringFilterRuleType = "XmlaStringFilterRuleType"; - internal const string XmlaNumberFilterRuleType = "XmlaNumberFilterRuleType"; - - //***************** Visualizations - Settings ******************* - internal const string AssetVisualizationSettingsType = "AssetVisualizationSettingsType"; - internal const string ChartVisualizationSettingsType = "ChartVisualizationSettingsType"; - internal const string ChoroplethMapVisualizationSettingsType = "ChoroplethMapVisualizationSettingsType"; - internal const string DiyVisualizationSettingsType = "DIYVisualizationSettingsType"; - internal const string GaugeVisualizationSettingsType = "GaugeVisualizationSettingsType"; - internal const string GeoMapBaseVisualizationSettingsType = "GeoMapBaseVisualizationSettingsType"; - internal const string GridVisualizationSettingsType = "GridVisualizationSettingsType"; - internal const string HeatMapVisualizationSettingsType = "HeatMapVisualizationSettingsType"; - internal const string IndicatorVisualizationSettingsType = "IndicatorVisualizationSettingsType"; - internal const string IndicatorTargetVisualizationSettingsType = "IndicatorTargetVisualizationSettingsType"; - internal const string MapVisualizationSettingsType = "MapVisualizationSettingsType"; - internal const string PivotVisualizationSettingsType = "PivotVisualizationSettingsType"; - internal const string ScatterMapVisualizationSettingsType = "ScatterMapVisualizationSettingsType"; - internal const string ScriptVisualizationSettingsType = "ScriptVisualizationSettingsType"; - internal const string SparklineVisualizationSettingsType = "SparklineVisualizationSettingsType"; - internal const string TextBoxVisualizationSettingsType = "TextBoxVisualizationSettingsType"; - internal const string TreeMapVisualizationSettingsType = "TreeMapVisualizationSettingsType"; - - //***************** Visualizations - Specs ******************* - internal const string AssetVisualizationDataSpecType = "AssetVisualizationDataSpecType"; - internal const string BubbleVisualizationDataSpecType = "BubbleVisualizationDataSpecType"; - internal const string ChoroplethMapVisualizationDataSpecType = "ChoroplethMapVisualizationDataSpecType"; - internal const string CompositeChartVisualizationDataSpecType = "CompositeChartVisualizationDataSpecType"; - internal const string FinancialVisualizationDataSpecType = "FinancialVisualizationDataSpecType"; - internal const string GridVisualizationDataSpecType = "GridVisualizationDataSpecType"; - internal const string IndicatorBaseVisualizationDataSpecType = "IndicatorBaseVisualizationDataSpecType"; - internal const string LinearGaugeVisualizationDataSpecType = "LinearGaugeVisualizationDataSpecType"; - internal const string ScatterMapVisualizationDataSpecType = "ScatterMapVisualizationDataSpecType"; - internal const string ScatterVisualizationDataSpecType = "ScatterVisualizationDataSpecType"; - internal const string SingleGaugeVisualizationDataSpecType = "SingleGaugeVisualizationDataSpecType"; - internal const string SingleValueCategoryVisualizationDataSpecType = "SingleValueCategoryVisualizationDataSpecType"; - internal const string SingleValueVisualizationDataSpecType = "SingleValueVisualizationDataSpecType"; - internal const string TreeMapVisualizationDataSpecType = "TreeMapVisualizationDataSpecType"; - internal const string CategoryVisualizationDataSpecType = "CategoryVisualizationDataSpecType"; - internal const string IndicatorVisualizationDataSpecType = "IndicatorVisualizationDataSpecType"; - internal const string IndicatorTargetVisualizationDataSpecType = "IndicatorTargetVisualizationDataSpecType"; - internal const string PivotVisualizationDataSpecType = "PivotVisualizationDataSpecType"; - internal const string SingleRowVisualizationSettingsType = "SingleRowVisualizationSettingsType"; - internal const string SingleValueLabelsVisualizationDataSpecType = "SingleValueLabelsVisualizationDataSpecType"; - internal const string SparklineVisualizationDataSpecType = "SparklineVisualizationDataSpecType"; - internal const string TimeSeriesVisualizationDataSpecType = "TimeSeriesVisualizationDataSpecType"; - - internal const string DateFormattingSpecType = "DateFormattingSpecType"; - internal const string DimensionColumnSpecType = "DimensionColumnSpecType"; - internal const string MeasureColumnSpecType = "MeasureColumnSpecType"; - internal const string TabularDataSpecType = "TabularDataSpecType"; - internal const string NumberFormattingSpecType = "NumberFormattingSpecType"; - internal const string ResourceDataSpecType = "ResourceDataSpecType"; - internal const string TextBoxDataSpecType = "TextBoxDataSpecType"; - internal const string XmlaDataSpecType = "XmlaDataSpecType"; - - //******* not sure how these should be classified yet ***************** - internal const string FieldBindingSourceType = "FieldBindingSourceType"; - internal const string ParameterBindingSourceType = "ParameterBindingSourceType"; - internal const string DateGlobalFilterBindingTargetType = "DateGlobalFilterBindingTargetType"; - internal const string DateTimeFieldSettingsType = "DateTimeFieldSettingsType"; - internal const string SummarizationDateFieldType = "SummarizationDateFieldType"; - internal const string SummarizationRegularFieldType = "SummarizationRegularFieldType"; - internal const string SummarizationValueFieldType = "SummarizationValueFieldType"; - internal const string CompositeDataSourceItemType = "CompositeDataSourceItemType"; - internal const string DataBasedGlobalFilterBindingTargetType = "DataBasedGlobalFilterBindingTargetType"; - internal const string GlobalVariableBindingTargetType = "GlobalVariableBindingTargetType"; - internal const string GaugeBandType = "GaugeBandType"; - internal const string ConditionalFormattingBandType = "ConditionalFormattingBandType"; - internal const string TabularColumnSpecType = "TabularColumnSpecType"; - } -} +using System; + +namespace Reveal.Sdk.Dom.Core.Constants +{ + //these constants are needed in order to map existing json Schema names to new API names, otherwise we could just generate them in code + internal class SchemaTypeNames + { + //******************* DataSourcs ******************* + internal const string DataSourceType = "DataSourceType"; + internal const string DataSourceItemType = "DataSourceItemType"; + + //******************* FILTERS ******************* + internal const string DateGlobalFilterType = "DateGlobalFilterType"; + internal const string TabularGlobalFilterType = "TabularGlobalFilterType"; + internal const string NumberFilterType = "NumberFilterType"; + internal const string DateTimeFilterType = "DateTimeFilterType"; + internal const string StringFilterType = "StringFilterType"; + internal const string TimeFilterType = "TimeFilterType"; + internal const string XmlaDateFilterType = "XmlaDateFilterType"; + internal const string XmlaRegularFilterType = "XmlaRegularFilterType"; + internal const string XmlaStringFilterRuleType = "XmlaStringFilterRuleType"; + internal const string XmlaNumberFilterRuleType = "XmlaNumberFilterRuleType"; + + //******************* Visualizations - Settings ******************* + internal const string AssetVisualizationSettingsType = "AssetVisualizationSettingsType"; + internal const string ChartVisualizationSettingsType = "ChartVisualizationSettingsType"; + internal const string ChoroplethMapVisualizationSettingsType = "ChoroplethMapVisualizationSettingsType"; + internal const string DiyVisualizationSettingsType = "DIYVisualizationSettingsType"; + internal const string GaugeVisualizationSettingsType = "GaugeVisualizationSettingsType"; + internal const string GeoMapBaseVisualizationSettingsType = "GeoMapBaseVisualizationSettingsType"; + internal const string GridVisualizationSettingsType = "GridVisualizationSettingsType"; + internal const string HeatMapVisualizationSettingsType = "HeatMapVisualizationSettingsType"; + internal const string IndicatorVisualizationSettingsType = "IndicatorVisualizationSettingsType"; + internal const string IndicatorTargetVisualizationSettingsType = "IndicatorTargetVisualizationSettingsType"; + internal const string MapVisualizationSettingsType = "MapVisualizationSettingsType"; + internal const string PivotVisualizationSettingsType = "PivotVisualizationSettingsType"; + internal const string ScatterMapVisualizationSettingsType = "ScatterMapVisualizationSettingsType"; + internal const string ScriptVisualizationSettingsType = "ScriptVisualizationSettingsType"; + internal const string SparklineVisualizationSettingsType = "SparklineVisualizationSettingsType"; + internal const string TextBoxVisualizationSettingsType = "TextBoxVisualizationSettingsType"; + internal const string TreeMapVisualizationSettingsType = "TreeMapVisualizationSettingsType"; + + //******************* Visualizations - Specs ******************* + internal const string AssetVisualizationDataSpecType = "AssetVisualizationDataSpecType"; + internal const string BubbleVisualizationDataSpecType = "BubbleVisualizationDataSpecType"; + internal const string ChoroplethMapVisualizationDataSpecType = "ChoroplethMapVisualizationDataSpecType"; + internal const string CompositeChartVisualizationDataSpecType = "CompositeChartVisualizationDataSpecType"; + internal const string FinancialVisualizationDataSpecType = "FinancialVisualizationDataSpecType"; + internal const string GridVisualizationDataSpecType = "GridVisualizationDataSpecType"; + internal const string IndicatorBaseVisualizationDataSpecType = "IndicatorBaseVisualizationDataSpecType"; + internal const string LinearGaugeVisualizationDataSpecType = "LinearGaugeVisualizationDataSpecType"; + internal const string ScatterMapVisualizationDataSpecType = "ScatterMapVisualizationDataSpecType"; + internal const string ScatterVisualizationDataSpecType = "ScatterVisualizationDataSpecType"; + internal const string SingleGaugeVisualizationDataSpecType = "SingleGaugeVisualizationDataSpecType"; + internal const string SingleValueCategoryVisualizationDataSpecType = "SingleValueCategoryVisualizationDataSpecType"; + internal const string SingleValueVisualizationDataSpecType = "SingleValueVisualizationDataSpecType"; + internal const string TreeMapVisualizationDataSpecType = "TreeMapVisualizationDataSpecType"; + internal const string CategoryVisualizationDataSpecType = "CategoryVisualizationDataSpecType"; + internal const string IndicatorVisualizationDataSpecType = "IndicatorVisualizationDataSpecType"; + internal const string IndicatorTargetVisualizationDataSpecType = "IndicatorTargetVisualizationDataSpecType"; + internal const string PivotVisualizationDataSpecType = "PivotVisualizationDataSpecType"; + internal const string SingleRowVisualizationSettingsType = "SingleRowVisualizationSettingsType"; + internal const string SingleValueLabelsVisualizationDataSpecType = "SingleValueLabelsVisualizationDataSpecType"; + internal const string SparklineVisualizationDataSpecType = "SparklineVisualizationDataSpecType"; + internal const string TimeSeriesVisualizationDataSpecType = "TimeSeriesVisualizationDataSpecType"; + + internal const string DateFormattingSpecType = "DateFormattingSpecType"; + internal const string DimensionColumnSpecType = "DimensionColumnSpecType"; + internal const string MeasureColumnSpecType = "MeasureColumnSpecType"; + internal const string TabularDataSpecType = "TabularDataSpecType"; + internal const string NumberFormattingSpecType = "NumberFormattingSpecType"; + internal const string ResourceDataSpecType = "ResourceDataSpecType"; + internal const string TextBoxDataSpecType = "TextBoxDataSpecType"; + internal const string XmlaDataSpecType = "XmlaDataSpecType"; + + //******************* XMLA ***************** + internal const string XmlaDimensionType = "XmlaDimensionType"; + internal const string XmlaHierarchyLevelType = "XmlaHierarchyLevelType"; + internal const string XmlaHierarchyType = "XmlaHierarchyType"; + internal const string XmlaSetType = "XmlaSetType"; + + //******************* not sure how these should be classified yet ***************** + internal const string FieldBindingSourceType = "FieldBindingSourceType"; + internal const string ParameterBindingSourceType = "ParameterBindingSourceType"; + internal const string DateGlobalFilterBindingTargetType = "DateGlobalFilterBindingTargetType"; + internal const string DateTimeFieldSettingsType = "DateTimeFieldSettingsType"; + internal const string SummarizationDateFieldType = "SummarizationDateFieldType"; + internal const string SummarizationRegularFieldType = "SummarizationRegularFieldType"; + internal const string SummarizationValueFieldType = "SummarizationValueFieldType"; + internal const string CompositeDataSourceItemType = "CompositeDataSourceItemType"; + internal const string DataBasedGlobalFilterBindingTargetType = "DataBasedGlobalFilterBindingTargetType"; + internal const string GlobalVariableBindingTargetType = "GlobalVariableBindingTargetType"; + internal const string GaugeBandType = "GaugeBandType"; + internal const string ConditionalFormattingBandType = "ConditionalFormattingBandType"; + internal const string TabularColumnSpecType = "TabularColumnSpecType"; + } +} diff --git a/src/Reveal.Sdk.Dom/Core/Serialization/Converters/DataSpecConverter.cs b/src/Reveal.Sdk.Dom/Core/Serialization/Converters/DataSpecConverter.cs index 9753f3b7..8761e2a3 100644 --- a/src/Reveal.Sdk.Dom/Core/Serialization/Converters/DataSpecConverter.cs +++ b/src/Reveal.Sdk.Dom/Core/Serialization/Converters/DataSpecConverter.cs @@ -1,18 +1,19 @@ -using Reveal.Sdk.Dom.Core.Constants; -using Reveal.Sdk.Dom.Visualizations; -using System; - -namespace Reveal.Sdk.Dom.Core.Serialization.Converters -{ - internal class DataSpecConverter : TypeMapConverter - { - public DataSpecConverter() - { - TypeMap = new System.Collections.Generic.Dictionary() - { - { SchemaTypeNames.TabularDataSpecType, typeof(TabularDataDefinition)}, - { SchemaTypeNames.TextBoxDataSpecType, typeof(TextBoxDataDefinition)}, - }; - } - } -} +using Reveal.Sdk.Dom.Core.Constants; +using Reveal.Sdk.Dom.Visualizations; +using System; + +namespace Reveal.Sdk.Dom.Core.Serialization.Converters +{ + internal class DataSpecConverter : TypeMapConverter + { + public DataSpecConverter() + { + TypeMap = new System.Collections.Generic.Dictionary() + { + { SchemaTypeNames.TabularDataSpecType, typeof(TabularDataDefinition)}, + { SchemaTypeNames.TextBoxDataSpecType, typeof(TextBoxDataDefinition)}, + { SchemaTypeNames.XmlaDataSpecType, typeof(XmlaDataDefinition)}, + }; + } + } +} diff --git a/src/Reveal.Sdk.Dom/Core/Serialization/Converters/FilterConverter.cs b/src/Reveal.Sdk.Dom/Core/Serialization/Converters/FilterConverter.cs index 9f2bdc8f..e5c0885d 100644 --- a/src/Reveal.Sdk.Dom/Core/Serialization/Converters/FilterConverter.cs +++ b/src/Reveal.Sdk.Dom/Core/Serialization/Converters/FilterConverter.cs @@ -14,6 +14,8 @@ public FilterConverter() { SchemaTypeNames.StringFilterType, typeof(TextFilter) }, { SchemaTypeNames.DateTimeFilterType, typeof(DateTimeFilter) }, { SchemaTypeNames.TimeFilterType, typeof(TimeFilter) }, + { SchemaTypeNames.XmlaDateFilterType, typeof(XmlaDateFilter) }, + { SchemaTypeNames.XmlaRegularFilterType, typeof(XmlaRegularFilter) }, }; } } diff --git a/src/Reveal.Sdk.Dom/Core/Serialization/Converters/TypeMapConverter.cs b/src/Reveal.Sdk.Dom/Core/Serialization/Converters/TypeMapConverter.cs index 958cac0b..c7faf9b0 100644 --- a/src/Reveal.Sdk.Dom/Core/Serialization/Converters/TypeMapConverter.cs +++ b/src/Reveal.Sdk.Dom/Core/Serialization/Converters/TypeMapConverter.cs @@ -1,39 +1,39 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Core.Serialization.Converters -{ - internal class TypeMapConverter : CustomJsonConverter - where T : class - { - protected Dictionary TypeMap { get; set; } - protected string Selector { get; private set; } - - public TypeMapConverter() : this("_type") { } - - public TypeMapConverter(string selector) - { - Selector = selector; - } - - public override T ReadJson(JsonReader reader, Type objectType, T existingValue, bool hasExistingValue, JsonSerializer serializer) - { - JObject jObject = JObject.Load(reader); - string key = jObject[Selector]?.Value() ?? string.Empty; - - if (string.IsNullOrEmpty(key)) - return (T)Activator.CreateInstance(typeof(T), true); - - if (TypeMap.TryGetValue(jObject[Selector].Value(), out Type target)) - { - T item = (T)Activator.CreateInstance(target, true); - serializer.Populate(jObject.CreateReader(), item); - return item; - } - - throw new JsonException($"Type not supported {key}"); - } - } -} +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Core.Serialization.Converters +{ + internal class TypeMapConverter : CustomJsonConverter + where T : class + { + protected Dictionary TypeMap { get; set; } + protected string Selector { get; private set; } + + public TypeMapConverter() : this("_type") { } + + public TypeMapConverter(string selector) + { + Selector = selector; + } + + public override T ReadJson(JsonReader reader, Type objectType, T existingValue, bool hasExistingValue, JsonSerializer serializer) + { + JObject jObject = JObject.Load(reader); + string key = jObject[Selector]?.Value() ?? string.Empty; + + if (string.IsNullOrEmpty(key)) + return (T)Activator.CreateInstance(typeof(T), true); + + if (TypeMap.TryGetValue(jObject[Selector].Value(), out Type target)) + { + T item = (T)Activator.CreateInstance(target, true); + serializer.Populate(jObject.CreateReader(), item); + return item; + } + + throw new JsonException($"{GetType().Name}: Type not supported {key}"); + } + } +} diff --git a/src/Reveal.Sdk.Dom/Core/Serialization/Converters/XmlaDimensionElementConverter.cs b/src/Reveal.Sdk.Dom/Core/Serialization/Converters/XmlaDimensionElementConverter.cs new file mode 100644 index 00000000..225024fd --- /dev/null +++ b/src/Reveal.Sdk.Dom/Core/Serialization/Converters/XmlaDimensionElementConverter.cs @@ -0,0 +1,20 @@ +using Reveal.Sdk.Dom.Visualizations; +using System; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Core.Serialization.Converters +{ + internal class XmlaDimensionElementConverter : TypeMapConverter + { + public XmlaDimensionElementConverter() + { + TypeMap = new Dictionary() + { + { "XmlaDimensionType", typeof(XmlaDimension) }, + { "XmlaHierarchyLevelType", typeof(XmlaHierarchyLevel) }, + { "XmlaHierarchyType", typeof(XmlaHierarchy) }, + { "XmlaSetType", typeof(XmlaSet) }, + }; + } + } +} diff --git a/src/Reveal.Sdk.Dom/Core/Utilities/RdashDocumentValidator.cs b/src/Reveal.Sdk.Dom/Core/Utilities/RdashDocumentValidator.cs index 485a30ef..4aa20dea 100644 --- a/src/Reveal.Sdk.Dom/Core/Utilities/RdashDocumentValidator.cs +++ b/src/Reveal.Sdk.Dom/Core/Utilities/RdashDocumentValidator.cs @@ -1,64 +1,65 @@ -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Visualizations; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Reveal.Sdk.Dom.Core.Utilities -{ - internal static class RdashDocumentValidator - { - internal static void FixDocument(RdashDocument document) - { - FixDataSources(document); - } - - static void FixDataSources(RdashDocument document) - { - Dictionary dataSources = new Dictionary(); - foreach (var visualization in document.Visualizations) - { - if (visualization is ITabularVisualization tv) - { - var fields = tv.DataDefinition?.Fields; - if (fields == null) - throw new Exception($"DataDefinition.Fields for visualization {visualization.Title} is null."); - - var dsi = tv.DataDefinition?.DataSourceItem; - if (dsi == null) - throw new Exception($"DataDefinition.DataSourceItem for visualization {visualization.Title} is null."); - - if (dsi.DataSource != null) - { - if (!dataSources.ContainsKey(dsi.DataSource.Id)) - dataSources.Add(dsi.DataSource.Id, dsi.DataSource); - - if (dsi.ResourceItemDataSource != null && !dataSources.ContainsKey(dsi.ResourceItemDataSource.Id)) - dataSources.Add(dsi.ResourceItemDataSource.Id, dsi.ResourceItemDataSource); - } - else - { - ValidateManuallyAddedDataSourceItem(document, dsi); - } - } - } - - var allDataSources = document.DataSources?.Union(dataSources.Values.ToArray()); - document.DataSources = allDataSources?.ToList(); - } - - static void ValidateManuallyAddedDataSourceItem(RdashDocument document, DataSourceItem dsi) - { - var ds = document.DataSources?.FirstOrDefault(x => x.Id == dsi.DataSourceId); - if (ds == null) - throw new Exception($"Data source with id {dsi.DataSourceId} not found in the RdashDocument.DataSources collection."); - - if (dsi.ResourceItem != null) - { - var rds = document.DataSources?.FirstOrDefault(x => x.Id == dsi.ResourceItem.DataSourceId); - if (rds == null) - throw new Exception($"ResourceItem with Data source id {dsi.ResourceItem.DataSourceId} not found in the RdashDocument.DataSources collection."); - } - } - } -} +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Reveal.Sdk.Dom.Core.Utilities +{ + internal static class RdashDocumentValidator + { + internal static void FixDocument(RdashDocument document) + { + FixDataSources(document); + } + + static void FixDataSources(RdashDocument document) + { + Dictionary dataSources = new Dictionary(); + foreach (var visualization in document.Visualizations) + { + if (visualization.DataDefinition is TabularDataDefinition tdd) + { + var fields = tdd.Fields; + if (fields == null) + throw new Exception($"DataDefinition.Fields for visualization {visualization.Title} is null."); + + var dsi = tdd.DataSourceItem; + if (dsi == null) + throw new Exception($"DataDefinition.DataSourceItem for visualization {visualization.Title} is null."); + + if (dsi.DataSource != null) + { + if (!dataSources.ContainsKey(dsi.DataSource.Id)) + dataSources.Add(dsi.DataSource.Id, dsi.DataSource); + + if (dsi.ResourceItemDataSource != null && !dataSources.ContainsKey(dsi.ResourceItemDataSource.Id)) + dataSources.Add(dsi.ResourceItemDataSource.Id, dsi.ResourceItemDataSource); + } + else + { + ValidateManuallyAddedDataSourceItem(document, dsi); + } + } + //todo: handle XmlaDataDefinition + } + + var allDataSources = document.DataSources?.Union(dataSources.Values.ToArray()); + document.DataSources = allDataSources?.ToList(); + } + + static void ValidateManuallyAddedDataSourceItem(RdashDocument document, DataSourceItem dsi) + { + var ds = document.DataSources?.FirstOrDefault(x => x.Id == dsi.DataSourceId); + if (ds == null) + throw new Exception($"Data source with id {dsi.DataSourceId} not found in the RdashDocument.DataSources collection."); + + if (dsi.ResourceItem != null) + { + var rds = document.DataSources?.FirstOrDefault(x => x.Id == dsi.ResourceItem.DataSourceId); + if (rds == null) + throw new Exception($"ResourceItem with Data source id {dsi.ResourceItem.DataSourceId} not found in the RdashDocument.DataSources collection."); + } + } + } +} diff --git a/src/Reveal.Sdk.Dom/Data/DataSourceItem.cs b/src/Reveal.Sdk.Dom/Data/DataSourceItem.cs index ef3fad17..6acc3b65 100644 --- a/src/Reveal.Sdk.Dom/Data/DataSourceItem.cs +++ b/src/Reveal.Sdk.Dom/Data/DataSourceItem.cs @@ -1,44 +1,44 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Core; -using Reveal.Sdk.Dom.Core.Constants; -using Reveal.Sdk.Dom.Visualizations; -using System; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Data -{ - public sealed class DataSourceItem : SchemaType - { - public string Id { get; set; } = Guid.NewGuid().ToString(); - public string Title { get; set; } - public string Subtitle { get; set; } - public string DataSourceId { get; set; } - public bool HasTabularData { get; set; } - public bool HasAsset { get; set; } - public Dictionary Properties { get; set; } = new Dictionary(); - public Dictionary Parameters { get; set; } = new Dictionary(); - public DataSourceItem ResourceItem { get; set; } - - [JsonIgnore] - internal List Fields { get; set; } = new List(); - - /// - /// The data source for the current DataSourceItem. This is set internally by a data source builder and is only used during the RdashDocumentValidator process. - /// If this is null, then the DataSourceItem was manually added to the document and the DataSourceId property should be used to find the data source. - /// - [JsonIgnore] - internal DataSource DataSource { get; set; } - - /// - /// The data source for the ResourceItem. This is set internally by a data source builder and is only used during the RdashDocumentValidator process. - /// If this is null, then the ResourceItem was manually added to the document and the ResourceItem.DataSourceId property should be used to find the data source. - /// - [JsonIgnore] - internal DataSource ResourceItemDataSource { get; set; } - - public DataSourceItem() - { - SchemaTypeName = SchemaTypeNames.DataSourceItemType; - } - } -} +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Core; +using Reveal.Sdk.Dom.Core.Constants; +using Reveal.Sdk.Dom.Visualizations; +using System; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Data +{ + public sealed class DataSourceItem : SchemaType + { + public string Id { get; set; } = Guid.NewGuid().ToString(); + public string Title { get; set; } + public string Subtitle { get; set; } + public string DataSourceId { get; set; } + public bool HasTabularData { get; set; } = true; + public bool HasAsset { get; set; } + public Dictionary Properties { get; set; } = new Dictionary(); + public Dictionary Parameters { get; set; } = new Dictionary(); + public DataSourceItem ResourceItem { get; set; } + + [JsonIgnore] + internal List Fields { get; set; } = new List(); + + /// + /// The data source for the current DataSourceItem. This is set internally by a data source builder and is only used during the RdashDocumentValidator process. + /// If this is null, then the DataSourceItem was manually added to the document and the DataSourceId property should be used to find the data source. + /// + [JsonIgnore] + internal DataSource DataSource { get; set; } + + /// + /// The data source for the ResourceItem. This is set internally by a data source builder and is only used during the RdashDocumentValidator process. + /// If this is null, then the ResourceItem was manually added to the document and the ResourceItem.DataSourceId property should be used to find the data source. + /// + [JsonIgnore] + internal DataSource ResourceItemDataSource { get; set; } + + public DataSourceItem() + { + SchemaTypeName = SchemaTypeNames.DataSourceItemType; + } + } +} diff --git a/src/Reveal.Sdk.Dom/Filters/Enums/XmlaElementType.cs b/src/Reveal.Sdk.Dom/Filters/Enums/XmlaElementType.cs index f11eeeb0..8239cab9 100644 --- a/src/Reveal.Sdk.Dom/Filters/Enums/XmlaElementType.cs +++ b/src/Reveal.Sdk.Dom/Filters/Enums/XmlaElementType.cs @@ -1,11 +1,11 @@ -namespace Reveal.Sdk.Dom.Filters -{ - internal enum XmlaElementType - { - Dimension, - Level, - Hierarchy, - Member, - Set - } -} +namespace Reveal.Sdk.Dom.Filters +{ + public enum XmlaElementType + { + Dimension, + Level, + Hierarchy, + Member, + Set + } +} diff --git a/src/Reveal.Sdk.Dom/Filters/XmlaDateFilter.cs b/src/Reveal.Sdk.Dom/Filters/XmlaDateFilter.cs index d63aa3c8..a9f87840 100644 --- a/src/Reveal.Sdk.Dom/Filters/XmlaDateFilter.cs +++ b/src/Reveal.Sdk.Dom/Filters/XmlaDateFilter.cs @@ -1,19 +1,19 @@ -using Reveal.Sdk.Dom.Core.Constants; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace Reveal.Sdk.Dom.Filters -{ - internal sealed class XmlaDateFilter : FilterBase - { - [JsonConverter(typeof(StringEnumConverter))] - public DateRuleType RuleType { get; set; } = DateRuleType.AllTime; - public DateRange CustomDateRange { get; set; } - public bool IncludeToday { get; set; } = true; - - public XmlaDateFilter() - { - SchemaTypeName = SchemaTypeNames.XmlaDateFilterType; - } - } -} +using Reveal.Sdk.Dom.Core.Constants; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Reveal.Sdk.Dom.Filters +{ + public sealed class XmlaDateFilter : FilterBase + { + [JsonConverter(typeof(StringEnumConverter))] + public DateRuleType RuleType { get; set; } = DateRuleType.AllTime; + public DateRange CustomDateRange { get; set; } + public bool IncludeToday { get; set; } = true; + + public XmlaDateFilter() + { + SchemaTypeName = SchemaTypeNames.XmlaDateFilterType; + } + } +} diff --git a/src/Reveal.Sdk.Dom/Filters/XmlaFilter.cs b/src/Reveal.Sdk.Dom/Filters/XmlaFilter.cs index a091fc62..f3e25cf1 100644 --- a/src/Reveal.Sdk.Dom/Filters/XmlaFilter.cs +++ b/src/Reveal.Sdk.Dom/Filters/XmlaFilter.cs @@ -1,22 +1,22 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace Reveal.Sdk.Dom.Filters -{ - internal sealed class XmlaFilter - { - public IFilter Filter { get; set; } - public string UniqueName { get; set; } - [JsonConverter(typeof(StringEnumConverter))] - public DataType DataType { get; set; } - [JsonConverter(typeof(StringEnumConverter))] - public XmlaElementType ElementType { get; set; } - public bool IsDynamic { get; set; } - - public XmlaFilter() - { - DataType = DataType.String; - ElementType = XmlaElementType.Dimension; - } - } -} +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Reveal.Sdk.Dom.Filters +{ + public sealed class XmlaFilter + { + public IFilter Filter { get; set; } + public string UniqueName { get; set; } + [JsonConverter(typeof(StringEnumConverter))] + public DataType DataType { get; set; } + [JsonConverter(typeof(StringEnumConverter))] + public XmlaElementType ElementType { get; set; } + public bool IsDynamic { get; set; } + + public XmlaFilter() + { + DataType = DataType.String; + ElementType = XmlaElementType.Dimension; + } + } +} diff --git a/src/Reveal.Sdk.Dom/Filters/XmlaFilterRule.cs b/src/Reveal.Sdk.Dom/Filters/XmlaFilterRule.cs index 1f5daa24..51058b7e 100644 --- a/src/Reveal.Sdk.Dom/Filters/XmlaFilterRule.cs +++ b/src/Reveal.Sdk.Dom/Filters/XmlaFilterRule.cs @@ -1,9 +1,10 @@ -using Reveal.Sdk.Dom.Core; - -namespace Reveal.Sdk.Dom.Filters -{ - internal abstract class XmlaFilterRule : SchemaType - { - - } -} +using Reveal.Sdk.Dom.Core; + +namespace Reveal.Sdk.Dom.Filters +{ + //todo: need converter XmlaNumberFilterRuleType XmlaStringFilterRuleType + public abstract class XmlaFilterRule : SchemaType + { + + } +} diff --git a/src/Reveal.Sdk.Dom/Filters/XmlaRegularFilter.cs b/src/Reveal.Sdk.Dom/Filters/XmlaRegularFilter.cs index 677d55b5..f1beff06 100644 --- a/src/Reveal.Sdk.Dom/Filters/XmlaRegularFilter.cs +++ b/src/Reveal.Sdk.Dom/Filters/XmlaRegularFilter.cs @@ -1,14 +1,14 @@ -using Reveal.Sdk.Dom.Core.Constants; - -namespace Reveal.Sdk.Dom.Filters -{ - internal sealed class XmlaRegularFilter : FilterBase - { - public XmlaFilterRule FilterRule { get; set; } - - public XmlaRegularFilter() - { - SchemaTypeName = SchemaTypeNames.XmlaRegularFilterType; - } - } -} +using Reveal.Sdk.Dom.Core.Constants; + +namespace Reveal.Sdk.Dom.Filters +{ + public sealed class XmlaRegularFilter : FilterBase + { + public XmlaFilterRule FilterRule { get; set; } + + public XmlaRegularFilter() + { + SchemaTypeName = SchemaTypeNames.XmlaRegularFilterType; + } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/BubbleVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/BubbleVisualization.cs index 7ade3917..87e36861 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/BubbleVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/BubbleVisualization.cs @@ -1,44 +1,44 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Visualizations.Settings; -using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Visualizations -{ +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations.Settings; +using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Visualizations +{ /// /// The bubble chart visualization is a type of scatter chart that show markers with variable scaling to represent the relationship among items in several distinct series of data or to plot data items using x and y coordinates. These coordinates of the data point are determined by two numeric data columns. The bubble chart draws attention to uneven intervals or clusters of data. This chart is often used to plot scientific data, and can highlight the deviation of collected data from predicted results. - /// - public sealed class BubbleVisualization : TabularVisualizationBase, ILabels, IAxis - { - internal BubbleVisualization() : this(null) { } - + /// + public sealed class BubbleVisualization : Visualization, ILabels, IAxis + { + internal BubbleVisualization() : this(null) { } + /// /// Creates a bubble chart visualization from the supplied . /// - /// The data soure item used to represent a dataset. - public BubbleVisualization(DataSourceItem dataSourceItem) : this(null, dataSourceItem) { } - + /// The data soure item used to represent a dataset. + public BubbleVisualization(DataSourceItem dataSourceItem) : this(null, dataSourceItem) { } + /// /// Creates a bubble chart visualization from the supplied and sets the title to the provided string. /// /// The string to use as the visualization's title. - /// The data soure item used to represent a dataset. - public BubbleVisualization(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { ChartType = ChartType.Bubble; } - - [JsonProperty(Order = 7)] - BubbleVisualizationDataSpec VisualizationDataSpec { get; set; } = new BubbleVisualizationDataSpec(); - - [JsonIgnore] - public List Labels { get { return VisualizationDataSpec.Rows; } } - - [JsonIgnore] - public List XAxes { get { return VisualizationDataSpec.XAxis; } } - - [JsonIgnore] - public List YAxes { get { return VisualizationDataSpec.YAxis; } } - - [JsonIgnore] - public List Radius { get { return VisualizationDataSpec.Radius; }} - } -} + /// The data soure item used to represent a dataset. + public BubbleVisualization(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { ChartType = ChartType.Bubble; } + + [JsonProperty(Order = 7)] + BubbleVisualizationDataSpec VisualizationDataSpec { get; set; } = new BubbleVisualizationDataSpec(); + + [JsonIgnore] + public List Labels { get { return VisualizationDataSpec.Rows; } } + + [JsonIgnore] + public List XAxes { get { return VisualizationDataSpec.XAxis; } } + + [JsonIgnore] + public List YAxes { get { return VisualizationDataSpec.YAxis; } } + + [JsonIgnore] + public List Radius { get { return VisualizationDataSpec.Radius; }} + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/CategoryVisualizationBase.cs b/src/Reveal.Sdk.Dom/Visualizations/CategoryVisualizationBase.cs index 95dac7d4..9f6bbd3d 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/CategoryVisualizationBase.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/CategoryVisualizationBase.cs @@ -1,31 +1,31 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Visualizations.Settings; -using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public abstract class CategoryVisualizationBase : TabularVisualizationBase, ILabels, IValues, ICategory - where TSettings : ChartVisualizationSettingsBase, new() - { - protected CategoryVisualizationBase(DataSourceItem dataSourceItem) : this(null, dataSourceItem) { } - protected CategoryVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } - - [JsonIgnore] - public List Labels { get { return VisualizationDataSpec.Rows; } } - - [JsonIgnore] - public List Values { get { return VisualizationDataSpec.Values; } } - - [JsonIgnore] - public DimensionColumn Category - { - get { return VisualizationDataSpec.Category; } - set { VisualizationDataSpec.Category = value; } - } - - [JsonProperty(Order = 7)] - CategoryVisualizationDataSpec VisualizationDataSpec { get; set; } = new CategoryVisualizationDataSpec(); - } +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations.Settings; +using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public abstract class CategoryVisualizationBase : Visualization, ILabels, IValues, ICategory + where TSettings : ChartVisualizationSettingsBase, new() + { + protected CategoryVisualizationBase(DataSourceItem dataSourceItem) : this(null, dataSourceItem) { } + protected CategoryVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } + + [JsonIgnore] + public List Labels { get { return VisualizationDataSpec.Rows; } } + + [JsonIgnore] + public List Values { get { return VisualizationDataSpec.Values; } } + + [JsonIgnore] + public DimensionColumn Category + { + get { return VisualizationDataSpec.Category; } + set { VisualizationDataSpec.Category = value; } + } + + [JsonProperty(Order = 7)] + CategoryVisualizationDataSpec VisualizationDataSpec { get; set; } = new CategoryVisualizationDataSpec(); + } } \ No newline at end of file diff --git a/src/Reveal.Sdk.Dom/Visualizations/ChoroplethVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/ChoroplethVisualization.cs index b0edf719..65f5a1ac 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/ChoroplethVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/ChoroplethVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The choropleth visualization is used to display geo-spatial data using shape polygons in a geographic context. This type of visualization is often used to render shapes of countries or regions defined by geographic locations. /// - public sealed class ChoroplethVisualization : TabularVisualizationBase, IValues, IMap + public sealed class ChoroplethVisualization : Visualization, IValues, IMap { internal ChoroplethVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/ComboChartVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/ComboChartVisualization.cs index c0ab1e24..776739fe 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/ComboChartVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/ComboChartVisualization.cs @@ -9,7 +9,8 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The combo chart visualization is used to combine two different category charts into one visualization. This visualization type only supports adding these chart types; column, stacked column, area, line, step area, step line, and spline area. /// - public sealed class ComboChartVisualization : TabularVisualizationBase, ILabels + //public sealed class ComboChartVisualization : TabularVisualizationBase, ILabels + public sealed class ComboChartVisualization : Visualization, ILabels { internal ComboChartVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/CustomVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/CustomVisualization.cs index 8cf70d60..3d8ecb56 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/CustomVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/CustomVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The custom visualizion is used to support visualizations not supported out of the box. /// - public sealed class CustomVisualization : TabularVisualizationBase, IRows, IValues, IColumns + public sealed class CustomVisualization : Visualization, IRows, IValues, IColumns { internal CustomVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/DataDefinitionBase.cs b/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/DataDefinitionBase.cs index 8af038cd..06ed30c0 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/DataDefinitionBase.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/DataDefinitionBase.cs @@ -1,24 +1,22 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Core; -using Reveal.Sdk.Dom.Data; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public abstract class DataDefinitionBase : SchemaType - { - [JsonProperty] - public DataSourceItem DataSourceItem { get; internal set; } - - /// - /// Gets or sets the expiration time in minutes for the data cache. - /// - [JsonProperty("Expiration")] - public int CacheExpiration { get; set; } = 1440; - - /// - /// This is exposed via the Visualization.FilterBindings property - /// - [JsonProperty] - internal DataSpecBindings Bindings { get; set; } = new DataSpecBindings(); - } -} +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Core; +using Reveal.Sdk.Dom.Data; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public abstract class DataDefinitionBase : SchemaType, IDataDefinition + { + [JsonProperty] + public DataSourceItem DataSourceItem { get; internal set; } + + /// + [JsonProperty("Expiration")] + public int CacheExpiration { get; set; } = 1440; + + /// + /// This is exposed via the Visualization.FilterBindings property + /// + [JsonProperty] + internal DataSpecBindings Bindings { get; set; } = new DataSpecBindings(); + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/TabularDataDefinition.cs b/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/TabularDataDefinition.cs index 7c6a0b0f..a1a6575a 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/TabularDataDefinition.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/TabularDataDefinition.cs @@ -1,44 +1,42 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Core.Constants; -using Reveal.Sdk.Dom.Filters; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public sealed class TabularDataDefinition : DataDefinitionBase - { - public TabularDataDefinition() - { - SchemaTypeName = SchemaTypeNames.TabularDataSpecType; - } - - //not sure what this is for yet - [JsonProperty] - internal bool IsTransposed { get; set; } - - [JsonProperty] - public List Fields { get; internal set; } = new List(); - - //not sure what this is for yet - [JsonProperty] - internal List TransposedFields { get; set; } = new List(); - - /// - /// This is exposed via the Visualization.Filters property - /// - [JsonProperty] - internal List QuickFilters { get; set; } = new List(); - - //not sure what this is for yet - [JsonProperty] - internal SummarizationSpec SummarizationSpec { get; set; } - - //used when joining tables from multiple data sources - [JsonProperty] - internal List AdditionalTables { get; set; } = new List(); - - //not sure what this is for yet - [JsonProperty] - internal List ServiceAdditionalTables { get; set; } = new List(); - } -} +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Core.Constants; +using Reveal.Sdk.Dom.Filters; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public sealed class TabularDataDefinition : DataDefinitionBase + { + public TabularDataDefinition() + { + SchemaTypeName = SchemaTypeNames.TabularDataSpecType; + } + + //not sure what this is for yet + [JsonProperty] + internal bool IsTransposed { get; set; } + + [JsonProperty] + public List Fields { get; internal set; } = new List(); + + //not sure what this is for yet + [JsonProperty] + internal List TransposedFields { get; set; } = new List(); + + //this is used as visualization filters. let's find a better way to expose this + [JsonProperty] + internal List QuickFilters { get; set; } = new List(); + + //not sure what this is for yet + [JsonProperty] + internal SummarizationSpec SummarizationSpec { get; set; } + + //used when joining tables from multiple data sources + [JsonProperty] + internal List AdditionalTables { get; set; } = new List(); + + //not sure what this is for yet + [JsonProperty] + internal List ServiceAdditionalTables { get; set; } = new List(); + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/XmlaDataDefinition.cs b/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/XmlaDataDefinition.cs new file mode 100644 index 00000000..8c5347fd --- /dev/null +++ b/src/Reveal.Sdk.Dom/Visualizations/DataDefinitions/XmlaDataDefinition.cs @@ -0,0 +1,20 @@ +using Reveal.Sdk.Dom.Core.Constants; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public sealed class XmlaDataDefinition : DataDefinitionBase + { + public XmlaDataDefinition() + { + SchemaTypeName = SchemaTypeNames.XmlaDataSpecType; + } + + public bool ShowGrandTotals { get; set; } + public List Rows { get; set; } = new List(); + public List Columns { get; set; } = new List(); + public List Measures { get; set; } = new List(); + public List Filters { get; set; } = new List(); + public List DataFilters { get; set; } = new List(); + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Enums/XmlaDimensionType.cs b/src/Reveal.Sdk.Dom/Visualizations/Enums/XmlaDimensionType.cs index ca8d666a..5064bcd4 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/Enums/XmlaDimensionType.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/Enums/XmlaDimensionType.cs @@ -1,8 +1,8 @@ -namespace Reveal.Sdk.Dom.Visualizations -{ - internal enum XmlaDimensionType - { - Regular, - Date - } -} +namespace Reveal.Sdk.Dom.Visualizations +{ + public enum XmlaDimensionType + { + Regular, + Date + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Extensions/IDataDefinitionExtensions.cs b/src/Reveal.Sdk.Dom/Visualizations/Extensions/IDataDefinitionExtensions.cs new file mode 100644 index 00000000..8242c3c8 --- /dev/null +++ b/src/Reveal.Sdk.Dom/Visualizations/Extensions/IDataDefinitionExtensions.cs @@ -0,0 +1,15 @@ +namespace Reveal.Sdk.Dom.Visualizations +{ + public static class IDataDefinitionExtensions + { + public static TabularDataDefinition AsTabular(this IDataDefinition dataDefinition) + { + return dataDefinition as TabularDataDefinition; + } + + public static XmlaDataDefinition AsXmla(this IDataDefinition dataDefinition) + { + return dataDefinition as XmlaDataDefinition; + } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Extensions/ITabularVisualizationExtensions.cs b/src/Reveal.Sdk.Dom/Visualizations/Extensions/ITabularVisualizationExtensions.cs deleted file mode 100644 index a93b84a1..00000000 --- a/src/Reveal.Sdk.Dom/Visualizations/Extensions/ITabularVisualizationExtensions.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Reveal.Sdk.Dom.Filters; -using System.Linq; -using System; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public static class ITabularVisualizationExtensions - { - public static T AddDataFilter(this T visualization, string fieldName, TFilter filter) - where T : ITabularVisualization - where TFilter : IFilter - { - try - { - var field = visualization.DataDefinition.Fields.Where(x => x.FieldName == fieldName).First(); - var filterField = (FieldBase)field; - filterField.DataFilter = filter; - } - catch (InvalidOperationException ex) - { - throw new Exception($"AddDataFilter: Field {fieldName} cannot be found."); - } - catch - { - throw new Exception($"AddDataFilter: Field {fieldName} is not compatible with {filter.GetType()}."); - } - - return visualization; - } - - public static T AddFilter(this T visualization, string field) - where T : ITabularVisualization - { - visualization.Filters.Add(new VisualizationFilter(field)); - return visualization; - } - - public static T AddFilters(this T visualization, params string[] fields) - where T : ITabularVisualization - { - foreach (var filter in fields) - { - visualization.AddFilter(filter); - } - return visualization; - } - } -} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Extensions/IVisualizationExtensions.cs b/src/Reveal.Sdk.Dom/Visualizations/Extensions/IVisualizationExtensions.cs index 80df9680..ab766ec0 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/Extensions/IVisualizationExtensions.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/Extensions/IVisualizationExtensions.cs @@ -1,18 +1,63 @@ -namespace Reveal.Sdk.Dom.Visualizations -{ - public static class IVisualizationExtensions - { - public static T SetPosition(this T visualization, int rowSpan, int columnSpan) - where T : IVisualization - { - visualization.RowSpan = rowSpan; - visualization.ColumnSpan = columnSpan; - return visualization; - } - - public static ITabularVisualization AsTabularVisualization(this IVisualization visualization) - { - return visualization as ITabularVisualization; - } - } -} +using Reveal.Sdk.Dom.Filters; +using System; +using System.Linq; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public static class IVisualizationExtensions + { + public static T SetPosition(this T visualization, int rowSpan, int columnSpan) + where T : IVisualization + { + visualization.RowSpan = rowSpan; + visualization.ColumnSpan = columnSpan; + return visualization; + } + + public static T AddDataFilter(this T visualization, string fieldName, TFilter filter) + where T : IVisualization + where TFilter : IFilter + { + try + { + if (visualization.DataDefinition is TabularDataDefinition tdd) + { + var field = tdd.Fields.Where(x => x.FieldName == fieldName).First(); + var filterField = (FieldBase)field; + filterField.DataFilter = filter; + } + } + catch (InvalidOperationException ex) + { + throw new Exception($"AddDataFilter: Field {fieldName} cannot be found."); + } + catch + { + throw new Exception($"AddDataFilter: Field {fieldName} is not compatible with {filter.GetType()}."); + } + + return visualization; + } + + public static T AddFilter(this T visualization, string field) + where T : IVisualization + { + if (visualization.DataDefinition is TabularDataDefinition tdd) + { + tdd.QuickFilters.Add(new VisualizationFilter(field)); + //visualization.Filters.Add(new VisualizationFilter(field)); //todo: can we expose a Filters property on IVisualization? Can the filters property apply to both Tabular and Xmla? + } + return visualization; + } + + public static T AddFilters(this T visualization, params string[] fields) + where T : IVisualization + { + foreach (var filter in fields) + { + visualization.AddFilter(filter); + } + return visualization; + } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/FinancialVisualizationBase.cs b/src/Reveal.Sdk.Dom/Visualizations/FinancialVisualizationBase.cs index ce9fc67f..6e4d6294 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/FinancialVisualizationBase.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/FinancialVisualizationBase.cs @@ -1,32 +1,32 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Visualizations.Settings; -using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public abstract class FinancialVisualizationBase : TabularVisualizationBase, ILabels, IFinance - where TSettings : FinancialVisualizationSettingsBase, new() - { - protected FinancialVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } - - [JsonProperty(Order = 7)] - FinancialVisualizationDataSpec VisualizationDataSpec { get; set; } = new FinancialVisualizationDataSpec(); - - [JsonIgnore] - public List Labels { get { return VisualizationDataSpec.Rows; } } - - [JsonIgnore] - public List Opens { get { return VisualizationDataSpec.Open; } } - - [JsonIgnore] - public List Highs { get { return VisualizationDataSpec.High; } } - - [JsonIgnore] - public List Lows { get { return VisualizationDataSpec.Low; } } - - [JsonIgnore] - public List Closes { get { return VisualizationDataSpec.Close; } } - } -} +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations.Settings; +using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public abstract class FinancialVisualizationBase : Visualization, ILabels, IFinance + where TSettings : FinancialVisualizationSettingsBase, new() + { + protected FinancialVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } + + [JsonProperty(Order = 7)] + FinancialVisualizationDataSpec VisualizationDataSpec { get; set; } = new FinancialVisualizationDataSpec(); + + [JsonIgnore] + public List Labels { get { return VisualizationDataSpec.Rows; } } + + [JsonIgnore] + public List Opens { get { return VisualizationDataSpec.Open; } } + + [JsonIgnore] + public List Highs { get { return VisualizationDataSpec.High; } } + + [JsonIgnore] + public List Lows { get { return VisualizationDataSpec.Low; } } + + [JsonIgnore] + public List Closes { get { return VisualizationDataSpec.Close; } } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/GridVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/GridVisualization.cs index c47f661d..b1b7a1b7 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/GridVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/GridVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The grid view visualization is used for displaying data which presents the information in a table. /// - public sealed class GridVisualization : TabularVisualizationBase, ITabularColumns + public sealed class GridVisualization : Visualization, ITabularColumns { internal GridVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/ImageVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/ImageVisualization.cs index 558a14a8..944d8565 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/ImageVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/ImageVisualization.cs @@ -8,7 +8,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The image visualization is used for displaying images, PDFs, or web content. /// - public sealed class ImageVisualization : TabularVisualizationBase + public sealed class ImageVisualization : Visualization { internal ImageVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IDataDefinition.cs b/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IDataDefinition.cs new file mode 100644 index 00000000..3f09b9f1 --- /dev/null +++ b/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IDataDefinition.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Core.Serialization.Converters; +using Reveal.Sdk.Dom.Data; + +namespace Reveal.Sdk.Dom.Visualizations +{ + [JsonConverter(typeof(DataSpecConverter))] + public interface IDataDefinition + { + /// + /// Gets or sets the expiration time in minutes for the data cache. + /// + int CacheExpiration { get; set; } + + + DataSourceItem DataSourceItem { get; } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IDataDefinitionProvider.cs b/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IDataDefinitionProvider.cs deleted file mode 100644 index d27b5167..00000000 --- a/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IDataDefinitionProvider.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Reveal.Sdk.Dom.Visualizations -{ - public interface IDataDefinitionProvider - where TDataDefinition : DataDefinitionBase - { - TDataDefinition DataDefinition { get; } - } -} \ No newline at end of file diff --git a/src/Reveal.Sdk.Dom/Visualizations/Interfaces/ITabularVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/Interfaces/ITabularVisualization.cs deleted file mode 100644 index a4fcd227..00000000 --- a/src/Reveal.Sdk.Dom/Visualizations/Interfaces/ITabularVisualization.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Filters; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public interface ITabularVisualization : IVisualization, IFilterBindings, IDataDefinitionProvider - { - List Filters { get; } - - void UpdateDataSourceItem(DataSourceItem dataSourceItem); - - DataSourceItem GetDataSourceItem(); - } -} \ No newline at end of file diff --git a/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IVisualization.cs index cbf97297..c82f6df1 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/Interfaces/IVisualization.cs @@ -12,5 +12,6 @@ public interface IVisualization bool IsTitleVisible { get; set; } int ColumnSpan { get; set; } int RowSpan { get; set; } + IDataDefinition DataDefinition { get; } } } \ No newline at end of file diff --git a/src/Reveal.Sdk.Dom/Visualizations/KpiTargetVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/KpiTargetVisualization.cs index f3960046..5355783b 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/KpiTargetVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/KpiTargetVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The KPI vs target visualization is used for measuring performance against a target through a prior time period. /// - public sealed class KpiTargetVisualization : TabularVisualizationBase, ITargets, IDate, IValues, ICategories + public sealed class KpiTargetVisualization : Visualization, ITargets, IDate, IValues, ICategories { internal KpiTargetVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/KpiTimeVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/KpiTimeVisualization.cs index b515235f..8d8e9aca 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/KpiTimeVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/KpiTimeVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The KPI vs time visualization is used for measuring performance of a value field compared against a prior time period. /// - public sealed class KpiTimeVisualization : TabularVisualizationBase, IDate, IValues, ICategories + public sealed class KpiTimeVisualization : Visualization, IDate, IValues, ICategories { internal KpiTimeVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/LinearGaugeVisualizationBase.cs b/src/Reveal.Sdk.Dom/Visualizations/LinearGaugeVisualizationBase.cs index 9c7a5b0f..8671e844 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/LinearGaugeVisualizationBase.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/LinearGaugeVisualizationBase.cs @@ -1,29 +1,29 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Visualizations.Settings; -using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public abstract class LinearGaugeVisualizationBase : TabularVisualizationBase, ILabels, IValues - where TSettings : GaugeVisualizationSettings, new() - { - protected LinearGaugeVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } - - [JsonIgnore] - public List Labels - { - get { return VisualizationDataSpec.Rows; } - } - - [JsonIgnore] - public List Values - { - get { return VisualizationDataSpec.Value; } - } - - [JsonProperty(Order = 7)] - internal LinearGaugeVisualizationDataSpec VisualizationDataSpec { get; set; } = new LinearGaugeVisualizationDataSpec(); - } +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations.Settings; +using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public abstract class LinearGaugeVisualizationBase : Visualization, ILabels, IValues + where TSettings : GaugeVisualizationSettings, new() + { + protected LinearGaugeVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } + + [JsonIgnore] + public List Labels + { + get { return VisualizationDataSpec.Rows; } + } + + [JsonIgnore] + public List Values + { + get { return VisualizationDataSpec.Value; } + } + + [JsonProperty(Order = 7)] + internal LinearGaugeVisualizationDataSpec VisualizationDataSpec { get; set; } = new LinearGaugeVisualizationDataSpec(); + } } \ No newline at end of file diff --git a/src/Reveal.Sdk.Dom/Visualizations/PivotVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/PivotVisualization.cs index 60b4fab5..0cd0026c 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/PivotVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/PivotVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The pivot table visualization is used as a data summarization tool, which among other functions allows you to automatically count, average and total the data stored in a table like format, typically grouped by values. /// - public sealed class PivotVisualization : TabularVisualizationBase, IValues, IRows, IColumns + public sealed class PivotVisualization : Visualization, IValues, IRows, IColumns { internal PivotVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/Primitives/AdditionalTable.cs b/src/Reveal.Sdk.Dom/Visualizations/Primitives/AdditionalTable.cs index df546378..5bff3b65 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/Primitives/AdditionalTable.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/Primitives/AdditionalTable.cs @@ -8,9 +8,8 @@ internal sealed class AdditionalTable { public string Alias { get; set; } - [JsonProperty("DataSpec")] - [JsonConverter(typeof(DataSpecConverter))] - public DataDefinitionBase DataDefinition { get; set; } + [JsonProperty("DataSpec")] + public DataDefinitionBase DataDefinition { get; set; } //todo: convert to interface public List JoinConditions { get; set; } public AdditionalTable() diff --git a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaDimension.cs b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaDimension.cs new file mode 100644 index 00000000..3a1e2d3f --- /dev/null +++ b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaDimension.cs @@ -0,0 +1,14 @@ +using Reveal.Sdk.Dom.Core.Constants; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public class XmlaDimension : XmlaDimensionElement + { + public XmlaDimension() + { + SchemaTypeName = SchemaTypeNames.XmlaDimensionType; + } + + public string DefaultHierarchy { get; set; } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaDimensionElement.cs b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaDimensionElement.cs index 8ec54e2b..9a014fac 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaDimensionElement.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaDimensionElement.cs @@ -1,38 +1,33 @@ -using Reveal.Sdk.Dom.Filters; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace Reveal.Sdk.Dom.Visualizations -{ - internal sealed class XmlaDimensionElement - { - public string UniqueName { get; set; } - public string Caption { get; set; } - public string UserCaption { get; set; } - public string DimensionUniqueName { get; set; } - [JsonConverter(typeof(StringEnumConverter))] - public XmlaDimensionType DimensionType { get; set; } - public List DrillDownElements { get; set; } - [JsonConverter(typeof(StringEnumConverter))] - public SortingType Sorting { get; set; } - public bool FieldSortingByLabel { get; set; } - public XmlaFilter XmlaFilter { get; set; } - public int FullyExpandedLevels { get; set; } - public List ExpandedItems { get; set; } - [JsonConverter(typeof(StringEnumConverter))] - public DateAggregationType DateAggregationType { get; set; } - public int DateFiscalYearStartMonth { get; set; } - public List DrillDownMembers { get; set; } - - public XmlaDimensionElement() - { - DrillDownElements = new List(); - ExpandedItems = new List(); - DrillDownMembers = new List(); - DimensionType = XmlaDimensionType.Regular; - Sorting = SortingType.None; - DateAggregationType = DateAggregationType.Year; - } - } -} +using Reveal.Sdk.Dom.Filters; +using System.Collections.Generic; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Reveal.Sdk.Dom.Core.Serialization.Converters; +using Reveal.Sdk.Dom.Core; + +namespace Reveal.Sdk.Dom.Visualizations +{ + [JsonConverter(typeof(XmlaDimensionElementConverter))] + public abstract class XmlaDimensionElement : SchemaType + { + public XmlaDimensionElement() { } + + public string UniqueName { get; set; } + public string Caption { get; set; } + public string UserCaption { get; set; } + public string DimensionUniqueName { get; set; } + [JsonConverter(typeof(StringEnumConverter))] + public XmlaDimensionType DimensionType { get; set; } = XmlaDimensionType.Regular; + public List DrillDownElements { get; set; } = new List(); + [JsonConverter(typeof(StringEnumConverter))] + public SortingType Sorting { get; set; } = SortingType.None; + public bool FieldSortingByLabel { get; set; } + public XmlaFilter XmlaFilter { get; set; } + public int FullyExpandedLevels { get; set; } + public List ExpandedItems { get; set; } = new List(); + [JsonConverter(typeof(StringEnumConverter))] + public DateAggregationType DateAggregationType { get; set; } = DateAggregationType.Year; + public int DateFiscalYearStartMonth { get; set; } + public List DrillDownMembers { get; set; } = new List(); + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaHierarchy.cs b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaHierarchy.cs new file mode 100644 index 00000000..30fa2e23 --- /dev/null +++ b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaHierarchy.cs @@ -0,0 +1,19 @@ +using Reveal.Sdk.Dom.Core.Constants; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public class XmlaHierarchy : XmlaDimensionElement + { + public XmlaHierarchy() + { + SchemaTypeName = SchemaTypeNames.XmlaHierarchyType; + } + + public int Origin { get; set; } + public string Description { get; set; } + public int? Cardinality { get; set; } + public string DisplayFolder { get; set; } + public string AllMember { get; set; } + public string DefaultMember { get; set; } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaHierarchyLevel.cs b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaHierarchyLevel.cs new file mode 100644 index 00000000..252ab045 --- /dev/null +++ b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaHierarchyLevel.cs @@ -0,0 +1,16 @@ +using Reveal.Sdk.Dom.Core.Constants; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public sealed class XmlaHierarchyLevel : XmlaDimensionElement + { + public XmlaHierarchyLevel() + { + SchemaTypeName = SchemaTypeNames.XmlaHierarchyLevelType; + } + + public string HierarchyUniqueName { get; set; } + public int LevelNumber { get; set; } + public int Cardinality { get; set; } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaMeasure.cs b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaMeasure.cs index 8c3dfd73..3ea2fdec 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaMeasure.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaMeasure.cs @@ -1,27 +1,28 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace Reveal.Sdk.Dom.Visualizations -{ - internal sealed class XmlaMeasure - { - public bool IsHidden { get; set; } - public string UniqueName { get; set; } - public string Caption { get; set; } - public string DisplayFolder { get; set; } - public string MeasureGroupName { get; set; } - public string UserCaption { get; set; } - public bool IsCalculated { get; set; } - public string Expression { get; set; } - public FormattingBase Formatting { get; set; } - public ConditionalFormatting ConditionalFormatting { get; set; } - public string Description { get; set; } - [JsonConverter(typeof(StringEnumConverter))] - public SortingType Sorting { get; set; } - - public XmlaMeasure() - { - Sorting = SortingType.None; - } - } +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public sealed class XmlaMeasure + { + public XmlaMeasure() + { + Sorting = SortingType.None; + } + + public bool IsHidden { get; set; } + public string UniqueName { get; set; } + public string Caption { get; set; } + public string DisplayFolder { get; set; } + public string MeasureGroupName { get; set; } + public string UserCaption { get; set; } + public bool IsCalculated { get; set; } + public string Expression { get; set; } + public NumberFormatting Formatting { get; set; } + public ConditionalFormatting ConditionalFormatting { get; set; } + public string Description { get; set; } + + [JsonConverter(typeof(StringEnumConverter))] + public SortingType Sorting { get; set; } + } } \ No newline at end of file diff --git a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaMember.cs b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaMember.cs index 9876c1ea..221a3bc0 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaMember.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaMember.cs @@ -1,8 +1,8 @@ -namespace Reveal.Sdk.Dom.Visualizations -{ - internal sealed class XmlaMember - { - public string UniqueName { get; set; } - public string Caption { get; set; } - } -} +namespace Reveal.Sdk.Dom.Visualizations +{ + public sealed class XmlaMember + { + public string UniqueName { get; set; } + public string Caption { get; set; } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaSet.cs b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaSet.cs new file mode 100644 index 00000000..9be0a764 --- /dev/null +++ b/src/Reveal.Sdk.Dom/Visualizations/Primitives/XmlaSet.cs @@ -0,0 +1,15 @@ +using Reveal.Sdk.Dom.Core.Constants; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public class XmlaSet : XmlaDimensionElement + { + public XmlaSet() + { + SchemaTypeName = SchemaTypeNames.XmlaSetType; + } + + public string HierarchyUniqueName { get; set; } + public string DisplayFolder { get; set; } + } +} diff --git a/src/Reveal.Sdk.Dom/Visualizations/ScatterMapVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/ScatterMapVisualization.cs index b6a8bb91..42471965 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/ScatterMapVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/ScatterMapVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The scatter map visualization is used to display geo-spatial data using points or markers in a geographic context. This type of visualization is often used to render a collection of geographic locations such as cities, airports, earthquakes, or points of interests. /// - public sealed class ScatterMapVisualization : TabularVisualizationBase, ILabel, IMap + public sealed class ScatterMapVisualization : Visualization, ILabel, IMap { internal ScatterMapVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/ScatterVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/ScatterVisualization.cs index af9ef2c3..5510fa12 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/ScatterVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/ScatterVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The scatter visualization is used to show the relationship among items in distinct series of data or to plot data items using numeric x and y coordinates. These charts draw attention to uneven intervals or clusters of data. /// - public sealed class ScatterVisualization : TabularVisualizationBase, ILabels, IAxis + public sealed class ScatterVisualization : Visualization, ILabels, IAxis { internal ScatterVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/SingleGaugeVisualizationBase.cs b/src/Reveal.Sdk.Dom/Visualizations/SingleGaugeVisualizationBase.cs index 97ecedf3..bf61b32d 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/SingleGaugeVisualizationBase.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/SingleGaugeVisualizationBase.cs @@ -1,27 +1,27 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Visualizations.Settings; -using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public abstract class SingleGaugeVisualizationBase : TabularVisualizationBase, ILabel, IValues - where TSettings : VisualizationSettings, new() - { - protected SingleGaugeVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } - - [JsonIgnore] - public DimensionColumn Label - { - get { return VisualizationDataSpec.Label; } - set { VisualizationDataSpec.Label = value; } - } - - [JsonIgnore] - public List Values { get { return VisualizationDataSpec.Value; } } - - [JsonProperty(Order = 7)] - SingleGaugeVisualizationDataSpec VisualizationDataSpec { get; set; } = new SingleGaugeVisualizationDataSpec(); - } +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations.Settings; +using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public abstract class SingleGaugeVisualizationBase : Visualization, ILabel, IValues + where TSettings : VisualizationSettings, new() + { + protected SingleGaugeVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } + + [JsonIgnore] + public DimensionColumn Label + { + get { return VisualizationDataSpec.Label; } + set { VisualizationDataSpec.Label = value; } + } + + [JsonIgnore] + public List Values { get { return VisualizationDataSpec.Value; } } + + [JsonProperty(Order = 7)] + SingleGaugeVisualizationDataSpec VisualizationDataSpec { get; set; } = new SingleGaugeVisualizationDataSpec(); + } } \ No newline at end of file diff --git a/src/Reveal.Sdk.Dom/Visualizations/SingleValueLabelsVisualizationBase.cs b/src/Reveal.Sdk.Dom/Visualizations/SingleValueLabelsVisualizationBase.cs index 0bd7bca3..bfeb42fb 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/SingleValueLabelsVisualizationBase.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/SingleValueLabelsVisualizationBase.cs @@ -1,23 +1,23 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Visualizations.Settings; -using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; -using System.Collections.Generic; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public abstract class SingleValueLabelsVisualizationBase : TabularVisualizationBase, ILabels, IValues - where TSettings : VisualizationSettings, new() - { - protected SingleValueLabelsVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } - - [JsonIgnore] - public List Labels { get { return VisualizationDataSpec.Rows; } } - - [JsonIgnore] - public List Values { get { return VisualizationDataSpec.Value; } } - - [JsonProperty(Order = 7)] - SingleValueLabelsVisualizationDataSpec VisualizationDataSpec { get; set; } = new SingleValueLabelsVisualizationDataSpec(); - } +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations.Settings; +using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; +using System.Collections.Generic; + +namespace Reveal.Sdk.Dom.Visualizations +{ + public abstract class SingleValueLabelsVisualizationBase : Visualization, ILabels, IValues + where TSettings : VisualizationSettings, new() + { + protected SingleValueLabelsVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title, dataSourceItem) { } + + [JsonIgnore] + public List Labels { get { return VisualizationDataSpec.Rows; } } + + [JsonIgnore] + public List Values { get { return VisualizationDataSpec.Value; } } + + [JsonProperty(Order = 7)] + SingleValueLabelsVisualizationDataSpec VisualizationDataSpec { get; set; } = new SingleValueLabelsVisualizationDataSpec(); + } } \ No newline at end of file diff --git a/src/Reveal.Sdk.Dom/Visualizations/SparklineVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/SparklineVisualization.cs index eab02264..425801b1 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/SparklineVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/SparklineVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The sparkline visualization is used to show data in table form along with a small-scale chart that uses a line or area series to show trends in a collection of values. /// - public sealed class SparklineVisualization : TabularVisualizationBase, IDate, IValues, ICategories + public sealed class SparklineVisualization : Visualization, IDate, IValues, ICategories { internal SparklineVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/TabularVisualizationBase.cs b/src/Reveal.Sdk.Dom/Visualizations/TabularVisualizationBase.cs index cc00ee63..e3ed3792 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/TabularVisualizationBase.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/TabularVisualizationBase.cs @@ -1,54 +1,54 @@ -using Newtonsoft.Json; -using Reveal.Sdk.Dom.Core; -using Reveal.Sdk.Dom.Core.Utilities; -using Reveal.Sdk.Dom.Data; -using Reveal.Sdk.Dom.Filters; -using Reveal.Sdk.Dom.Visualizations.Settings; -using System.Collections.Generic; -using System.Linq; - -namespace Reveal.Sdk.Dom.Visualizations -{ - public abstract class TabularVisualizationBase : Visualization, ITabularVisualization - where TSettings : VisualizationSettings, new() - { - protected TabularVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title) - { - DataDefinition = new TabularDataDefinition(); - UpdateDataSourceItem(dataSourceItem); - } - - [JsonIgnore] - public List Filters - { - get { return DataDefinition.QuickFilters; } - } - - /// - /// Gets the data source item for the visualization. - /// - /// The - public DataSourceItem GetDataSourceItem() - { - var dataSourceItem = DataDefinition.DataSourceItem; - dataSourceItem.Fields = DataDefinition.Fields.Clone(); - - IParentDocument viz = this; - dataSourceItem.DataSource = viz.Document.DataSources.Where(x => x.Id == dataSourceItem.DataSourceId).First(); - if (dataSourceItem.ResourceItem != null) - dataSourceItem.ResourceItemDataSource = viz.Document.DataSources.Where(x => x.Id == dataSourceItem.ResourceItem.DataSourceId).First(); - - return dataSourceItem; - } - - /// - /// Updates the data source item and available fields for the visualization. - /// - /// The created with a data source builder. - public void UpdateDataSourceItem(DataSourceItem dataSourceItem) - { - DataDefinition.DataSourceItem = dataSourceItem; - DataDefinition.Fields = dataSourceItem?.Fields.Clone(); - } - } +using Newtonsoft.Json; +using Reveal.Sdk.Dom.Core; +using Reveal.Sdk.Dom.Core.Utilities; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Filters; +using Reveal.Sdk.Dom.Visualizations.Settings; +using System.Collections.Generic; +using System.Linq; + +namespace Reveal.Sdk.Dom.Visualizations +{ + //public abstract class TabularVisualizationBase : Visualization, ITabularVisualization + // where TSettings : VisualizationSettings, new() + //{ + // protected TabularVisualizationBase(string title, DataSourceItem dataSourceItem) : base(title) + // { + // DataDefinition = new TabularDataDefinition(); + // UpdateDataSourceItem(dataSourceItem); + // } + + // [JsonIgnore] + // public List Filters + // { + // get { return DataDefinition.QuickFilters; } + // } + + // /// + // /// Gets the data source item for the visualization. + // /// + // /// The + // public DataSourceItem GetDataSourceItem() + // { + // var dataSourceItem = DataDefinition.DataSourceItem; + // dataSourceItem.Fields = DataDefinition.Fields.Clone(); + + // IParentDocument viz = this; + // dataSourceItem.DataSource = viz.Document.DataSources.Where(x => x.Id == dataSourceItem.DataSourceId).First(); + // if (dataSourceItem.ResourceItem != null) + // dataSourceItem.ResourceItemDataSource = viz.Document.DataSources.Where(x => x.Id == dataSourceItem.ResourceItem.DataSourceId).First(); + + // return dataSourceItem; + // } + + // /// + // /// Updates the data source item and available fields for the visualization. + // /// + // /// The created with a data source builder. + // public void UpdateDataSourceItem(DataSourceItem dataSourceItem) + // { + // DataDefinition.DataSourceItem = dataSourceItem; + // DataDefinition.Fields = dataSourceItem?.Fields.Clone(); + // } + //} } \ No newline at end of file diff --git a/src/Reveal.Sdk.Dom/Visualizations/TextBoxVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/TextBoxVisualization.cs index 9620475f..dd862314 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/TextBoxVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/TextBoxVisualization.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using Reveal.Sdk.Dom.Data; using Reveal.Sdk.Dom.Visualizations.Settings; namespace Reveal.Sdk.Dom.Visualizations @@ -6,7 +7,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The text box visualizations is used to display a text body and an optional title. It is not connected to a data source. /// - public sealed class TextBoxVisualization : Visualization + public sealed class TextBoxVisualization : Visualization { /// /// Creates a text box visualization. @@ -17,32 +18,44 @@ public TextBoxVisualization() : this(null) { } /// Creates a text box visualization and sets the title to the provided string. /// /// The string to use as the visualization's title. - public TextBoxVisualization(string title) : base(title) + public TextBoxVisualization(string title) : base(title, null) { - DataDefinition = new TextBoxDataDefinition(); - DataDefinition.Bindings = null; ChartType = ChartType.TextBox; + InitializeDataDefinition(null); } [JsonIgnore] public Alignment Alignment { - get { return DataDefinition.Alignment; } - set { DataDefinition.Alignment = value; } + get { return TextBoxDataDefinition.Alignment; } + set { TextBoxDataDefinition.Alignment = value; } } [JsonIgnore] public FontSize FontSize { - get { return DataDefinition.FontSize; } - set { DataDefinition.FontSize = value; } + get { return TextBoxDataDefinition.FontSize; } + set { TextBoxDataDefinition.FontSize = value; } } [JsonIgnore] public string Text { - get { return DataDefinition.Text; } - set { DataDefinition.Text = value; } + get { return TextBoxDataDefinition.Text; } + set { TextBoxDataDefinition.Text = value; } + } + + private TextBoxDataDefinition TextBoxDataDefinition + { + get => (TextBoxDataDefinition)DataDefinition; + } + + override protected void InitializeDataDefinition(DataSourceItem dataSourceItem) + { + DataDefinition = new TextBoxDataDefinition() + { + Bindings = null + }; } } } diff --git a/src/Reveal.Sdk.Dom/Visualizations/TextViewVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/TextViewVisualization.cs index a799dcd1..0e9d188c 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/TextViewVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/TextViewVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The text view visualization is used to display information that follows a key-value pattern. It only displays the first row of data paired with the column's label. /// - public sealed class TextViewVisualization : TabularVisualizationBase, ITabularColumns + public sealed class TextViewVisualization : Visualization, ITabularColumns { internal TextViewVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/TimeSeriesVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/TimeSeriesVisualization.cs index b27784c1..5daf96b2 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/TimeSeriesVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/TimeSeriesVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// A time series visualization is used to display data points indexed in time order. It is commonly used to detect trends at a glance, allowing an easy observation of development over time. /// - public sealed class TimeSeriesVisualization : TabularVisualizationBase, IDate, IValues, ICategory + public sealed class TimeSeriesVisualization : Visualization, IDate, IValues, ICategory { internal TimeSeriesVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/TreeMapVisualization.cs b/src/Reveal.Sdk.Dom/Visualizations/TreeMapVisualization.cs index d7075a70..8008eb4e 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/TreeMapVisualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/TreeMapVisualization.cs @@ -9,7 +9,7 @@ namespace Reveal.Sdk.Dom.Visualizations /// /// The treemap visualization is used to display hierarchical data as a set of nested rectangles. Rectangles of each level are of different sizes and colors. /// - public sealed class TreeMapVisualization : TabularVisualizationBase, ILabels, IValues + public sealed class TreeMapVisualization : Visualization, ILabels, IValues { internal TreeMapVisualization() : this(null) { } diff --git a/src/Reveal.Sdk.Dom/Visualizations/Visualization.cs b/src/Reveal.Sdk.Dom/Visualizations/Visualization.cs index 98e12d65..f8f8b746 100644 --- a/src/Reveal.Sdk.Dom/Visualizations/Visualization.cs +++ b/src/Reveal.Sdk.Dom/Visualizations/Visualization.cs @@ -1,25 +1,25 @@ using Newtonsoft.Json; using Reveal.Sdk.Dom.Core; +using Reveal.Sdk.Dom.Core.Utilities; +using Reveal.Sdk.Dom.Data; using Reveal.Sdk.Dom.Filters; using Reveal.Sdk.Dom.Visualizations.Settings; using System; using System.Collections.Generic; +using System.Linq; namespace Reveal.Sdk.Dom.Visualizations { - public abstract class Visualization : Visualization, ISettingsProvider, IDataDefinitionProvider, IFilterBindings + public abstract class Visualization : Visualization, ISettingsProvider, IFilterBindings where TSettings : VisualizationSettings, new() - where TDataDefinition : DataDefinitionBase { - protected Visualization(string title) : base(title) { } - - [JsonProperty("DataSpec", Order = 6)] - public TDataDefinition DataDefinition { get; internal set; } + protected Visualization(string title, DataSourceItem dataSourceItem) + : base(title, dataSourceItem) { } [JsonIgnore] public List FilterBindings { - get { return DataDefinition.Bindings.Bindings; } + get { return ((DataDefinitionBase)DataDefinition).Bindings.Bindings; } } [JsonProperty("ActionsModel", Order = 10)] @@ -27,13 +27,21 @@ public List FilterBindings [JsonProperty("VisualizationSettings", Order = 5)] public TSettings Settings { get; internal set; } = new TSettings(); + + //todo: is it possible to create a Filters property that can properly handle both Tabular and Xmla data specs? + //[JsonIgnore] + //public List Filters + //{ + // get { return DataDefinition.QuickFilters; } //this works for tabluar + //} } public abstract class Visualization : IVisualization, IParentDocument { - protected Visualization(string title) + protected Visualization(string title, DataSourceItem dataSourceItem) { Title = title; + InitializeDataDefinition(dataSourceItem); } [JsonProperty(Order = 0)] @@ -56,5 +64,61 @@ protected Visualization(string title) [JsonIgnore] RdashDocument IParentDocument.Document { get; set; } + + [JsonProperty("DataSpec", Order = 6)] + public IDataDefinition DataDefinition { get; internal set; } + + /// + /// Gets the data source item for the visualization. + /// + /// The + public DataSourceItem GetDataSourceItem() + { + var dataSourceItem = DataDefinition.DataSourceItem; + if (DataDefinition is TabularDataDefinition tdd) + { + dataSourceItem.Fields = tdd.Fields.Clone(); + } + + IParentDocument viz = this; + dataSourceItem.DataSource = viz.Document.DataSources.Where(x => x.Id == dataSourceItem.DataSourceId).First(); + if (dataSourceItem.ResourceItem != null) + dataSourceItem.ResourceItemDataSource = viz.Document.DataSources.Where(x => x.Id == dataSourceItem.ResourceItem.DataSourceId).First(); + + return dataSourceItem; + } + + /// + /// Updates the data source item and available fields for the visualization. + /// + /// The created with a data source builder. + public void UpdateDataSourceItem(DataSourceItem dataSourceItem) + { + if (DataDefinition == null) + return; + + ((DataDefinitionBase)DataDefinition).DataSourceItem = dataSourceItem; + if (DataDefinition is TabularDataDefinition tdd) + { + tdd.Fields = dataSourceItem?.Fields.Clone(); + } + } + + protected virtual void InitializeDataDefinition(DataSourceItem dataSourceItem) + { + if (dataSourceItem != null) + { + if (dataSourceItem.HasTabularData) + { + DataDefinition = new TabularDataDefinition(); + } + else + { + DataDefinition = new XmlaDataDefinition(); + } + + UpdateDataSourceItem(dataSourceItem); + } + } } } \ No newline at end of file