From 8a417c344aecad5916f49217f7b05400344661a9 Mon Sep 17 00:00:00 2001 From: Violet Voronetzky Date: Mon, 18 Nov 2019 15:02:11 +0200 Subject: [PATCH 1/2] Fixed getDefaultSelection method --- src/common/kustoChartHelper.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/kustoChartHelper.ts b/src/common/kustoChartHelper.ts index 71b8df9..19e2415 100644 --- a/src/common/kustoChartHelper.ts +++ b/src/common/kustoChartHelper.ts @@ -83,7 +83,7 @@ export class KustoChartHelper implements IChartHelper { const defaultXAxis: IColumn = this.selectDefaultXAxis(supportedColumnsForChart.xAxis); const defaultSplitBy: IColumn = this.selectDefaultSplitByColumn(supportedColumnsForChart.splitBy, defaultXAxis, chartType); - const defaultYAxes: IColumn[] = this.selectDefaultYAxes(supportedColumnsForChart.yAxis, defaultXAxis, defaultSplitBy); + const defaultYAxes: IColumn[] = this.selectDefaultYAxes(supportedColumnsForChart.yAxis, defaultXAxis, defaultSplitBy, chartType); return { xAxis: defaultXAxis, @@ -196,7 +196,7 @@ export class KustoChartHelper implements IChartHelper { return supportedColumns[0]; } - private selectDefaultYAxes(supportedColumns: IColumn[], selectedXAxis: IColumn, selectedSplitBy?: IColumn): IColumn[] { + private selectDefaultYAxes(supportedColumns: IColumn[], selectedXAxis: IColumn, selectedSplitBy: IColumn, chartType: ChartType): IColumn[] { if (!supportedColumns || supportedColumns.length === 0 || !selectedXAxis) { return null; } @@ -213,7 +213,13 @@ export class KustoChartHelper implements IChartHelper { return null; } - const numberOfDefaultYAxes: number = selectedSplitBy ? 1 : KustoChartHelper.maxDefaultYAxesSelection; + let numberOfDefaultYAxes: number = 1; + + // The y-axis is a single select when there is split-by, ot for Pie / Donut charts + if (chartType !== ChartType.Pie && chartType !== ChartType.Donut && !selectedSplitBy) { + numberOfDefaultYAxes = KustoChartHelper.maxDefaultYAxesSelection; + } + const selectedYAxes: IColumn[] = updatedSupportedColumns.slice(0, numberOfDefaultYAxes); return selectedYAxes; From 3f436c6c86e933b6e19d80aa7c9d26f95063151e Mon Sep 17 00:00:00 2001 From: Violet Voronetzky Date: Mon, 18 Nov 2019 15:23:54 +0200 Subject: [PATCH 2/2] Fix typo --- src/common/kustoChartHelper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/kustoChartHelper.ts b/src/common/kustoChartHelper.ts index 19e2415..93c504a 100644 --- a/src/common/kustoChartHelper.ts +++ b/src/common/kustoChartHelper.ts @@ -215,7 +215,7 @@ export class KustoChartHelper implements IChartHelper { let numberOfDefaultYAxes: number = 1; - // The y-axis is a single select when there is split-by, ot for Pie / Donut charts + // The y-axis is a single select when there is split-by, or for Pie / Donut charts if (chartType !== ChartType.Pie && chartType !== ChartType.Donut && !selectedSplitBy) { numberOfDefaultYAxes = KustoChartHelper.maxDefaultYAxesSelection; }