From b5781a8ebe9376a2d4c8f181530abbf466b5aa90 Mon Sep 17 00:00:00 2001 From: Eric Radman Date: Tue, 25 Nov 2025 11:43:15 -0500 Subject: [PATCH] Add lineShape option for Line and Area charts (#7582) Linear Spline Horizontal-Vertical Vertical-Horizontal --- .../chart/Editor/GeneralSettings.tsx | 32 +++++++++++++++++++ .../src/visualizations/chart/getOptions.ts | 1 + .../prepareData/line-area/default.json | 4 ++- .../line-area/keep-missing-values.json | 5 ++- .../line-area/missing-values-0.json | 5 ++- .../line-area/normalized-stacked.json | 5 ++- .../prepareData/line-area/normalized.json | 5 ++- .../prepareData/line-area/stacked.json | 5 ++- .../chart/plotly/prepareDefaultData.ts | 6 ++++ 9 files changed, 62 insertions(+), 6 deletions(-) diff --git a/viz-lib/src/visualizations/chart/Editor/GeneralSettings.tsx b/viz-lib/src/visualizations/chart/Editor/GeneralSettings.tsx index 64455cd01..798484977 100644 --- a/viz-lib/src/visualizations/chart/Editor/GeneralSettings.tsx +++ b/viz-lib/src/visualizations/chart/Editor/GeneralSettings.tsx @@ -336,6 +336,38 @@ export default function GeneralSettings({ options, data, onOptionsChange }: any) )} + {includes(["line", "area"], options.globalSeriesType) && ( + // @ts-expect-error ts-migrate(2745) FIXME: This JSX tag's 'children' prop expects type 'never... Remove this comment to see the full error message +
+ +
+ )} + {!includes(["custom", "heatmap", "bubble"], options.globalSeriesType) && ( // @ts-expect-error ts-migrate(2745) FIXME: This JSX tag's 'children' prop expects type 'never... Remove this comment to see the full error message
diff --git a/viz-lib/src/visualizations/chart/getOptions.ts b/viz-lib/src/visualizations/chart/getOptions.ts index 6ede5bf82..dffafb1f4 100644 --- a/viz-lib/src/visualizations/chart/getOptions.ts +++ b/viz-lib/src/visualizations/chart/getOptions.ts @@ -18,6 +18,7 @@ const DEFAULT_OPTIONS = { coefficient: 1, piesort: true, color_scheme: "Redash", + lineShape: "linear", // showDataLabels: false, // depends on chart type numberFormat: "0,0[.]00000", diff --git a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/default.json b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/default.json index 8e12fe101..47c7fc4f0 100644 --- a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/default.json +++ b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/default.json @@ -20,7 +20,8 @@ "x": "x", "y1": "y" }, - "missingValuesAsZero": true + "missingValuesAsZero": true, + "lineShape": "linear" }, "data": [ { @@ -46,6 +47,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["10 ± 0", "20 ± 0", "30 ± 0", "40 ± 0"], + "line": { "shape": "linear" }, "marker": { "color": "red" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" diff --git a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/keep-missing-values.json b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/keep-missing-values.json index be49bec3d..795a51888 100644 --- a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/keep-missing-values.json +++ b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/keep-missing-values.json @@ -21,7 +21,8 @@ "x": "x", "y1": "y" }, - "missingValuesAsZero": false + "missingValuesAsZero": false, + "lineShape": "linear" }, "data": [ { @@ -54,6 +55,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["10 ± 0", "20 ± 0", "30 ± 0", "40 ± 0"], + "line": { "shape": "linear" }, "marker": { "color": "red" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" @@ -68,6 +70,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["", "2 ± 0", "", "4 ± 0"], + "line": { "shape": "linear" }, "marker": { "color": "blue" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" diff --git a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/missing-values-0.json b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/missing-values-0.json index e7d4a449a..7aedd4843 100644 --- a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/missing-values-0.json +++ b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/missing-values-0.json @@ -21,7 +21,8 @@ "x": "x", "y1": "y" }, - "missingValuesAsZero": true + "missingValuesAsZero": true, + "lineShape": "linear" }, "data": [ { @@ -54,6 +55,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["10 ± 0", "20 ± 0", "30 ± 0", "40 ± 0"], + "line": { "shape": "linear" }, "marker": { "color": "red" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" @@ -68,6 +70,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["0", "2 ± 0", "0", "4 ± 0"], + "line": { "shape": "linear" }, "marker": { "color": "blue" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" diff --git a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/normalized-stacked.json b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/normalized-stacked.json index 17776da78..f887aecf4 100644 --- a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/normalized-stacked.json +++ b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/normalized-stacked.json @@ -21,7 +21,8 @@ "x": "x", "y1": "y" }, - "missingValuesAsZero": true + "missingValuesAsZero": true, + "lineShape": "linear" }, "data": [ { @@ -56,6 +57,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["20% (10 ± 0)", "40% (20 ± 0)", "60% (30 ± 0)", "80% (40 ± 0)"], + "line": { "shape": "linear" }, "marker": { "color": "red" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" @@ -70,6 +72,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["80% (40 ± 0)", "60% (30 ± 0)", "40% (20 ± 0)", "20% (10 ± 0)"], + "line": { "shape": "linear" }, "marker": { "color": "blue" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" diff --git a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/normalized.json b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/normalized.json index 40e8b03c2..99748136a 100644 --- a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/normalized.json +++ b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/normalized.json @@ -21,7 +21,8 @@ "x": "x", "y1": "y" }, - "missingValuesAsZero": true + "missingValuesAsZero": true, + "lineShape": "linear" }, "data": [ { @@ -56,6 +57,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["20% (10 ± 0)", "40% (20 ± 0)", "60% (30 ± 0)", "80% (40 ± 0)"], + "line": { "shape": "linear" }, "marker": { "color": "red" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" @@ -70,6 +72,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["80% (40 ± 0)", "60% (30 ± 0)", "40% (20 ± 0)", "20% (10 ± 0)"], + "line": { "shape": "linear" }, "marker": { "color": "blue" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" diff --git a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/stacked.json b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/stacked.json index d6c2027e6..a0ba76da5 100644 --- a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/stacked.json +++ b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/line-area/stacked.json @@ -21,7 +21,8 @@ "x": "x", "y1": "y" }, - "missingValuesAsZero": true + "missingValuesAsZero": true, + "lineShape": "linear" }, "data": [ { @@ -56,6 +57,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["10 ± 0", "20 ± 0", "30 ± 0", "40 ± 0"], + "line": { "shape": "linear" }, "marker": { "color": "red" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" @@ -70,6 +72,7 @@ "hoverinfo": "text+x+name", "hover": [], "text": ["1 ± 0", "2 ± 0", "3 ± 0", "4 ± 0"], + "line": { "shape": "linear" }, "marker": { "color": "blue" }, "insidetextfont": { "color": "#ffffff" }, "yaxis": "y" diff --git a/viz-lib/src/visualizations/chart/plotly/prepareDefaultData.ts b/viz-lib/src/visualizations/chart/plotly/prepareDefaultData.ts index 9ff06f6a2..cf2d4ba6c 100644 --- a/viz-lib/src/visualizations/chart/plotly/prepareDefaultData.ts +++ b/viz-lib/src/visualizations/chart/plotly/prepareDefaultData.ts @@ -39,11 +39,17 @@ function prepareBarSeries(series: any, options: any, additionalOptions: any) { function prepareLineSeries(series: any, options: any) { series.mode = "lines" + (options.showDataLabels ? "+text" : ""); + series.line = { + shape: options.lineShape, + } return series; } function prepareAreaSeries(series: any, options: any) { series.mode = "lines" + (options.showDataLabels ? "+text" : ""); + series.line = { + shape: options.lineShape, + } series.fill = options.series.stacking ? "tonexty" : "tozeroy"; return series; }