From d981844addddff4df56970a93c3e161ac66aed5a Mon Sep 17 00:00:00 2001 From: Mohammed Faiyyaz Khatri Date: Thu, 29 May 2025 17:28:50 +0530 Subject: [PATCH 1/3] Update LineChart.tsx yAxisPosition for label position --- src/line-chart/LineChart.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/line-chart/LineChart.tsx b/src/line-chart/LineChart.tsx index 895e911a..dcd4c6af 100644 --- a/src/line-chart/LineChart.tsx +++ b/src/line-chart/LineChart.tsx @@ -214,6 +214,10 @@ export interface LineChartProps extends AbstractChartProps { * The number of horizontal lines */ segments?: number; + /** + * The position of y axis + */ + yAxisPosition?: 'left' | 'right'; } type LineChartState = { @@ -815,7 +819,8 @@ class LineChart extends AbstractChart { formatXLabel = xLabel => xLabel, segments, transparent = false, - chartConfig + chartConfig, + yAxisPosition, } = this.props; const { scrollableDotHorizontalOffset } = this.state; @@ -893,7 +898,8 @@ class LineChart extends AbstractChart { paddingTop: paddingTop as number, paddingRight: paddingRight as number, formatYLabel, - decimalPlaces: chartConfig.decimalPlaces + decimalPlaces: chartConfig.decimalPlaces. + yAxisPosition: yAxisPosition, })} From 9e2558a2f42d50cf2e879800e1237d8dd998dd19 Mon Sep 17 00:00:00 2001 From: Mohammed Faiyyaz Khatri Date: Thu, 29 May 2025 17:30:26 +0530 Subject: [PATCH 2/3] yAxisPosition for y axis label --- src/AbstractChart.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/AbstractChart.tsx b/src/AbstractChart.tsx index 4f7b124f..f0a2f718 100644 --- a/src/AbstractChart.tsx +++ b/src/AbstractChart.tsx @@ -32,6 +32,7 @@ export interface AbstractChartConfig extends ChartConfig { formatXLabel?: (xLabel: string) => string; verticalLabelsHeightPercentage?: number; formatTopBarValue?: (topBarValue: number) => string | number; + yAxisPosition?: 'left' | 'right'; } export type AbstractChartState = {}; @@ -140,7 +141,7 @@ class AbstractChart< height, paddingTop, paddingRight, - verticalLabelsHeightPercentage = DEFAULT_X_LABELS_HEIGHT_PERCENTAGE + verticalLabelsHeightPercentage = DEFAULT_X_LABELS_HEIGHT_PERCENTAGE, } = config; const basePosition = height * verticalLabelsHeightPercentage; @@ -191,7 +192,9 @@ class AbstractChart< horizontalLabelRotation = 0, decimalPlaces = 2, formatYLabel = (yLabel: string) => yLabel, - verticalLabelsHeightPercentage = DEFAULT_X_LABELS_HEIGHT_PERCENTAGE + verticalLabelsHeightPercentage = DEFAULT_X_LABELS_HEIGHT_PERCENTAGE, + yAxisPosition = 'left', + width } = config; const { @@ -216,7 +219,10 @@ class AbstractChart< } const basePosition = height * verticalLabelsHeightPercentage; - const x = paddingRight - yLabelsOffset; + const x = + yAxisPosition === 'left' + ? paddingRight - yLabelsOffset + : width - (yLabelsOffset - 10); const y = count === 1 && this.props.fromZero ? paddingTop + 4 From 8c00353d817d4444130080e8c2411a10aafb7f26 Mon Sep 17 00:00:00 2001 From: Mohammed Faiyyaz Khatri Date: Mon, 2 Jun 2025 18:45:51 +0530 Subject: [PATCH 3/3] Build issue fixed for LineChart --- src/line-chart/LineChart.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/line-chart/LineChart.tsx b/src/line-chart/LineChart.tsx index dcd4c6af..4d890248 100644 --- a/src/line-chart/LineChart.tsx +++ b/src/line-chart/LineChart.tsx @@ -898,7 +898,7 @@ class LineChart extends AbstractChart { paddingTop: paddingTop as number, paddingRight: paddingRight as number, formatYLabel, - decimalPlaces: chartConfig.decimalPlaces. + decimalPlaces: chartConfig.decimalPlaces, yAxisPosition: yAxisPosition, })}