mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-05 09:35:39 -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:
@@ -8,7 +8,7 @@ import 'vs/css!./media/chartView';
|
||||
import { IPanelView } from 'sql/base/browser/ui/panel/panel';
|
||||
import { Insight } from './insight';
|
||||
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 { Extensions, IInsightRegistry, IInsightData } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||
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 { Taskbar, ITaskbarContent } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||
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 * as nls from 'vs/nls';
|
||||
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)) {
|
||||
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)) {
|
||||
|
||||
@@ -11,12 +11,19 @@ export interface IColumn {
|
||||
isJson?: boolean;
|
||||
}
|
||||
|
||||
export type VisualizationType = 'bar' | 'count' | 'doughnut' | 'horizontalBar' | 'image' | 'line' | 'pie' | 'scatter' | 'table' | 'timeSeries';
|
||||
|
||||
export interface VisualizationOptions {
|
||||
type: VisualizationType
|
||||
}
|
||||
|
||||
export interface ResultSetSummary {
|
||||
id: number;
|
||||
batchId: number;
|
||||
rowCount: number;
|
||||
columnInfo: IColumn[];
|
||||
complete: boolean;
|
||||
visualization?: VisualizationOptions;
|
||||
}
|
||||
|
||||
export interface BatchStartSummary {
|
||||
|
||||
Reference in New Issue
Block a user