Skip to content

Commit 436323d

Browse files
committed
[FIX] chart: tooltip has wrong format for date chart
The tooltip doesn't have the same format as the date format of the cells of the chart. We were missing the `tooltipFormat` option. closes #7275 Task: 5126261 X-original-commit: bdddbf0 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com> Signed-off-by: Adrien Minne (adrm) <adrm@odoo.com>
1 parent 4b19753 commit 436323d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/helpers/chart_date.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function getChartTimeOptions(
6464
parser: luxonFormat,
6565
displayFormats,
6666
unit: timeUnit ?? false,
67+
tooltipFormat: luxonFormat,
6768
};
6869
}
6970

tests/figures/chart/__snapshots__/chart_plugin.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ exports[`Linear/Time charts snapshot test of chartJS configuration for date char
273273
"day": "M/d/yyyy",
274274
},
275275
"parser": "M/d/yyyy",
276+
"tooltipFormat": "M/d/yyyy",
276277
"unit": "day",
277278
},
278279
"title": undefined,

tests/figures/chart/chart_plugin.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,9 +2660,15 @@ describe("Linear/Time charts", () => {
26602660
},
26612661
chartId
26622662
);
2663-
let config = getChartConfiguration(model, chartId);
2664-
expect(config.options?.scales?.x?.type).toEqual("time");
2665-
expect(config.options?.scales?.x?.ticks?.callback).toBeUndefined();
2663+
const scale = getChartConfiguration(model, chartId).options.scales.x;
2664+
expect(scale.type).toEqual("time");
2665+
expect(scale.ticks?.callback).toBeUndefined();
2666+
expect(scale.time).toEqual({
2667+
displayFormats: { day: "M/d/yyyy" }, // luxon format
2668+
parser: "M/d/yyyy",
2669+
tooltipFormat: "M/d/yyyy",
2670+
unit: "day",
2671+
});
26662672
});
26672673

26682674
test("time axis for line/bar chart with formulas w/ date format as labels", () => {

0 commit comments

Comments
 (0)