Skip to content

Commit 785707a

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 #7226 Task: 5126261 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
1 parent c8f1120 commit 785707a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
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
@@ -201,6 +201,7 @@ exports[`Linear/Time charts snapshot test of chartJS configuration for date char
201201
"day": "M/d/yyyy",
202202
},
203203
"parser": "M/d/yyyy",
204+
"tooltipFormat": "M/d/yyyy",
204205
"unit": "day",
205206
},
206207
"type": "time",

tests/figures/chart/chart_plugin.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,12 +1908,14 @@ describe("Linear/Time charts", () => {
19081908
},
19091909
chartId
19101910
);
1911-
let chart = (model.getters.getChartRuntime(chartId) as LineChartRuntime).chartJsConfig;
1912-
expect(chart.options?.scales?.x?.type).toEqual("time");
1913-
1914-
updateChart(model, chartId, { type: "bar" });
1915-
model.getters.getChartRuntime(chartId)!;
1916-
expect(chart.options?.scales?.x?.type).toEqual("time");
1911+
const scale = (model.getters.getChartRuntime(chartId) as any).chartJsConfig.options.scales.x;
1912+
expect(scale.type).toEqual("time");
1913+
expect(scale.time).toEqual({
1914+
displayFormats: { day: "M/d/yyyy" }, // luxon format
1915+
parser: "M/d/yyyy",
1916+
tooltipFormat: "M/d/yyyy",
1917+
unit: "day",
1918+
});
19171919
});
19181920

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

0 commit comments

Comments
 (0)