NHanser commented on code in PR #41859:
URL: https://github.com/apache/superset/pull/41859#discussion_r3544762824
##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx:
##########
@@ -63,6 +70,60 @@ const {
yAxisIndex,
} = DEFAULT_FORM_DATA;
+function hasBarSeriesInState(state: ControlPanelState | null): boolean {
+ const formData = state?.form_data;
+ const seriesA =
+ state?.controls?.seriesType?.value ?? formData?.seriesType ?? seriesType;
+ const seriesB =
+ state?.controls?.seriesTypeB?.value ?? formData?.seriesTypeB ?? seriesType;
+ return (
+ seriesA === EchartsTimeseriesSeriesType.Bar ||
+ seriesB === EchartsTimeseriesSeriesType.Bar
+ );
+}
+
+function isNumericXAxisState(state: ControlPanelState | null): boolean {
+ return checkColumnType(
+ getColumnLabel(state?.controls?.x_axis?.value as QueryFormColumn),
+ state?.controls?.datasource?.datasource,
+ [GenericDataType.Numeric],
+ );
+}
+
+const mixedXAxisForceCategoricalControl = {
+ ...xAxisForceCategoricalControl,
+ config: {
+ ...xAxisForceCategoricalControl.config,
+ description: t(
+ 'Treat values as categorical. Enabled by default when any query uses bar
series to prevent bar overflow and intermediate tick labels. Disable to use a
continuous numeric x-axis that preserves spacing for missing values.',
+ ),
+ initialValue: (control: ControlState, state: ControlPanelState | null) => {
+ if (!isNumericXAxisState(state)) {
+ return control.value;
+ }
+ if (state?.form_data?.x_axis_sort !== undefined) {
+ return true;
+ }
+ if (control?.value !== undefined) {
+ return control.value;
+ }
+ return hasBarSeriesInState(state);
Review Comment:
This is intentional: for Temporal x-axis we keep AxisType.Time unless
xAxisForceCategorical is explicitly enabled. mixedXAxisForceCategoricalControl
short-circuits for non-numeric x-axis, and getAxisType returns Time for
Temporal when forceCategorical is false. Bar rendering is protected for numeric
axes; Temporal stays time-scale
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]