mirror of
https://github.com/apache/superset.git
synced 2024-09-06 13:57:40 -04:00
fix(plugin-chart-echarts): xAxis scale is not correct when setting quarter time grain (#19686)
This commit is contained in:
parent
ee85466f2e
commit
059cb4ec25
@ -28,6 +28,7 @@ import {
|
||||
isFormulaAnnotationLayer,
|
||||
isIntervalAnnotationLayer,
|
||||
isTimeseriesAnnotationLayer,
|
||||
TimeGranularity,
|
||||
TimeseriesChartDataResponseResult,
|
||||
} from '@superset-ui/core';
|
||||
import { EChartsCoreOption, SeriesOption } from 'echarts';
|
||||
@ -69,6 +70,14 @@ import {
|
||||
} from './transformers';
|
||||
import { TIMESERIES_CONSTANTS } from '../constants';
|
||||
|
||||
const TimeGrainToTimestamp = {
|
||||
[TimeGranularity.HOUR]: 3600 * 1000,
|
||||
[TimeGranularity.DAY]: 3600 * 1000 * 24,
|
||||
[TimeGranularity.MONTH]: 3600 * 1000 * 24 * 31,
|
||||
[TimeGranularity.QUARTER]: 3600 * 1000 * 24 * 31 * 3,
|
||||
[TimeGranularity.YEAR]: 3600 * 1000 * 24 * 31 * 12,
|
||||
};
|
||||
|
||||
export default function transformProps(
|
||||
chartProps: EchartsTimeseriesChartProps,
|
||||
): TimeseriesChartTransformedProps {
|
||||
@ -126,6 +135,7 @@ export default function transformProps(
|
||||
yAxisTitleMargin,
|
||||
yAxisTitlePosition,
|
||||
sliceId,
|
||||
timeGrainSqla,
|
||||
}: EchartsTimeseriesFormData = { ...DEFAULT_FORM_DATA, ...formData };
|
||||
|
||||
const colorScale = CategoricalColorNamespace.getScale(colorScheme as string);
|
||||
@ -324,6 +334,10 @@ export default function transformProps(
|
||||
formatter: xAxisFormatter,
|
||||
rotate: xAxisLabelRotation,
|
||||
},
|
||||
minInterval:
|
||||
xAxisType === 'time' && timeGrainSqla
|
||||
? TimeGrainToTimestamp[timeGrainSqla]
|
||||
: 0,
|
||||
},
|
||||
yAxis: {
|
||||
...defaultYAxis,
|
||||
|
Loading…
Reference in New Issue
Block a user