mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat: Floating Point Formatting for Scatter Point Chart (#35915)
Co-authored-by: Vincent <vincent.trung4@gmail.com>
This commit is contained in:
@@ -112,6 +112,53 @@ const config: ControlPanelConfig = {
|
||||
...sharedControls.x_axis_time_format,
|
||||
default: 'smart_date',
|
||||
description: `${D3_TIME_FORMAT_DOCS}. ${TIME_SERIES_DESCRIPTION_TEXT}`,
|
||||
visibility: ({ controls }: ControlPanelsContainerProps) => {
|
||||
// check if x axis is a time column
|
||||
const xAxisColumn = controls?.x_axis?.value;
|
||||
const xAxisOptions = controls?.x_axis?.options;
|
||||
|
||||
if (!xAxisColumn || !Array.isArray(xAxisOptions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const xAxisType = xAxisOptions.find(
|
||||
option => option.column_name === xAxisColumn,
|
||||
)?.type;
|
||||
|
||||
return (
|
||||
typeof xAxisType === 'string' &&
|
||||
xAxisType.toUpperCase().includes('TIME')
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'x_axis_number_format',
|
||||
config: {
|
||||
...sharedControls.x_axis_number_format,
|
||||
visibility: ({ controls }: ControlPanelsContainerProps) => {
|
||||
// check if x axis is a floating-point column
|
||||
const xAxisColumn = controls?.x_axis?.value;
|
||||
const xAxisOptions = controls?.x_axis?.options;
|
||||
|
||||
if (!xAxisColumn || !Array.isArray(xAxisOptions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const xAxisType = xAxisOptions.find(
|
||||
option => option.column_name === xAxisColumn,
|
||||
)?.type;
|
||||
|
||||
if (typeof xAxisType !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const typeUpper = xAxisType.toUpperCase();
|
||||
|
||||
return ['FLOAT', 'DOUBLE', 'REAL', 'NUMERIC', 'DECIMAL'].some(
|
||||
t => typeUpper.includes(t),
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -72,6 +72,7 @@ export const DEFAULT_FORM_DATA: EchartsTimeseriesFormData = {
|
||||
stack: false,
|
||||
tooltipTimeFormat: 'smart_date',
|
||||
xAxisTimeFormat: 'smart_date',
|
||||
xAxisNumberFormat: 'SMART_NUMBER',
|
||||
truncateXAxis: true,
|
||||
truncateYAxis: false,
|
||||
yAxisBounds: [null, null],
|
||||
|
||||
@@ -189,6 +189,7 @@ export default function transformProps(
|
||||
xAxisSort,
|
||||
xAxisSortAsc,
|
||||
xAxisTimeFormat,
|
||||
xAxisNumberFormat,
|
||||
xAxisTitle,
|
||||
xAxisTitleMargin,
|
||||
yAxisBounds,
|
||||
@@ -485,7 +486,9 @@ export default function transformProps(
|
||||
const xAxisFormatter =
|
||||
xAxisDataType === GenericDataType.Temporal
|
||||
? getXAxisFormatter(xAxisTimeFormat)
|
||||
: String;
|
||||
: xAxisDataType === GenericDataType.Numeric
|
||||
? getNumberFormatter(xAxisNumberFormat)
|
||||
: String;
|
||||
|
||||
const {
|
||||
setDataMask = () => {},
|
||||
|
||||
@@ -84,6 +84,7 @@ export type EchartsTimeseriesFormData = QueryFormData & {
|
||||
yAxisFormat?: string;
|
||||
xAxisForceCategorical?: boolean;
|
||||
xAxisTimeFormat?: string;
|
||||
xAxisNumberFormat?: string;
|
||||
timeGrainSqla?: TimeGranularity;
|
||||
forceMaxInterval?: boolean;
|
||||
xAxisBounds: [number | undefined | null, number | undefined | null];
|
||||
|
||||
Reference in New Issue
Block a user