mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix Dashboard Errors (#1106)
* fix ordering of component instance calls to fix erros * add more verification methods
This commit is contained in:
@@ -198,11 +198,11 @@ export class InsightsWidget extends DashboardWidget implements IDashboardWidget,
|
|||||||
|
|
||||||
let componentRef = this.componentHost.viewContainerRef.createComponent(componentFactory);
|
let componentRef = this.componentHost.viewContainerRef.createComponent(componentFactory);
|
||||||
let componentInstance = componentRef.instance;
|
let componentInstance = componentRef.instance;
|
||||||
componentInstance.data = { columns: result.columnInfo.map(item => item.columnName), rows: result.rows.map(row => row.map(item => item.displayValue)) };
|
|
||||||
// check if the setter is defined
|
// check if the setter is defined
|
||||||
if (componentInstance.setConfig) {
|
if (componentInstance.setConfig) {
|
||||||
componentInstance.setConfig(this.insightConfig.type[this._typeKey]);
|
componentInstance.setConfig(this.insightConfig.type[this._typeKey]);
|
||||||
}
|
}
|
||||||
|
componentInstance.data = { columns: result.columnInfo.map(item => item.columnName), rows: result.rows.map(row => row.map(item => item.displayValue)) };
|
||||||
|
|
||||||
if (componentInstance.init) {
|
if (componentInstance.init) {
|
||||||
componentInstance.init();
|
componentInstance.init();
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export const defaultChartConfig: IChartConfig = {
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: ` <div style="display: block; width: 100%; height: 100%; position: relative">
|
template: ` <div style="display: block; width: 100%; height: 100%; position: relative">
|
||||||
<canvas #canvas *ngIf="_isDataAvailable"
|
<canvas #canvas *ngIf="_isDataAvailable && _hasInit"
|
||||||
baseChart
|
baseChart
|
||||||
[datasets]="chartData"
|
[datasets]="chartData"
|
||||||
[labels]="labels"
|
[labels]="labels"
|
||||||
@@ -101,6 +101,7 @@ export const defaultChartConfig: IChartConfig = {
|
|||||||
})
|
})
|
||||||
export abstract class ChartInsight extends Disposable implements IInsightsView {
|
export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||||
private _isDataAvailable: boolean = false;
|
private _isDataAvailable: boolean = false;
|
||||||
|
private _hasInit: boolean = false;
|
||||||
private _options: any = {};
|
private _options: any = {};
|
||||||
|
|
||||||
@ViewChild(BaseChartDirective) private _chart: BaseChartDirective;
|
@ViewChild(BaseChartDirective) private _chart: BaseChartDirective;
|
||||||
@@ -126,6 +127,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
|||||||
// This is because chart.js doesn't auto-update anything other than dataset when re-rendering so defaults are used
|
// This is because chart.js doesn't auto-update anything other than dataset when re-rendering so defaults are used
|
||||||
// hence it's easier to not render until ready
|
// hence it's easier to not render until ready
|
||||||
this.options = mixin(this.options, { maintainAspectRatio: false });
|
this.options = mixin(this.options, { maintainAspectRatio: false });
|
||||||
|
this._hasInit = true;
|
||||||
this._changeRef.detectChanges();
|
this._changeRef.detectChanges();
|
||||||
TelemetryUtils.addTelemetry(this._bootstrapService.telemetryService, TelemetryKeys.ChartCreated, { type: this.chartType });
|
TelemetryUtils.addTelemetry(this._bootstrapService.telemetryService, TelemetryKeys.ChartCreated, { type: this.chartType });
|
||||||
}
|
}
|
||||||
@@ -160,7 +162,9 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
|||||||
|
|
||||||
public refresh() {
|
public refresh() {
|
||||||
// cheaper refresh but causes problems when change data for rerender
|
// cheaper refresh but causes problems when change data for rerender
|
||||||
this._chart.ngOnChanges({});
|
if (this._chart) {
|
||||||
|
this._chart.ngOnChanges({});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCanvasData(): string {
|
public getCanvasData(): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user