From f75be771383bb45d15b799bd872ae148e4d1e6cb Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Thu, 11 Feb 2021 15:40:29 -0800 Subject: [PATCH] add visualization option support (#1160) * add visualization option support * add comments --- .../Contracts/ResultSetSummary.cs | 51 +++++++++++++++++- .../Contracts/ResultSetSummary.cs | 52 ++++++++++++++++++- 2 files changed, 101 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Kusto.ServiceLayer/QueryExecution/Contracts/ResultSetSummary.cs b/src/Microsoft.Kusto.ServiceLayer/QueryExecution/Contracts/ResultSetSummary.cs index 8548b07f..3d0dcfca 100644 --- a/src/Microsoft.Kusto.ServiceLayer/QueryExecution/Contracts/ResultSetSummary.cs +++ b/src/Microsoft.Kusto.ServiceLayer/QueryExecution/Contracts/ResultSetSummary.cs @@ -2,6 +2,9 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; namespace Microsoft.Kusto.ServiceLayer.QueryExecution.Contracts { @@ -40,7 +43,53 @@ namespace Microsoft.Kusto.ServiceLayer.QueryExecution.Contracts /// public SpecialAction SpecialAction { get; set; } - public override string ToString() => $"Result Summary Id:{Id}, Batch Id:'{BatchId}', RowCount:'{RowCount}', Complete:'{Complete}', SpecialAction:'{SpecialAction}'"; + /// + /// The visualization options for the client to render charts. + /// + public VisualizationOptions Visualization { get; set; } + /// + /// Returns a string represents the current object. + /// + public override string ToString() => $"Result Summary Id:{Id}, Batch Id:'{BatchId}', RowCount:'{RowCount}', Complete:'{Complete}', SpecialAction:'{SpecialAction}', Visualization:'{Visualization}'"; + } + + /// + /// Represents the configuration options for data visualization + /// + public class VisualizationOptions + { + /// + /// Gets or sets the type of the visualization + /// + public VisualizationType Type { get; set; } + } + + /// + /// The supported visualization types + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum VisualizationType + { + [EnumMember(Value = "bar")] + Bar, + [EnumMember(Value = "count")] + Count, + [EnumMember(Value = "doughnut")] + Doughnut, + [EnumMember(Value = "horizontalBar")] + HorizontalBar, + [EnumMember(Value = "image")] + Image, + [EnumMember(Value = "line")] + Line, + [EnumMember(Value = "pie")] + Pie, + [EnumMember(Value = "scatter")] + Scatter, + [EnumMember(Value = "table")] + Table, + [EnumMember(Value = "timeSeries")] + TimeSeries } } diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ResultSetSummary.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ResultSetSummary.cs index 5486c8fa..a60bdf9e 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ResultSetSummary.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Contracts/ResultSetSummary.cs @@ -3,6 +3,10 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts { /// @@ -40,7 +44,53 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts /// public SpecialAction SpecialAction { get; set; } - public override string ToString() => $"Result Summary Id:{Id}, Batch Id:'{BatchId}', RowCount:'{RowCount}', Complete:'{Complete}', SpecialAction:'{SpecialAction}'"; + /// + /// The visualization options for the client to render charts. + /// + public VisualizationOptions Visualization { get; set; } + /// + /// Returns a string represents the current object. + /// + public override string ToString() => $"Result Summary Id:{Id}, Batch Id:'{BatchId}', RowCount:'{RowCount}', Complete:'{Complete}', SpecialAction:'{SpecialAction}', Visualization:'{Visualization}'"; + } + + /// + /// Represents the configuration options for data visualization + /// + public class VisualizationOptions + { + /// + /// Gets or sets the type of the visualization + /// + public VisualizationType Type { get; set; } + } + + /// + /// The supported visualization types + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum VisualizationType + { + [EnumMember(Value = "bar")] + Bar, + [EnumMember(Value = "count")] + Count, + [EnumMember(Value = "doughnut")] + Doughnut, + [EnumMember(Value = "horizontalBar")] + HorizontalBar, + [EnumMember(Value = "image")] + Image, + [EnumMember(Value = "line")] + Line, + [EnumMember(Value = "pie")] + Pie, + [EnumMember(Value = "scatter")] + Scatter, + [EnumMember(Value = "table")] + Table, + [EnumMember(Value = "timeSeries")] + TimeSeries } }