mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
added default config for timeSeries since it is not the same (#1852)
This commit is contained in:
@@ -5,13 +5,12 @@
|
|||||||
import 'vs/css!sql/parts/grid/views/query/chartViewer';
|
import 'vs/css!sql/parts/grid/views/query/chartViewer';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Component, Inject, ViewContainerRef, forwardRef, OnInit,
|
Component, Inject, forwardRef, OnInit, ComponentFactoryResolver, ViewChild,
|
||||||
ComponentFactoryResolver, ViewChild, OnDestroy, Input, ElementRef, ChangeDetectorRef
|
OnDestroy, Input, ElementRef, ChangeDetectorRef
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NgGridItemConfig } from 'angular2-grid';
|
import { NgGridItemConfig } from 'angular2-grid';
|
||||||
|
|
||||||
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||||
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
|
|
||||||
import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost.directive';
|
import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost.directive';
|
||||||
import { IGridDataSet } from 'sql/parts/grid/common/interfaces';
|
import { IGridDataSet } from 'sql/parts/grid/common/interfaces';
|
||||||
import { IInsightData, IInsightsView, IInsightsConfig } from 'sql/parts/dashboard/widgets/insights/interfaces';
|
import { IInsightData, IInsightsView, IInsightsConfig } from 'sql/parts/dashboard/widgets/insights/interfaces';
|
||||||
@@ -32,7 +31,6 @@ import {
|
|||||||
} from 'sql/parts/dashboard/widgets/insights/views/charts/chartInsight.component';
|
} from 'sql/parts/dashboard/widgets/insights/views/charts/chartInsight.component';
|
||||||
|
|
||||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
|
|
||||||
import Severity from 'vs/base/common/severity';
|
import Severity from 'vs/base/common/severity';
|
||||||
import URI from 'vs/base/common/uri';
|
import URI from 'vs/base/common/uri';
|
||||||
import * as nls from 'vs/nls';
|
import * as nls from 'vs/nls';
|
||||||
@@ -87,21 +85,17 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
|
|||||||
private _saveAction: SaveImageAction;
|
private _saveAction: SaveImageAction;
|
||||||
private _chartConfig: ILineConfig;
|
private _chartConfig: ILineConfig;
|
||||||
private _disposables: Array<IDisposable> = [];
|
private _disposables: Array<IDisposable> = [];
|
||||||
private _dataSet: IGridDataSet;
|
|
||||||
private _executeResult: IInsightData;
|
private _executeResult: IInsightData;
|
||||||
private _chartComponent: ChartInsight;
|
private _chartComponent: ChartInsight;
|
||||||
|
|
||||||
private localizedStrings = LocalizedStrings;
|
protected localizedStrings = LocalizedStrings;
|
||||||
private insightRegistry = insightRegistry;
|
protected insightRegistry = insightRegistry;
|
||||||
|
|
||||||
@ViewChild(ComponentHostDirective) private componentHost: ComponentHostDirective;
|
@ViewChild(ComponentHostDirective) private componentHost: ComponentHostDirective;
|
||||||
@ViewChild('taskbarContainer', { read: ElementRef }) private taskbarContainer;
|
@ViewChild('taskbarContainer', { read: ElementRef }) private taskbarContainer;
|
||||||
@ViewChild('chartTypesContainer', { read: ElementRef }) private chartTypesElement;
|
|
||||||
@ViewChild('legendContainer', { read: ElementRef }) private legendElement;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(forwardRef(() => ComponentFactoryResolver)) private _componentFactoryResolver: ComponentFactoryResolver,
|
@Inject(forwardRef(() => ComponentFactoryResolver)) private _componentFactoryResolver: ComponentFactoryResolver,
|
||||||
@Inject(forwardRef(() => ViewContainerRef)) private _viewContainerRef: ViewContainerRef,
|
|
||||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
|
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
|
||||||
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
|
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
|
||||||
@Inject(INotificationService) private notificationService: INotificationService,
|
@Inject(INotificationService) private notificationService: INotificationService,
|
||||||
@@ -123,15 +117,25 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
private setDefaultChartConfig() {
|
private setDefaultChartConfig() {
|
||||||
this._chartConfig = <ILineConfig>{
|
let defaultChart = this.getDefaultChartType();
|
||||||
dataDirection: 'vertical',
|
if (defaultChart === 'timeSeries') {
|
||||||
dataType: 'number',
|
this._chartConfig = <ILineConfig>{
|
||||||
legendPosition: 'none',
|
dataDirection: 'vertical',
|
||||||
labelFirstColumn: false
|
dataType: 'point',
|
||||||
};
|
legendPosition: 'none',
|
||||||
|
labelFirstColumn: false
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this._chartConfig = <ILineConfig>{
|
||||||
|
dataDirection: 'vertical',
|
||||||
|
dataType: 'number',
|
||||||
|
legendPosition: 'none',
|
||||||
|
labelFirstColumn: false
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDefaultChartType(): string {
|
protected getDefaultChartType(): string {
|
||||||
let defaultChartType = Constants.chartTypeHorizontalBar;
|
let defaultChartType = Constants.chartTypeHorizontalBar;
|
||||||
if (this.configurationService) {
|
if (this.configurationService) {
|
||||||
let chartSettings = WorkbenchUtils.getSqlConfigSection(this.configurationService, 'chart');
|
let chartSettings = WorkbenchUtils.getSqlConfigSection(this.configurationService, 'chart');
|
||||||
@@ -300,22 +304,18 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get showDataDirection(): boolean {
|
protected get showDataDirection(): boolean {
|
||||||
return ['pie', 'horizontalBar', 'bar', 'doughnut'].some(item => item === this.chartTypesSelectBox.value) || (this.chartTypesSelectBox.value === 'line' && this.dataType === 'number');
|
return ['pie', 'horizontalBar', 'bar', 'doughnut'].some(item => item === this.chartTypesSelectBox.value) || (this.chartTypesSelectBox.value === 'line' && this.dataType === 'number');
|
||||||
}
|
}
|
||||||
|
|
||||||
private get showLabelFirstColumn(): boolean {
|
protected get showLabelFirstColumn(): boolean {
|
||||||
return this.dataDirection === 'horizontal' && this.dataType !== 'point';
|
return this.dataDirection === 'horizontal' && this.dataType !== 'point';
|
||||||
}
|
}
|
||||||
|
|
||||||
private get showColumnsAsLabels(): boolean {
|
protected get showColumnsAsLabels(): boolean {
|
||||||
return this.dataDirection === 'vertical' && this.dataType !== 'point';
|
return this.dataDirection === 'vertical' && this.dataType !== 'point';
|
||||||
}
|
}
|
||||||
|
|
||||||
private get showDataType(): boolean {
|
|
||||||
return this.chartTypesSelectBox.value === 'line';
|
|
||||||
}
|
|
||||||
|
|
||||||
public get dataDirection(): DataDirection {
|
public get dataDirection(): DataDirection {
|
||||||
return this._chartConfig.dataDirection;
|
return this._chartConfig.dataDirection;
|
||||||
}
|
}
|
||||||
@@ -326,7 +326,6 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
|
|||||||
|
|
||||||
@Input() set dataSet(dataSet: IGridDataSet) {
|
@Input() set dataSet(dataSet: IGridDataSet) {
|
||||||
// Setup the execute result
|
// Setup the execute result
|
||||||
this._dataSet = dataSet;
|
|
||||||
this._executeResult = <IInsightData>{};
|
this._executeResult = <IInsightData>{};
|
||||||
this._executeResult.columns = dataSet.columnDefinitions.map(def => def.name);
|
this._executeResult.columns = dataSet.columnDefinitions.map(def => def.name);
|
||||||
this._executeResult.rows = dataSet.dataRows.getRange(0, dataSet.dataRows.getLength()).map(gridRow => {
|
this._executeResult.rows = dataSet.dataRows.getRange(0, dataSet.dataRows.getLength()).map(gridRow => {
|
||||||
@@ -356,4 +355,4 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
|
|||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this._disposables.forEach(i => i.dispose());
|
this._disposables.forEach(i => i.dispose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user