mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
fix problems with low result count breaking insights (#1052)
This commit is contained in:
committed by
Karl Burtram
parent
86748e6d69
commit
bec8e72688
@@ -111,7 +111,6 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
|||||||
|
|
||||||
protected abstract get chartType(): ChartType;
|
protected abstract get chartType(): ChartType;
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
||||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
||||||
@@ -127,7 +126,6 @@ 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._isDataAvailable = 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 });
|
||||||
}
|
}
|
||||||
@@ -178,6 +176,9 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
|||||||
unmemoize(this, 'chartData');
|
unmemoize(this, 'chartData');
|
||||||
unmemoize(this, 'labels');
|
unmemoize(this, 'labels');
|
||||||
this._data = data;
|
this._data = data;
|
||||||
|
if (isValidData(data)) {
|
||||||
|
this._isDataAvailable = true;
|
||||||
|
}
|
||||||
|
|
||||||
this._changeRef.detectChanges();
|
this._changeRef.detectChanges();
|
||||||
}
|
}
|
||||||
@@ -226,14 +227,14 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
|||||||
data: this._data.rows.map(row => Number(row[i])),
|
data: this._data.rows.map(row => Number(row[i])),
|
||||||
label: this._data.columns[i]
|
label: this._data.columns[i]
|
||||||
};
|
};
|
||||||
}).slice(1);
|
});
|
||||||
} else {
|
} else {
|
||||||
return this._data.rows[0].map((row, i) => {
|
return this._data.rows[0].map((row, i) => {
|
||||||
return {
|
return {
|
||||||
data: this._data.rows.map(row => Number(row[i])),
|
data: this._data.rows.map(row => Number(row[i])),
|
||||||
label: 'Series' + i
|
label: 'Series' + i
|
||||||
};
|
};
|
||||||
}).slice(1);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,3 +285,19 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
|||||||
this.options = mixin(this.options, options);
|
this.options = mixin(this.options, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidData(data: IInsightData): boolean {
|
||||||
|
if (types.isUndefinedOrNull(data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (types.isUndefinedOrNull(data.columns)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (types.isUndefinedOrNull(data.rows)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -351,7 +351,9 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
|
|||||||
this.componentHost.viewContainerRef.clear();
|
this.componentHost.viewContainerRef.clear();
|
||||||
let componentRef = this.componentHost.viewContainerRef.createComponent(componentFactory);
|
let componentRef = this.componentHost.viewContainerRef.createComponent(componentFactory);
|
||||||
this._chartComponent = <ChartInsight>componentRef.instance;
|
this._chartComponent = <ChartInsight>componentRef.instance;
|
||||||
this._chartComponent.setConfig(this._chartConfig);
|
if (this._chartComponent.setConfig) {
|
||||||
|
this._chartComponent.setConfig(this._chartConfig);
|
||||||
|
}
|
||||||
this._chartComponent.data = this._executeResult;
|
this._chartComponent.data = this._executeResult;
|
||||||
this._chartComponent.options = mixin(this._chartComponent.options, { animation: { duration: 0 } });
|
this._chartComponent.options = mixin(this._chartComponent.options, { animation: { duration: 0 } });
|
||||||
if (this._chartComponent.init) {
|
if (this._chartComponent.init) {
|
||||||
|
|||||||
Reference in New Issue
Block a user