Fix Dashboard Errors (#1106)

* fix ordering of component instance calls to fix erros

* add more verification methods
This commit is contained in:
Anthony Dresser
2018-04-10 13:46:07 -07:00
committed by GitHub
parent 5ac89e5a49
commit a327889d05
2 changed files with 7 additions and 3 deletions

View File

@@ -198,11 +198,11 @@ export class InsightsWidget extends DashboardWidget implements IDashboardWidget,
let componentRef = this.componentHost.viewContainerRef.createComponent(componentFactory);
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
if (componentInstance.setConfig) {
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) {
componentInstance.init();

View File

@@ -90,7 +90,7 @@ export const defaultChartConfig: IChartConfig = {
@Component({
template: ` <div style="display: block; width: 100%; height: 100%; position: relative">
<canvas #canvas *ngIf="_isDataAvailable"
<canvas #canvas *ngIf="_isDataAvailable && _hasInit"
baseChart
[datasets]="chartData"
[labels]="labels"
@@ -101,6 +101,7 @@ export const defaultChartConfig: IChartConfig = {
})
export abstract class ChartInsight extends Disposable implements IInsightsView {
private _isDataAvailable: boolean = false;
private _hasInit: boolean = false;
private _options: any = {};
@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
// hence it's easier to not render until ready
this.options = mixin(this.options, { maintainAspectRatio: false });
this._hasInit = true;
this._changeRef.detectChanges();
TelemetryUtils.addTelemetry(this._bootstrapService.telemetryService, TelemetryKeys.ChartCreated, { type: this.chartType });
}
@@ -160,7 +162,9 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
public refresh() {
// cheaper refresh but causes problems when change data for rerender
this._chart.ngOnChanges({});
if (this._chart) {
this._chart.ngOnChanges({});
}
}
public getCanvasData(): string {