Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Date column in Heatmap is displayed as unix timestamp #25009

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,16 @@ function Heatmap(element, props) {
xScaleInterval,
yScaleInterval,
yAxisBounds,
xAxisFormatter,
yAxisFormatter,
} = 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 = {
top: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
sections,
sharedControls,
getStandardizedControls,
D3_TIME_FORMAT_DOCS,
} from '@superset-ui/chart-controls';

const sortAxisChoices = [
Expand Down Expand Up @@ -257,6 +258,16 @@ const config: ControlPanelConfig = {
},
],
['y_axis_format'],
[
{
name: 'time_format',
config: {
...sharedControls.x_axis_time_format,
default: '%d/%m/%Y',
description: `${D3_TIME_FORMAT_DOCS}.`,
},
},
],
['currency_format'],
[
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { getValueFormatter } from '@superset-ui/core';

/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,6 +16,12 @@ import { getValueFormatter } from '@superset-ui/core';
* specific language governing permissions and limitations
* under the License.
*/
import {
GenericDataType,
getTimeFormatter,
getValueFormatter,
} from '@superset-ui/core';

export default function transformProps(chartProps) {
const { width, height, formData, queriesData, datasource } = chartProps;
const {
Expand All @@ -38,8 +42,10 @@ export default function transformProps(chartProps) {
yscaleInterval,
yAxisBounds,
yAxisFormat,
timeFormat,
currencyFormat,
} = formData;
const { data = [], coltypes = [] } = queriesData[0];
const { columnFormats = {}, currencyFormats = {} } = datasource;
const valueFormatter = getValueFormatter(
metric,
Expand All @@ -48,10 +54,18 @@ export default function transformProps(chartProps) {
yAxisFormat,
currencyFormat,
);
const xAxisFormatter =
coltypes[0] === GenericDataType.TEMPORAL
? getTimeFormatter(timeFormat)
: String;
const yAxisFormatter =
coltypes[1] === GenericDataType.TEMPORAL
? getTimeFormatter(timeFormat)
: String;
return {
width,
height,
data: queriesData[0].data,
data,
bottomMargin,
canvasImageRendering,
colorScheme: linearColorScheme,
Expand All @@ -69,5 +83,7 @@ export default function transformProps(chartProps) {
yScaleInterval: parseInt(yscaleInterval, 10),
yAxisBounds,
valueFormatter,
xAxisFormatter,
yAxisFormatter,
};
}
Loading