mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
add support to accept visualization options (#14254)
* allow query provider to specify visual options * make it reusable * add comment * fix error * null check
This commit is contained in:
19
src/sql/azdata.proposed.d.ts
vendored
19
src/sql/azdata.proposed.d.ts
vendored
@@ -983,4 +983,23 @@ declare module 'azdata' {
|
|||||||
*/
|
*/
|
||||||
MsGraph = 7
|
MsGraph = 7
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ResultSetSummary {
|
||||||
|
/**
|
||||||
|
* The visualization options for the result set.
|
||||||
|
*/
|
||||||
|
visualization?: VisualizationOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines all the supported visualization types
|
||||||
|
*/
|
||||||
|
export type VisualizationType = 'bar' | 'count' | 'doughnut' | 'horizontalBar' | 'image' | 'line' | 'pie' | 'scatter' | 'table' | 'timeSeries';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the configuration options for visualization
|
||||||
|
*/
|
||||||
|
export interface VisualizationOptions {
|
||||||
|
type: VisualizationType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import 'vs/css!./media/chartView';
|
|||||||
import { IPanelView } from 'sql/base/browser/ui/panel/panel';
|
import { IPanelView } from 'sql/base/browser/ui/panel/panel';
|
||||||
import { Insight } from './insight';
|
import { Insight } from './insight';
|
||||||
import QueryRunner from 'sql/workbench/services/query/common/queryRunner';
|
import QueryRunner from 'sql/workbench/services/query/common/queryRunner';
|
||||||
import { ICellValue } from 'sql/workbench/services/query/common/query';
|
import { ICellValue, VisualizationOptions } from 'sql/workbench/services/query/common/query';
|
||||||
import { ChartOptions, IChartOption, ControlType } from './chartOptions';
|
import { ChartOptions, IChartOption, ControlType } from './chartOptions';
|
||||||
import { Extensions, IInsightRegistry, IInsightData } from 'sql/platform/dashboard/browser/insightRegistry';
|
import { Extensions, IInsightRegistry, IInsightData } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||||
import { Registry } from 'vs/platform/registry/common/platform';
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
@@ -24,7 +24,7 @@ import { isUndefinedOrNull } from 'vs/base/common/types';
|
|||||||
import { CreateInsightAction, CopyAction, SaveImageAction, IChartActionContext, ConfigureChartAction } from 'sql/workbench/contrib/charts/browser/actions';
|
import { CreateInsightAction, CopyAction, SaveImageAction, IChartActionContext, ConfigureChartAction } from 'sql/workbench/contrib/charts/browser/actions';
|
||||||
import { Taskbar, ITaskbarContent } from 'sql/base/browser/ui/taskbar/taskbar';
|
import { Taskbar, ITaskbarContent } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||||
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
|
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
|
||||||
import { IInsightOptions, ChartType } from 'sql/workbench/contrib/charts/common/interfaces';
|
import { IInsightOptions, ChartType, InsightType } from 'sql/workbench/contrib/charts/common/interfaces';
|
||||||
import { ChartState } from 'sql/workbench/common/editor/query/chartState';
|
import { ChartState } from 'sql/workbench/common/editor/query/chartState';
|
||||||
import * as nls from 'vs/nls';
|
import * as nls from 'vs/nls';
|
||||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||||
@@ -453,4 +453,16 @@ export class ChartView extends Disposable implements IPanelView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the visualization options, this method handles the conversion from VisualizationOptions(defined in azdata typing) to IInsightOptions
|
||||||
|
* @param options visualization options returned by query
|
||||||
|
*/
|
||||||
|
public setVisualizationOptions(options: VisualizationOptions): void {
|
||||||
|
if (options?.type) {
|
||||||
|
this.options = {
|
||||||
|
type: options.type as (ChartType | InsightType)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,6 +237,16 @@ export class QueryResultsView extends Disposable {
|
|||||||
if (runner.messages.some(v => v.isError)) {
|
if (runner.messages.some(v => v.isError)) {
|
||||||
this._panelView.showTab(this.messagesTab.identifier);
|
this._panelView.showTab(this.messagesTab.identifier);
|
||||||
}
|
}
|
||||||
|
// Currently we only need to support visualization options for the first result set.
|
||||||
|
if (runner.batchSets[0]?.resultSetSummaries[0]?.visualization) {
|
||||||
|
const batchSet = runner.batchSets[0];
|
||||||
|
const resultSet = batchSet.resultSetSummaries[0];
|
||||||
|
this.chartData({
|
||||||
|
resultId: batchSet.id,
|
||||||
|
batchId: resultSet.batchId
|
||||||
|
});
|
||||||
|
this.chartTab.view.setVisualizationOptions(resultSet.visualization);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (this.input?.state.visibleTabs.has(this.chartTab.identifier) && !this._panelView.contains(this.chartTab)) {
|
if (this.input?.state.visibleTabs.has(this.chartTab.identifier) && !this._panelView.contains(this.chartTab)) {
|
||||||
|
|||||||
@@ -11,12 +11,19 @@ export interface IColumn {
|
|||||||
isJson?: boolean;
|
isJson?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type VisualizationType = 'bar' | 'count' | 'doughnut' | 'horizontalBar' | 'image' | 'line' | 'pie' | 'scatter' | 'table' | 'timeSeries';
|
||||||
|
|
||||||
|
export interface VisualizationOptions {
|
||||||
|
type: VisualizationType
|
||||||
|
}
|
||||||
|
|
||||||
export interface ResultSetSummary {
|
export interface ResultSetSummary {
|
||||||
id: number;
|
id: number;
|
||||||
batchId: number;
|
batchId: number;
|
||||||
rowCount: number;
|
rowCount: number;
|
||||||
columnInfo: IColumn[];
|
columnInfo: IColumn[];
|
||||||
complete: boolean;
|
complete: boolean;
|
||||||
|
visualization?: VisualizationOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BatchStartSummary {
|
export interface BatchStartSummary {
|
||||||
|
|||||||
Reference in New Issue
Block a user