You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2025/09/11 03:27:29 UTC
(superset) branch master updated: feat(Timeseries & MixedTimeseries): Force selected timegrain on timeseries intervals when the x-axis is of timestamp type (#34595)
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin 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 eb4351af83 feat(Timeseries & MixedTimeseries): Force selected timegrain on timeseries intervals when the x-axis is of timestamp type (#34595)
eb4351af83 is described below
commit eb4351af83c43649e248d491ad6522b043c651c4
Author: Devanjan Banerjee <92...@users.noreply.github.com>
AuthorDate: Thu Sep 11 08:57:23 2025 +0530
feat(Timeseries & MixedTimeseries): Force selected timegrain on timeseries intervals when the x-axis is of timestamp type (#34595)
---
.../src/MixedTimeseries/controlPanel.tsx | 2 ++
.../src/MixedTimeseries/transformProps.ts | 9 ++++++++-
.../plugin-chart-echarts/src/MixedTimeseries/types.ts | 1 +
.../src/Timeseries/Area/controlPanel.tsx | 2 ++
.../src/Timeseries/Regular/Bar/controlPanel.tsx | 2 ++
.../src/Timeseries/Regular/Line/controlPanel.tsx | 2 ++
.../src/Timeseries/Regular/Scatter/controlPanel.tsx | 2 ++
.../src/Timeseries/Regular/SmoothLine/controlPanel.tsx | 2 ++
.../src/Timeseries/Step/controlPanel.tsx | 2 ++
.../plugin-chart-echarts/src/Timeseries/transformProps.ts | 9 ++++++++-
.../plugins/plugin-chart-echarts/src/Timeseries/types.ts | 1 +
.../plugins/plugin-chart-echarts/src/controls.tsx | 15 +++++++++++++++
12 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx
index 7a20c9393d..a4b0ca7c42 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx
@@ -42,6 +42,7 @@ import {
xAxisBounds,
xAxisLabelRotation,
xAxisLabelInterval,
+ forceMaxInterval,
} from '../controls';
const {
@@ -358,6 +359,7 @@ const config: ControlPanelConfig = {
['x_axis_time_format'],
[xAxisLabelRotation],
[xAxisLabelInterval],
+ [forceMaxInterval],
[<ControlSubSectionHeader>{t('Tooltip')}</ControlSubSectionHeader>],
[
{
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
index e80a5df36d..29be1a39fc 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
@@ -214,6 +214,7 @@ export default function transformProps(
sortSeriesAscending,
sortSeriesAscendingB,
timeGrainSqla,
+ forceMaxInterval,
percentageThreshold,
showQueryIdentifiers = false,
metrics = [],
@@ -583,11 +584,17 @@ export default function transformProps(
},
minorTick: { show: minorTicks },
minInterval:
- xAxisType === AxisType.Time && timeGrainSqla
+ xAxisType === AxisType.Time && timeGrainSqla && !forceMaxInterval
? TIMEGRAIN_TO_TIMESTAMP[
timeGrainSqla as keyof typeof TIMEGRAIN_TO_TIMESTAMP
]
: 0,
+ maxInterval:
+ xAxisType === AxisType.Time && timeGrainSqla && forceMaxInterval
+ ? TIMEGRAIN_TO_TIMESTAMP[
+ timeGrainSqla as keyof typeof TIMEGRAIN_TO_TIMESTAMP
+ ]
+ : undefined,
...getMinAndMaxFromBounds(
xAxisType,
truncateXAxis,
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts
index d73a1c2c07..fe1bee9e41 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts
@@ -57,6 +57,7 @@ export type EchartsMixedTimeseriesFormData = QueryFormData & {
truncateYAxis: boolean;
truncateYAxisSecondary: boolean;
timeGrainSqla?: TimeGranularity;
+ forceMaxInterval?: boolean;
tooltipTimeFormat?: string;
zoomable: boolean;
richTooltip: boolean;
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Area/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Area/controlPanel.tsx
index f3e40cb1dc..5b51242490 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Area/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Area/controlPanel.tsx
@@ -41,6 +41,7 @@ import {
truncateXAxis,
xAxisBounds,
minorTicks,
+ forceMaxInterval,
} from '../../controls';
import { AreaChartStackControlOptions } from '../../constants';
@@ -185,6 +186,7 @@ const config: ControlPanelConfig = {
],
[xAxisLabelRotation],
[xAxisLabelInterval],
+ [forceMaxInterval],
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
[<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx
index a2032d3967..9a26c3e8a6 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx
@@ -39,6 +39,7 @@ import {
xAxisBounds,
xAxisLabelRotation,
xAxisLabelInterval,
+ forceMaxInterval,
} from '../../../controls';
import { OrientationType } from '../../types';
@@ -364,6 +365,7 @@ const config: ControlPanelConfig = {
...createAxisControl('x'),
[truncateXAxis],
[xAxisBounds],
+ [forceMaxInterval],
...richTooltipSection,
[<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
...createAxisControl('y'),
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Line/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Line/controlPanel.tsx
index 2553fe48d3..148bc966b1 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Line/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Line/controlPanel.tsx
@@ -42,6 +42,7 @@ import {
xAxisBounds,
xAxisLabelRotation,
xAxisLabelInterval,
+ forceMaxInterval,
} from '../../../controls';
const {
@@ -173,6 +174,7 @@ const config: ControlPanelConfig = {
],
[xAxisLabelRotation],
[xAxisLabelInterval],
+ [forceMaxInterval],
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
[<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/controlPanel.tsx
index b9bca7ca5c..bf23eadd61 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/controlPanel.tsx
@@ -41,6 +41,7 @@ import {
xAxisBounds,
xAxisLabelRotation,
xAxisLabelInterval,
+ forceMaxInterval,
} from '../../../controls';
const {
@@ -116,6 +117,7 @@ const config: ControlPanelConfig = {
],
[xAxisLabelRotation],
[xAxisLabelInterval],
+ [forceMaxInterval],
// eslint-disable-next-line react/jsx-key
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/SmoothLine/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/SmoothLine/controlPanel.tsx
index d25fbbd566..00ea73742f 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/SmoothLine/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/SmoothLine/controlPanel.tsx
@@ -41,6 +41,7 @@ import {
xAxisBounds,
xAxisLabelRotation,
xAxisLabelInterval,
+ forceMaxInterval,
} from '../../../controls';
const {
@@ -115,6 +116,7 @@ const config: ControlPanelConfig = {
],
[xAxisLabelRotation],
[xAxisLabelInterval],
+ [forceMaxInterval],
// eslint-disable-next-line react/jsx-key
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/controlPanel.tsx
index a59ec06b34..cf2a8598e1 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/controlPanel.tsx
@@ -39,6 +39,7 @@ import {
xAxisBounds,
xAxisLabelRotation,
xAxisLabelInterval,
+ forceMaxInterval,
} from '../../controls';
const {
@@ -167,6 +168,7 @@ const config: ControlPanelConfig = {
],
[xAxisLabelRotation],
[xAxisLabelInterval],
+ [forceMaxInterval],
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
[<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
index abde2dabbe..4e07a8410d 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
@@ -168,6 +168,7 @@ export default function transformProps(
sortSeriesType,
sortSeriesAscending,
timeGrainSqla,
+ forceMaxInterval,
timeCompare,
timeShiftColor,
stack,
@@ -510,11 +511,17 @@ export default function transformProps(
},
minorTick: { show: minorTicks },
minInterval:
- xAxisType === AxisType.Time && timeGrainSqla
+ xAxisType === AxisType.Time && timeGrainSqla && !forceMaxInterval
? TIMEGRAIN_TO_TIMESTAMP[
timeGrainSqla as keyof typeof TIMEGRAIN_TO_TIMESTAMP
]
: 0,
+ maxInterval:
+ xAxisType === AxisType.Time && timeGrainSqla && forceMaxInterval
+ ? TIMEGRAIN_TO_TIMESTAMP[
+ timeGrainSqla as keyof typeof TIMEGRAIN_TO_TIMESTAMP
+ ]
+ : undefined,
...getMinAndMaxFromBounds(
xAxisType,
truncateXAxis,
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts
index 76f8b6387f..72ea97019e 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts
@@ -85,6 +85,7 @@ export type EchartsTimeseriesFormData = QueryFormData & {
xAxisForceCategorical?: boolean;
xAxisTimeFormat?: string;
timeGrainSqla?: TimeGranularity;
+ forceMaxInterval?: boolean;
xAxisBounds: [number | undefined | null, number | undefined | null];
yAxisBounds: [number | undefined | null, number | undefined | null];
zoomable: boolean;
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/controls.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/controls.tsx
index 071e748903..488ae5ef2e 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/controls.tsx
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/controls.tsx
@@ -338,6 +338,21 @@ export const xAxisLabelInterval = {
},
};
+export const forceMaxInterval = {
+ name: 'force_max_interval',
+ config: {
+ type: 'CheckboxControl',
+ label: t('Force Time Grain as Max Interval'),
+ renderTrigger: true,
+ default: false,
+ description: t(
+ 'Forces selected Time Grain as the maximum interval for X Axis Labels',
+ ),
+ visibility: ({ controls }: ControlPanelsContainerProps) =>
+ Boolean(controls?.time_grain_sqla?.value),
+ },
+};
+
export const seriesOrderSection: ControlSetRow[] = [
[<ControlSubSectionHeader>{t('Series Order')}</ControlSubSectionHeader>],
[sortSeriesType],