fix: Date column in Heatmap is displayed as unix timestamp (#25009)
This commit is contained in:
parent
712e1f760c
commit
35eb66a322
|
|
@ -99,9 +99,16 @@ function Heatmap(element, props) {
|
||||||
xScaleInterval,
|
xScaleInterval,
|
||||||
yScaleInterval,
|
yScaleInterval,
|
||||||
yAxisBounds,
|
yAxisBounds,
|
||||||
|
xAxisFormatter,
|
||||||
|
yAxisFormatter,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const { records, extents } = data;
|
const { extents } = data;
|
||||||
|
const records = data.records.map(record => ({
|
||||||
|
...record,
|
||||||
|
x: xAxisFormatter(record.x),
|
||||||
|
y: yAxisFormatter(record.y),
|
||||||
|
}));
|
||||||
|
|
||||||
const margin = {
|
const margin = {
|
||||||
top: 10,
|
top: 10,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import {
|
||||||
sections,
|
sections,
|
||||||
sharedControls,
|
sharedControls,
|
||||||
getStandardizedControls,
|
getStandardizedControls,
|
||||||
|
D3_TIME_FORMAT_DOCS,
|
||||||
} from '@superset-ui/chart-controls';
|
} from '@superset-ui/chart-controls';
|
||||||
|
|
||||||
const sortAxisChoices = [
|
const sortAxisChoices = [
|
||||||
|
|
@ -257,6 +258,16 @@ const config: ControlPanelConfig = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
['y_axis_format'],
|
['y_axis_format'],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name: 'time_format',
|
||||||
|
config: {
|
||||||
|
...sharedControls.x_axis_time_format,
|
||||||
|
default: '%d/%m/%Y',
|
||||||
|
description: `${D3_TIME_FORMAT_DOCS}.`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
['currency_format'],
|
['currency_format'],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import { getValueFormatter } from '@superset-ui/core';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
|
@ -18,6 +16,12 @@ import { getValueFormatter } from '@superset-ui/core';
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
import {
|
||||||
|
GenericDataType,
|
||||||
|
getTimeFormatter,
|
||||||
|
getValueFormatter,
|
||||||
|
} from '@superset-ui/core';
|
||||||
|
|
||||||
export default function transformProps(chartProps) {
|
export default function transformProps(chartProps) {
|
||||||
const { width, height, formData, queriesData, datasource } = chartProps;
|
const { width, height, formData, queriesData, datasource } = chartProps;
|
||||||
const {
|
const {
|
||||||
|
|
@ -38,8 +42,10 @@ export default function transformProps(chartProps) {
|
||||||
yscaleInterval,
|
yscaleInterval,
|
||||||
yAxisBounds,
|
yAxisBounds,
|
||||||
yAxisFormat,
|
yAxisFormat,
|
||||||
|
timeFormat,
|
||||||
currencyFormat,
|
currencyFormat,
|
||||||
} = formData;
|
} = formData;
|
||||||
|
const { data = [], coltypes = [] } = queriesData[0];
|
||||||
const { columnFormats = {}, currencyFormats = {} } = datasource;
|
const { columnFormats = {}, currencyFormats = {} } = datasource;
|
||||||
const valueFormatter = getValueFormatter(
|
const valueFormatter = getValueFormatter(
|
||||||
metric,
|
metric,
|
||||||
|
|
@ -48,10 +54,18 @@ export default function transformProps(chartProps) {
|
||||||
yAxisFormat,
|
yAxisFormat,
|
||||||
currencyFormat,
|
currencyFormat,
|
||||||
);
|
);
|
||||||
|
const xAxisFormatter =
|
||||||
|
coltypes[0] === GenericDataType.TEMPORAL
|
||||||
|
? getTimeFormatter(timeFormat)
|
||||||
|
: String;
|
||||||
|
const yAxisFormatter =
|
||||||
|
coltypes[1] === GenericDataType.TEMPORAL
|
||||||
|
? getTimeFormatter(timeFormat)
|
||||||
|
: String;
|
||||||
return {
|
return {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
data: queriesData[0].data,
|
data,
|
||||||
bottomMargin,
|
bottomMargin,
|
||||||
canvasImageRendering,
|
canvasImageRendering,
|
||||||
colorScheme: linearColorScheme,
|
colorScheme: linearColorScheme,
|
||||||
|
|
@ -69,5 +83,7 @@ export default function transformProps(chartProps) {
|
||||||
yScaleInterval: parseInt(yscaleInterval, 10),
|
yScaleInterval: parseInt(yscaleInterval, 10),
|
||||||
yAxisBounds,
|
yAxisBounds,
|
||||||
valueFormatter,
|
valueFormatter,
|
||||||
|
xAxisFormatter,
|
||||||
|
yAxisFormatter,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue