You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by en...@apache.org on 2026/07/03 08:59:19 UTC
(superset) branch master updated: fix(plugin-chart-echarts): prevent trendline stroke clipping at chart edges (#37918)
This is an automated email from the ASF dual-hosted git repository.
EnxDev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 4f37e955b54 fix(plugin-chart-echarts): prevent trendline stroke clipping at chart edges (#37918)
4f37e955b54 is described below
commit 4f37e955b54704324cd476d82facfd6d06b88d98
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Fri Jul 3 01:59:13 2026 -0700
fix(plugin-chart-echarts): prevent trendline stroke clipping at chart edges (#37918)
Co-authored-by: Amin Ghadersohi <am...@gmail.com>
Co-authored-by: Claude Opus 4.5 <no...@anthropic.com>
Co-authored-by: Enzo Martellucci <en...@gmail.com>
Co-authored-by: Evan Rusackas <ev...@preset.io>
Co-authored-by: Enzo Martellucci <52...@users.noreply.github.com>
Co-authored-by: Joe Li <jo...@preset.io>
---
.../BigNumber/BigNumberWithTrendline/transformProps.ts | 16 ++++++++++++----
.../test/BigNumber/transformProps.test.ts | 16 ++++++++++++----
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
index 23708f7a41c..fa57d2a8b71 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
@@ -282,6 +282,11 @@ export default function transformProps(
? formatTime
: numberFormatter;
+ const lineWidth = 2;
+ // Pad the grid by half the stroke width so the trendline isn't clipped at
+ // the edges of the chart area (the stroke extends beyond the data point).
+ const strokePad = lineWidth / 2;
+
const echartOptions: EChartsCoreOption = trendLineData
? {
series: [
@@ -293,6 +298,9 @@ export default function transformProps(
symbolSize: 10,
showSymbol: false,
color: mainColor ?? BRAND_COLOR,
+ lineStyle: {
+ width: lineWidth,
+ },
areaStyle: {
color: new graphic.LinearGradient(0, 0, 0, 1, [
{
@@ -346,10 +354,10 @@ export default function transformProps(
top: TIMESERIES_CONSTANTS.gridOffsetTop,
}
: {
- bottom: 0,
- left: 0,
- right: 0,
- top: 0,
+ bottom: strokePad,
+ left: strokePad,
+ right: strokePad,
+ top: strokePad,
},
tooltip: {
...getDefaultTooltip(refs),
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts
index 08912e4cbfb..7bd49f2c36f 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts
@@ -17,6 +17,7 @@
* under the License.
*/
import { DatasourceType, TimeGranularity, VizType } from '@superset-ui/core';
+import type { LineSeriesOption } from 'echarts';
import { supersetTheme } from '@apache-superset/core/theme';
import transformProps from '../../src/BigNumber/BigNumberWithTrendline/transformProps';
import {
@@ -269,11 +270,18 @@ describe('BigNumberWithTrendline', () => {
},
});
+ const series = (
+ transformed.echartOptions?.series as LineSeriesOption[]
+ )?.[0];
+ const lineWidth = series?.lineStyle?.width;
+ expect(lineWidth).toBe(2);
+
+ const expectedPad = (lineWidth as number) / 2;
expect(transformed.echartOptions?.grid).toEqual({
- bottom: 0,
- left: 0,
- right: 0,
- top: 0,
+ bottom: expectedPad,
+ left: expectedPad,
+ right: expectedPad,
+ top: expectedPad,
});
});