Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

UXW-5343 Fix missing first x-axis label (#83680)

Denis Berezin40efedabf497
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stack_All_Series_Without_Interpolation.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stack_All_Series_Without_Interpolation.png
index 3a8d46bb93b..b4016aca032 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stack_All_Series_Without_Interpolation.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stack_All_Series_Without_Interpolation.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stack_Interpolate_Missing_Values.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stack_Interpolate_Missing_Values.png
index 775b5b95a98..7d831089017 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stack_Interpolate_Missing_Values.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stack_Interpolate_Missing_Values.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stacked_Auto_Data_Labels.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stacked_Auto_Data_Labels.png
index d1c0364aa5c..e777b8f3747 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stacked_Auto_Data_Labels.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Area_Stacked_Auto_Data_Labels.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Between_Extent_And_Chart_Bound.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Between_Extent_And_Chart_Bound.png
index 4999d609a5f..5487bc85c01 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Between_Extent_And_Chart_Bound.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Between_Extent_And_Chart_Bound.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Line_Disabled.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Line_Disabled.png
index e52972d3b59..adf0298f6df 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Line_Disabled.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Line_Disabled.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Line_Out_Of_Bounds_37848.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Line_Out_Of_Bounds_37848.png
index 75a64ce1a00..f542f7832b3 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Line_Out_Of_Bounds_37848.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Line_Out_Of_Bounds_37848.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Very_Small.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Very_Small.png
index e54d20c2c07..691eecfd94b 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Very_Small.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Goal_Very_Small.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Image_Cut_Off_37275.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Image_Cut_Off_37275.png
index c14748c42ac..2e9c9774acd 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Image_Cut_Off_37275.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Image_Cut_Off_37275.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Incorrect_Label_Y_Axis_Split_41285.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Incorrect_Label_Y_Axis_Split_41285.png
index 2e1fe90a738..9a28b24d1f9 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Incorrect_Label_Y_Axis_Split_41285.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Incorrect_Label_Y_Axis_Split_41285.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Equals_Extents.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Equals_Extents.png
index c2a6fd69050..93d8946fb8f 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Equals_Extents.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Equals_Extents.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Off_Screen_High.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Off_Screen_High.png
index ef68f86586c..55d4afb8528 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Off_Screen_High.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Off_Screen_High.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Off_Screen_Low.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Off_Screen_Low.png
index 41adc236d39..77b59b67520 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Off_Screen_Low.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Custom_Y_Axis_Range_Off_Screen_Low.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_Auto.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_Auto.png
index e52972d3b59..adf0298f6df 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_Auto.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_Auto.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_Off.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_Off.png
index e52972d3b59..adf0298f6df 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_Off.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_Off.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_On.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_On.png
index a244a528068..8e145a5ee05 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_On.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Show_Dots_On.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Unpin_From_Zero.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Unpin_From_Zero.png
index b18c0fd7db9..142ef268c8c 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Unpin_From_Zero.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Line_Unpin_From_Zero.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Number_Of_Insights_Error_39608.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Number_Of_Insights_Error_39608.png
index 8173defd3e3..8f1aeb9321d 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Number_Of_Insights_Error_39608.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Number_Of_Insights_Error_39608.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Offset_Based_Timezone_47835.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Offset_Based_Timezone_47835.png
index 5db0a23dfe9..fb2e0616f37 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Offset_Based_Timezone_47835.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Offset_Based_Timezone_47835.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Time_Series_Yyyymmdd_Numbers_Format.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Time_Series_Yyyymmdd_Numbers_Format.png
index 67bb9f80b70..66f1e95055d 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Time_Series_Yyyymmdd_Numbers_Format.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Time_Series_Yyyymmdd_Numbers_Format.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo.png
index 8750e5e86b2..bfb43e5d259 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo_Log.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo_Log.png
index ddbf725fd9f..ba6d08d48e2 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo_Log.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo_Log.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo_Power.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo_Power.png
index 7a03e6c2695..b32c81c0681 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo_Power.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Combo_Power.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Bar.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Bar.png
index 4789a8147a4..39a624b80e1 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Bar.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Bar.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Normalized_Stacked_Bar.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Normalized_Stacked_Bar.png
index 1e7d979b51a..b1a7e4e44dd 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Normalized_Stacked_Bar.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Normalized_Stacked_Bar.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Stacked_Bar.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Stacked_Bar.png
index a356feb51dc..8f896493f04 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Stacked_Bar.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Multi_Series_Stacked_Bar.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Single_Series_Bar.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Single_Series_Bar.png
index c11bb0a46df..52fe601ccf4 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Single_Series_Bar.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ComboChart_Trend_Single_Series_Bar.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Auto_Y_Axis_Exclude_Zero_With_Goal.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Auto_Y_Axis_Exclude_Zero_With_Goal.png
index 102a9814e2c..88788630c96 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Auto_Y_Axis_Exclude_Zero_With_Goal.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Auto_Y_Axis_Exclude_Zero_With_Goal.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Timeseries_X_Scale.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Timeseries_X_Scale.png
index d453e51b1a8..8d910f4e202 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Timeseries_X_Scale.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_ScatterPlot_Timeseries_X_Scale.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Data_Labels_Timeseries.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Data_Labels_Timeseries.png
index da210d981fa..488ccb8f6db 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Data_Labels_Timeseries.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Data_Labels_Timeseries.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Enourmous_Dataset.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Enourmous_Dataset.png
index a901cc29752..f5a5162d677 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Enourmous_Dataset.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Enourmous_Dataset.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Log_Y_Scale.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Log_Y_Scale.png
index 3c245d29796..524270406f2 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Log_Y_Scale.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Log_Y_Scale.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Log_Y_Scale_Negative.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Log_Y_Scale_Negative.png
index 545faaf7f0f..26049df587c 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Log_Y_Scale_Negative.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Log_Y_Scale_Negative.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Native_Time_Series_Quarter.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Native_Time_Series_Quarter.png
index 680b7233bbb..86669c0fb7e 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Native_Time_Series_Quarter.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Native_Time_Series_Quarter.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Native_Time_Series_With_Gaps.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Native_Time_Series_With_Gaps.png
index 92f2dae28df..f26ce0c59df 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Native_Time_Series_With_Gaps.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Native_Time_Series_With_Gaps.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Negative_Only.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Negative_Only.png
index 3bee6416b10..2fa4ed5a690 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Negative_Only.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Negative_Only.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_No_Total_Timeseries.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_No_Total_Timeseries.png
index ea5c7b99d16..2034bdc6323 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_No_Total_Timeseries.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_No_Total_Timeseries.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Pow_Y_Scale_Negative_Only.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Pow_Y_Scale_Negative_Only.png
index 545faaf7f0f..26049df587c 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Pow_Y_Scale_Negative_Only.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Pow_Y_Scale_Negative_Only.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Timeseries_X_Scale.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Timeseries_X_Scale.png
index 8962a29511f..2737a4dddbf 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Timeseries_X_Scale.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Timeseries_X_Scale.png differ
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Timeseries_X_Scale_Unsorted.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Timeseries_X_Scale_Unsorted.png
index 8962a29511f..2737a4dddbf 100644
Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Timeseries_X_Scale_Unsorted.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_WaterfallChart_Timeseries_X_Scale_Unsorted.png differ
diff --git a/e2e/test/scenarios/binning/binning-options.cy.spec.js b/e2e/test/scenarios/binning/binning-options.cy.spec.js
index d9aa44a3ff0..a98b30319fa 100644
--- a/e2e/test/scenarios/binning/binning-options.cy.spec.js
+++ b/e2e/test/scenarios/binning/binning-options.cy.spec.js
@@ -92,7 +92,7 @@ describe("scenarios > binning > binning options", () => {
getTitle("Count by Created At: Quarter");
H.cartesianChartCircle();
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Q1 2026");
+ cy.findByText("Q2 2026");
});
it("should render and apply longitude/latitude binning options", () => {
@@ -183,7 +183,7 @@ describe("scenarios > binning > binning options", () => {
getTitle("Count by Created At: Quarter");
H.cartesianChartCircle();
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Q1 2026");
+ cy.findByText("Q2 2026");
});
it("should render and apply longitude/latitude binning options", () => {
@@ -238,7 +238,7 @@ describe("scenarios > binning > binning options", () => {
H.cartesianChartCircle();
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("January 2026");
+ cy.findByText("April 2026");
cy.log(
"time series footer highlights the current bucket (metabase#11183)",
diff --git a/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js b/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js
index b22ab7c4e1f..a1b5d4c2d29 100644
--- a/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashcard-click-behavior.cy.spec.js
@@ -580,7 +580,7 @@ describe("scenarios > dashboard > dashboard cards > click behavior", () => {
H.modal().button("Discard changes").click();
cy.button("Cancel").should("not.exist");
cy.findByTestId("visualization-root")
- .findByText("May 2025")
+ .findByText("April 2025")
.should("exist");
clickLineChartPoint();
cy.get("@targetDashboardId").then((targetDashboardId) => {
diff --git a/e2e/test/scenarios/question/offset.cy.spec.ts b/e2e/test/scenarios/question/offset.cy.spec.ts
index 1bce5879fb1..35ec0acf055 100644
--- a/e2e/test/scenarios/question/offset.cy.spec.ts
+++ b/e2e/test/scenarios/question/offset.cy.spec.ts
@@ -294,7 +294,7 @@ describe("scenarios > question > offset", () => {
H.visualize();
H.echartsContainer().within(() => {
- cy.contains("January 2027").should("be.visible");
+ cy.contains("April 2027").should("be.visible");
});
verifyLineChart({
xAxis: "Created At: Month",
diff --git a/e2e/test/scenarios/question/reproductions-3.cy.spec.js b/e2e/test/scenarios/question/reproductions-3.cy.spec.js
index 2857ce3a51c..9958b9382ee 100644
--- a/e2e/test/scenarios/question/reproductions-3.cy.spec.js
+++ b/e2e/test/scenarios/question/reproductions-3.cy.spec.js
@@ -718,9 +718,9 @@ describe("issue 44532", () => {
cy.findByText("Created At: Month").should("exist"); // x-axis
// x-axis values
- cy.findByText("January 2026").should("exist");
- cy.findByText("January 2027").should("exist");
- cy.findByText("January 2028").should("exist");
+ cy.findByText("April 2026").should("exist");
+ cy.findByText("April 2027").should("exist");
+ cy.findByText("April 2028").should("exist");
// previous x-axis values
cy.findByText("Doohickey").should("not.exist");
@@ -744,9 +744,9 @@ describe("issue 44532", () => {
cy.findByText("Created At: Month").should("exist"); // x-axis
// x-axis values
- cy.findByText("January 2026").should("exist");
- cy.findByText("January 2027").should("exist");
- cy.findByText("January 2028").should("exist");
+ cy.findByText("April 2026").should("exist");
+ cy.findByText("April 2027").should("exist");
+ cy.findByText("April 2028").should("exist");
// previous x-axis values
cy.findByText("Doohickey").should("not.exist");
diff --git a/e2e/test/scenarios/question/reproductions-4.cy.spec.js b/e2e/test/scenarios/question/reproductions-4.cy.spec.js
index 633370700a9..dadb63dae2d 100644
--- a/e2e/test/scenarios/question/reproductions-4.cy.spec.js
+++ b/e2e/test/scenarios/question/reproductions-4.cy.spec.js
@@ -687,7 +687,7 @@ describe("issue 36027", () => {
cy.findByText("Count").should("be.visible"); // y-axis
// x-axis values
- ["January 2026", "January 2027", "January 2028", "January 2029"].forEach(
+ ["April 2025", "April 2026", "April 2027", "April 2028"].forEach(
(state) => {
cy.findByText(state).should("be.visible");
},
diff --git a/e2e/test/scenarios/visualizations/charts/line_chart.cy.spec.js b/e2e/test/scenarios/visualizations/charts/line_chart.cy.spec.js
index d1724630d1f..fdfa62c773d 100644
--- a/e2e/test/scenarios/visualizations/charts/line_chart.cy.spec.js
+++ b/e2e/test/scenarios/visualizations/charts/line_chart.cy.spec.js
@@ -42,7 +42,7 @@ describe("scenarios > visualizations > line chart", () => {
cy.log("x-axis column settings (metabase#51952)");
cy.findByTestId("settings-CREATED_AT").click();
H.popover().findByText("Abbreviate days and months").click();
- H.echartsContainer().findByText("Jan 2027");
+ H.echartsContainer().findByText("Apr 2027");
cy.realPress("Escape");
cy.get("[data-element-id=mantine-popover]")
.filter(":visible")
diff --git a/e2e/test/scenarios/visualizations/charts/waterfall.cy.spec.js b/e2e/test/scenarios/visualizations/charts/waterfall.cy.spec.js
index f08d1acc8e8..d25bc574c0f 100644
--- a/e2e/test/scenarios/visualizations/charts/waterfall.cy.spec.js
+++ b/e2e/test/scenarios/visualizations/charts/waterfall.cy.spec.js
@@ -91,7 +91,7 @@ describe("scenarios > visualizations > waterfall", () => {
verifyWaterfallRendering("Created At", "Count");
});
- it("should hide the Total label if there is no space", () => {
+ it("should keep the Total label and drop the date label crowding it", () => {
H.openOrdersTable({ mode: "notebook" });
H.summarize({ mode: "notebook" });
// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
@@ -108,7 +108,11 @@ describe("scenarios > visualizations > waterfall", () => {
switchToWaterfallDisplay();
H.chartPathWithFillColor("#303D46").should("exist");
- H.echartsContainer().find("text").contains("Total").should("not.exist");
+ H.echartsContainer().within(() => {
+ cy.findByText("Total").should("exist");
+ // the last month sits one month before the Total and gives way to it
+ cy.findByText("April 2029").should("not.exist");
+ });
});
describe("multi-series (metabase#15152)", () => {
diff --git a/e2e/test/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js b/e2e/test/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js
index 0da1e6c7004..acc1941ada8 100644
--- a/e2e/test/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js
+++ b/e2e/test/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js
@@ -37,8 +37,8 @@ describe("scenarios > visualizations > drillthroughs > chart drill", () => {
H.queryBuilderMain().within(() => {
cy.findByLabelText("Legend").findByText("Gadget").should("exist");
H.echartsContainer()
- .should("contain.text", "July 2025")
- .and("contain.text", "January 2026");
+ .should("contain.text", "April 2025")
+ .and("contain.text", "April 2026");
});
cy.log("Chart drills");
@@ -298,7 +298,7 @@ describe("scenarios > visualizations > drillthroughs > chart drill", () => {
{ visitQuestion: true },
);
- H.echartsContainer().contains("January 2028");
+ H.echartsContainer().contains("May 2028");
// drill into a recent week
H.cartesianChartCircle().should("have.length.gte", 4).eq(-4).click();
diff --git a/frontend/src/metabase/visualizations/tests/timeseries-intervals.unit.spec.ts b/frontend/src/metabase/visualizations/tests/timeseries-intervals.unit.spec.ts
index 86706e46da2..e110b8c16fb 100644
--- a/frontend/src/metabase/visualizations/tests/timeseries-intervals.unit.spec.ts
+++ b/frontend/src/metabase/visualizations/tests/timeseries-intervals.unit.spec.ts
@@ -182,7 +182,7 @@ describe("timeseries intervals", () => {
end: "2020-04-05",
unit: "month",
count: 2,
- expected: 1, // 2020-03-01
+ expected: 2, // 2020-02-01, 2020-04-01: every second month from the first month in range
},
{
start: "2022-01-01",
@@ -198,6 +198,20 @@ describe("timeseries intervals", () => {
count: 2,
expected: 2, // 2024-01-01, 2026-01-01
},
+ {
+ start: "2021-01-01",
+ end: "2025-06-01",
+ unit: "year",
+ count: 2,
+ expected: 3, // 2021-01-01, 2023-01-01, 2025-01-01: the grid starts at the first year in range
+ },
+ {
+ start: "2021-03-01",
+ end: "2031-06-01",
+ unit: "year",
+ count: 5,
+ expected: 2, // 2022-01-01, 2027-01-01
+ },
{
start: "2025-01-01",
end: "2026-01-01",
@@ -224,7 +238,7 @@ describe("timeseries intervals", () => {
end: "2025-01-22T00:00:00Z", // Wednesday
unit: "week",
count: 1,
- expected: 2, // Jan 12, Jan 19
+ expected: 3, // Jan 8, Jan 15, Jan 22: weeks start on the first data point's weekday
},
{
start: "2025-03-15T00:00:00Z",
@@ -310,6 +324,7 @@ describe("timeseries intervals", () => {
xDomain: ContinuousDomain;
xInterval: TimeSeriesInterval;
outerWidth: number;
+ paddingX?: number;
xTickWidth: number;
};
type TickExpected = {
@@ -356,7 +371,7 @@ describe("timeseries intervals", () => {
},
{ expectedUnit: "quarter", expectedCount: 1 },
],
- // even narrower and we should show yearly ticks
+ // even narrower: five half-year labels of 55px still fit in 300px
[
{
xDomain: [
@@ -367,6 +382,19 @@ describe("timeseries intervals", () => {
outerWidth: 300,
xTickWidth: 55,
},
+ { expectedUnit: "quarter", expectedCount: 2 },
+ ],
+ // narrower still and we should show yearly ticks
+ [
+ {
+ xDomain: [
+ new Date("2020-01-01").getTime(),
+ new Date("2022-01-01").getTime(),
+ ],
+ xInterval: { unit: "month", count: 1 },
+ outerWidth: 250,
+ xTickWidth: 55,
+ },
{ expectedUnit: "year", expectedCount: 1 },
],
// FIXME: investigate and uncomment
@@ -380,6 +408,21 @@ describe("timeseries intervals", () => {
// },
// { expectedUnit: "month", expectedCount: 3 },
// ],
+ // 25 yearly points on a 540px static chart: 13 two-year labels of 32px
+ // fit in the 491px plot, so the chart must not fall back to 5 years
+ [
+ {
+ xDomain: [
+ new Date("1999-01-01").getTime(),
+ new Date("2023-01-01").getTime(),
+ ],
+ xInterval: { unit: "year", count: 1 },
+ outerWidth: 540,
+ paddingX: 49,
+ xTickWidth: 32.4,
+ },
+ { expectedUnit: "year", expectedCount: 2 },
+ ],
// wide tick labels should update the interval to have fewer ticks
[
{
@@ -393,11 +436,25 @@ describe("timeseries intervals", () => {
},
{ expectedUnit: "year", expectedCount: 1 },
],
+ // raw second-level timestamps over years must not materialize every
+ // candidate tick while searching for an interval that fits
+ [
+ {
+ xDomain: [
+ new Date("2025-04-30T18:56:13Z").getTime(),
+ new Date("2029-04-11T07:12:44Z").getTime(),
+ ],
+ xInterval: { unit: "second", count: 1 },
+ outerWidth: 1232,
+ xTickWidth: 80,
+ },
+ { expectedUnit: "quarter", expectedCount: 2 },
+ ],
];
TEST_CASES.forEach(
([
- { xDomain, xInterval, outerWidth, xTickWidth },
+ { xDomain, xInterval, outerWidth, paddingX = 0, xTickWidth },
{ expectedUnit, expectedCount },
]) => {
it(`should return ${expectedCount} ${expectedUnit}`, () => {
@@ -406,6 +463,7 @@ describe("timeseries intervals", () => {
xInterval,
createMockChartLayout({
outerWidth,
+ padding: { left: paddingX, right: 0 },
ticksDimensions: { getXTickWidth: () => xTickWidth },
}),
mockFormatter,
diff --git a/frontend/src/metabase/viz-core/echarts/cartesian/option/axis.ts b/frontend/src/metabase/viz-core/echarts/cartesian/option/axis.ts
index febb95d9d8d..adfee9b5268 100644
--- a/frontend/src/metabase/viz-core/echarts/cartesian/option/axis.ts
+++ b/frontend/src/metabase/viz-core/echarts/cartesian/option/axis.ts
@@ -20,6 +20,7 @@ import type {
NumericAxisScaleTransforms,
NumericXAxisModel,
TimeSeriesXAxisModel,
+ WaterfallXAxisModel,
YAxisModel,
} from "../model/types";
@@ -117,6 +118,7 @@ export const getDimensionTicksDefaultOption = (
return {
...getTicksDefaultOption(renderingContext),
show: !!settings["graph.x_axis.axis_enabled"],
+ showMinLabel: true,
rotate: getRotateAngle(settings),
};
};
@@ -285,13 +287,13 @@ export const buildNumericDimensionAxis = (
};
export const buildTimeSeriesDimensionAxis = (
- xAxisModel: TimeSeriesXAxisModel,
+ xAxisModel: TimeSeriesXAxisModel & Pick<WaterfallXAxisModel, "totalXValue">,
hasTimelineEvents: boolean,
settings: ComputedVisualizationSettings,
chartLayout: ChartLayout,
renderingContext: RenderingContext,
): XAXisOption => {
- const { formatter, maxInterval, minInterval, canRender, xDomainPadded } =
+ const { formatter, minInterval, customValues, canRender, xDomainPadded } =
getTicksOptions(xAxisModel, chartLayout);
return {
@@ -302,6 +304,7 @@ export const buildTimeSeriesDimensionAxis = (
? CHART_STYLE.timelineEvents.height
: renderingContext.theme.cartesian.ticks.marginX,
...getDimensionTicksDefaultOption(settings, renderingContext),
+ customValues,
formatter: (rawValue: number) => {
const value = xAxisModel.fromEChartsAxisValue(rawValue);
if (canRender(value)) {
@@ -315,7 +318,6 @@ export const buildTimeSeriesDimensionAxis = (
min: xDomainPadded[0],
max: xDomainPadded[1],
minInterval,
- maxInterval,
};
};
diff --git a/frontend/src/metabase/viz-core/echarts/cartesian/option/axis.unit.spec.ts b/frontend/src/metabase/viz-core/echarts/cartesian/option/axis.unit.spec.ts
index f8f3d61f417..21bd9989587 100644
--- a/frontend/src/metabase/viz-core/echarts/cartesian/option/axis.unit.spec.ts
+++ b/frontend/src/metabase/viz-core/echarts/cartesian/option/axis.unit.spec.ts
@@ -2,6 +2,7 @@ import {
createMockCartesianChartModel,
createMockChartLayout,
} from "__support__/echarts";
+import { dayjs } from "metabase/dayjs";
import {
createMockColumn,
createMockVisualizationSettings,
@@ -190,3 +191,84 @@ describe("responsive Y-axis ticks", () => {
expect(yAxis[0].axisLabel?.customValues).toEqual([0, 100]);
});
});
+
+describe("first x-axis label", () => {
+ const settings = createMockVisualizationSettings({
+ "graph.x_axis.axis_enabled": true,
+ });
+ const chartLayout = createMockChartLayout({ outerWidth: 300 });
+ const xAxisFor = (
+ chartModel: ReturnType<typeof createMockCartesianChartModel>,
+ chartSettings = settings,
+ ) =>
+ buildAxes(chartModel, chartLayout, chartSettings, false, renderingContext)
+ .xAxis;
+
+ it("keeps the first category label when it collides with the second", () => {
+ const xAxis = xAxisFor(
+ createMockCartesianChartModel({
+ xAxisModel: {
+ axisType: "category",
+ isHistogram: false,
+ valuesCount: 4,
+ formatter: String,
+ },
+ }),
+ );
+
+ expect(xAxis.axisLabel?.showMinLabel).toBe(true);
+ });
+
+ it("keeps the first time-series and numeric labels too", () => {
+ const timeAxis = xAxisFor(
+ createMockCartesianChartModel({
+ xAxisModel: {
+ axisType: "time",
+ interval: { unit: "month", count: 1 },
+ intervalsCount: 12,
+ range: [dayjs.utc("2025-01-01"), dayjs.utc("2026-01-01")],
+ formatter: String,
+ toEChartsAxisValue: (value) => String(value),
+ fromEChartsAxisValue: (value) => dayjs.utc(value),
+ },
+ }),
+ );
+ const numericAxis = xAxisFor(
+ createMockCartesianChartModel({
+ xAxisModel: {
+ axisType: "value",
+ extent: [0, 10],
+ interval: 1,
+ intervalsCount: 10,
+ isPadded: true,
+ formatter: String,
+ toEChartsAxisValue: (value) => Number(value),
+ fromEChartsAxisValue: (value) => value,
+ },
+ }),
+ );
+
+ expect(timeAxis.axisLabel?.showMinLabel).toBe(true);
+ expect(numericAxis.axisLabel?.showMinLabel).toBe(true);
+ });
+
+ it("still labels histogram bins by their right edge", () => {
+ const xAxis = xAxisFor(
+ createMockCartesianChartModel({
+ xAxisModel: {
+ axisType: "category",
+ isHistogram: true,
+ valuesCount: 4,
+ formatter: String,
+ },
+ }),
+ createMockVisualizationSettings({
+ "graph.x_axis.axis_enabled": true,
+ "graph.x_axis.scale": "histogram",
+ }),
+ );
+
+ expect(xAxis.axisLabel?.showMinLabel).toBe(false);
+ expect(xAxis.axisLabel?.showMaxLabel).toBe(true);
+ });
+});
diff --git a/frontend/src/metabase/viz-core/echarts/cartesian/option/ticks.ts b/frontend/src/metabase/viz-core/echarts/cartesian/option/ticks.ts
index fe7b83b539e..3044a7a27c0 100644
--- a/frontend/src/metabase/viz-core/echarts/cartesian/option/ticks.ts
+++ b/frontend/src/metabase/viz-core/echarts/cartesian/option/ticks.ts
@@ -5,11 +5,14 @@ import type { ChartLayout } from "../layout/types";
import type {
TimeSeriesAxisFormatter,
TimeSeriesXAxisModel,
+ WaterfallXAxisModel,
} from "../model/types";
import {
computeTimeseriesTicksInterval,
getFormatter,
+ getGridTickDates,
getLargestInterval,
+ getTickGrid,
getTimeSeriesIntervalDuration,
} from "../utils/timeseries";
@@ -26,14 +29,18 @@ export const getPadding = (intervalsCount: number) => {
};
export const getTicksOptions = (
- xAxisModel: TimeSeriesXAxisModel,
+ xAxisModel: TimeSeriesXAxisModel & Pick<WaterfallXAxisModel, "totalXValue">,
chartLayout: ChartLayout,
) => {
- const { range, toEChartsAxisValue, interval, intervalsCount } = xAxisModel;
+ const { range, toEChartsAxisValue, interval, intervalsCount, totalXValue } =
+ xAxisModel;
+ // A waterfall's Total bar sits one interval after the last data point.
+ const totalEChartsValue =
+ totalXValue == null ? null : toEChartsAxisValue(totalXValue);
+ const totalDate =
+ totalEChartsValue == null ? null : dayjs.utc(totalEChartsValue);
let formatter: TimeSeriesAxisFormatter = xAxisModel.formatter;
- let minInterval: number | undefined;
- let maxInterval: number | undefined;
// Unjustified type cast. FIXME
const xDomain = range.map((day) => {
@@ -68,74 +75,47 @@ export const getTicksOptions = (
return date.isAfter(paddedMin) && date.isBefore(paddedMax);
};
- let canRender: (value: Dayjs) => boolean = (date) => isWithinRange(date);
-
- // HACK: ECharts does not support weekly ticks internally and even by specifying minInterval=*week_duration*
- // it will not produce correct weekly ticks prioritizing start of months ticks. A workaround to this is to
- // force ECharts render daily ticks and then in formatter return actual formatted values only for days that
- // are start of week and an empty string for the rest.
- if (largestInterval.unit === "week") {
- const startOfWeek = range[0].day();
- canRender = (date: Dayjs) =>
- isWithinRange(date) &&
- date.day() === startOfWeek &&
- date.week() % largestInterval.count === 0;
- const effectiveTicksUnit = "day";
- maxInterval = getTimeSeriesIntervalDuration({
- count: 1,
- unit: effectiveTicksUnit,
- });
- }
-
- // HACK: For monthly ticks, we need to handle variable month lengths.
- // Setting a fixed minInterval causes ECharts to skip months because some months
- // (like February with 28 days) are shorter than others (31 days).
- // Instead, we force ECharts to generate daily ticks and filter to month starts.
- if (largestInterval.unit === "month") {
- canRender = (date: Dayjs) =>
- isWithinRange(date) &&
- date.date() === 1 &&
- date.month() % largestInterval.count === 0;
- maxInterval = getTimeSeriesIntervalDuration({
- count: 1,
- unit: "day",
- });
+ const grid = getTickGrid(largestInterval, interval.unit, isSingleItem);
+
+ if (grid == null) {
+ // ECharts picks the ticks: millisecond data, or a single quarterly point.
+ return {
+ formatter,
+ minInterval: getTimeSeriesIntervalDuration(largestInterval),
+ customValues: undefined,
+ canRender: isWithinRange,
+ xDomainPadded,
+ };
}
- // HACK: Similarly to weekly ticks, ECharts does not support quarterly ticks natively.
- // If we let ECharts select ticks for quarterly data it can pick January and March which
- // will look like a duplication because both ticks will be formatted as Q1. So we need to
- // force ECharts to render monthly ticks and then select ones for Jan, Apr, Jul, Oct.
- if (!isSingleItem && largestInterval.unit === "quarter") {
- const effectiveTicksUnit = "month";
- canRender = (date: Dayjs) =>
- isWithinRange(date) &&
- date.startOf("quarter").isSame(date, "month") &&
- (date.quarter() - 1) % largestInterval.count === 0;
- maxInterval = getTimeSeriesIntervalDuration({
- count: 1,
- unit: effectiveTicksUnit,
- });
+ // ECharts anchors multi-unit tick grids (every 2 years, every 3 hours…) at
+ // the axis extent, so the first boundaries inside the range can go unlabeled
+ // while the data has already started. Hand ECharts the exact tick dates
+ // instead: the grid from the first boundary inside the padded axis, and a
+ // waterfall's Total, which replaces the grid tick closer than one step to it
+ // so the Total label has room.
+ const weekday = range[0].day();
+ const hasRoomBeforeTotal = (date: Dayjs) =>
+ totalDate == null || totalDate.diff(date, grid.unit, true) >= grid.step;
+ const ticks = getGridTickDates(
+ grid,
+ xAxisModel.fromEChartsAxisValue(xDomainPadded[0]),
+ xAxisModel.fromEChartsAxisValue(xDomainPadded[1]),
+ weekday,
+ false,
+ ).filter(hasRoomBeforeTotal);
+ if (totalDate != null && isWithinRange(totalDate)) {
+ ticks.push(totalDate);
}
- // HACK: ECharts 6.1.0 emits intermediate (mid-year) ticks within the padded
- // single-point year domain. Unlike week/month/quarter, the year path had no
- // boundary guard, so two ticks in the same year both format as that year and
- // duplicate the label (metabase#63671). Filter to start-of-year ticks only.
- if (largestInterval.unit === "year") {
- canRender = (date: Dayjs) =>
- isWithinRange(date) && date.month() === 0 && date.date() === 1;
- }
-
- if (!maxInterval) {
- minInterval = getTimeSeriesIntervalDuration(largestInterval);
- }
+ const customValues = ticks.map((date) => date.valueOf());
+ const tickValues = new Set(customValues);
return {
formatter,
- minInterval,
- maxInterval,
- canRender,
+ minInterval: undefined,
+ customValues,
+ canRender: (date: Dayjs) => tickValues.has(date.valueOf()),
xDomainPadded,
};
};
diff --git a/frontend/src/metabase/viz-core/echarts/cartesian/option/ticks.unit.spec.ts b/frontend/src/metabase/viz-core/echarts/cartesian/option/ticks.unit.spec.ts
index c993c20c787..f34a4ddd661 100644
--- a/frontend/src/metabase/viz-core/echarts/cartesian/option/ticks.unit.spec.ts
+++ b/frontend/src/metabase/viz-core/echarts/cartesian/option/ticks.unit.spec.ts
@@ -60,3 +60,248 @@ describe("getTicksOptions", () => {
expect(model.toEChartsAxisValue(last)).toBe("2025-04-01T00:00:00Z");
});
});
+
+describe("year tick grids", () => {
+ const utc = (value: string | number) => dayjs.utc(value);
+ const model = (
+ unit: TimeSeriesXAxisModel["interval"]["unit"],
+ first: string,
+ last: string,
+ ): TimeSeriesXAxisModel => ({
+ axisType: "time",
+ interval: { unit, count: 1 },
+ intervalsCount: utc(last).diff(utc(first), unit),
+ range: [utc(first), utc(last)],
+ formatter: String,
+ toEChartsAxisValue: (value) =>
+ utc(String(value)).format("YYYY-MM-DDTHH:mm:ss[Z]"),
+ fromEChartsAxisValue: (value) => dayjs.utc(value),
+ });
+ // Every label is 60px wide, so a chart fits one tick per 70px.
+ const layout = (outerWidth: number) =>
+ createMockChartLayout({
+ outerWidth,
+ ticksDimensions: { getXTickWidth: () => 60 },
+ });
+ const rendered = (
+ options: ReturnType<typeof getTicksOptions>,
+ dates: string[],
+ ) => dates.filter((date) => options.canRender(utc(date)));
+
+ it("starts a two-year grid at the first year in range", () => {
+ // Monthly data from March 2019: yearly ticks (2020–2026) do not fit in
+ // four slots, so ticks come every two years from January 2020.
+ const options = getTicksOptions(
+ model("month", "2019-03-01", "2026-04-01"),
+ layout(300),
+ );
+
+ expect(options.minInterval).toBeUndefined();
+ expect(
+ rendered(options, [
+ "2019-01-01",
+ "2020-01-01",
+ "2020-07-01",
+ "2021-01-01",
+ "2022-01-01",
+ "2024-01-01",
+ "2026-01-01",
+ ]),
+ ).toEqual(["2020-01-01", "2022-01-01", "2024-01-01", "2026-01-01"]);
+ });
+
+ it("includes a year boundary that falls inside the axis padding", () => {
+ // Weekly data from Monday 4 January 2021: the padded axis starts before
+ // 1 January, so that boundary anchors the grid.
+ const options = getTicksOptions(
+ model("week", "2021-01-04", "2026-06-01"),
+ layout(300),
+ );
+
+ expect(
+ rendered(options, ["2021-01-01", "2022-01-01", "2023-01-01"]),
+ ).toEqual(["2021-01-01", "2023-01-01"]);
+ });
+
+ it("starts finer grids at the first boundary in range too", () => {
+ // Daily data from 20 January: two-month ticks start on 1 February.
+ const options = getTicksOptions(
+ model("day", "2026-01-20", "2026-07-15"),
+ layout(300),
+ );
+
+ expect(
+ rendered(options, [
+ "2026-01-20",
+ "2026-02-01",
+ "2026-03-01",
+ "2026-04-01",
+ "2026-06-01",
+ ]),
+ ).toEqual(["2026-02-01", "2026-04-01", "2026-06-01"]);
+ });
+
+ it("steps quarter grids over finer data three months from the first month in range", () => {
+ // The same daily data on a narrower chart: only two labels fit, so the
+ // grid is quarterly, but anchored on 1 February rather than a calendar
+ // quarter.
+ const options = getTicksOptions(
+ model("day", "2026-01-20", "2026-07-15"),
+ layout(180),
+ );
+
+ expect(
+ rendered(options, [
+ "2026-02-01",
+ "2026-04-01",
+ "2026-05-01",
+ "2026-07-01",
+ ]),
+ ).toEqual(["2026-02-01", "2026-05-01"]);
+ });
+
+ it("keeps quarterly data on calendar quarters", () => {
+ // Quarterly points from Q2 2025: half-year ticks start on that quarter.
+ const options = getTicksOptions(
+ model("quarter", "2025-04-01", "2028-01-01"),
+ layout(400),
+ );
+
+ expect(
+ rendered(options, [
+ "2025-04-01",
+ "2025-07-01",
+ "2025-10-01",
+ "2026-01-01",
+ "2026-04-01",
+ ]),
+ ).toEqual(["2025-04-01", "2025-10-01", "2026-04-01"]);
+ });
+
+ it("keeps sub-day grids on round clock values", () => {
+ // Hourly data from 01:00 on a three-hour grid: 03:00, 06:00… rather than
+ // 01:00, 04:00…, and 22:00 is not labeled.
+ const options = getTicksOptions(
+ model("hour", "2026-03-01T01:00:00Z", "2026-03-01T22:00:00Z"),
+ layout(560),
+ );
+
+ expect(
+ rendered(options, [
+ "2026-03-01T00:00:00Z",
+ "2026-03-01T01:00:00Z",
+ "2026-03-01T03:00:00Z",
+ "2026-03-01T04:00:00Z",
+ "2026-03-01T06:00:00Z",
+ "2026-03-01T21:00:00Z",
+ "2026-03-01T22:00:00Z",
+ ]),
+ ).toEqual([
+ "2026-03-01T03:00:00Z",
+ "2026-03-01T06:00:00Z",
+ "2026-03-01T21:00:00Z",
+ ]);
+ });
+
+ it("hands ECharts the exact tick dates", () => {
+ const options = getTicksOptions(
+ model("month", "2019-03-01", "2026-04-01"),
+ layout(300),
+ );
+
+ expect(
+ options.customValues?.map((value) => utc(value).toISOString()),
+ ).toEqual([
+ "2020-01-01T00:00:00.000Z",
+ "2022-01-01T00:00:00.000Z",
+ "2024-01-01T00:00:00.000Z",
+ "2026-01-01T00:00:00.000Z",
+ ]);
+ });
+});
+
+describe("waterfall Total tick", () => {
+ const utc = (value: string) => dayjs.utc(value);
+ const layout = (outerWidth: number) =>
+ createMockChartLayout({
+ outerWidth,
+ ticksDimensions: { getXTickWidth: () => 60 },
+ });
+ const rendered = (
+ options: ReturnType<typeof getTicksOptions>,
+ dates: string[],
+ ) => dates.filter((date) => options.canRender(utc(date)));
+ const waterfallModel = (
+ unit: TimeSeriesXAxisModel["interval"]["unit"],
+ first: string,
+ total: string,
+ ): TimeSeriesXAxisModel & { totalXValue: string } => ({
+ axisType: "time",
+ interval: { unit, count: 1 },
+ intervalsCount: utc(total).diff(utc(first), unit),
+ range: [utc(first), utc(total)],
+ formatter: String,
+ toEChartsAxisValue: (value: unknown) =>
+ utc(String(value)).format("YYYY-MM-DDTHH:mm:ss[Z]"),
+ fromEChartsAxisValue: (value: number) => dayjs.utc(value),
+ totalXValue: utc(total).toISOString(),
+ });
+
+ it("drops the grid tick crowded by the Total of a multi-year grid", () => {
+ // Yearly data 2024–2034 with Total at 2035: five-year ticks start at 2024,
+ // and 2034 gives way to the Total one year later.
+ const options = getTicksOptions(
+ waterfallModel("year", "2024-01-01", "2035-01-01"),
+ layout(300),
+ );
+
+ expect(
+ rendered(options, [
+ "2024-01-01",
+ "2025-01-01",
+ "2029-01-01",
+ "2034-01-01",
+ "2035-01-01",
+ ]),
+ ).toEqual(["2024-01-01", "2029-01-01", "2035-01-01"]);
+ });
+
+ it("drops the grid tick crowded by the Total of finer grids as well", () => {
+ // Monthly data January–July with Total in August: two-month ticks start
+ // in January, and July gives way to the Total a month later.
+ const options = getTicksOptions(
+ waterfallModel("month", "2025-01-01", "2025-08-01"),
+ layout(300),
+ );
+
+ expect(
+ rendered(options, [
+ "2025-01-01",
+ "2025-02-01",
+ "2025-03-01",
+ "2025-07-01",
+ "2025-08-01",
+ ]),
+ ).toEqual(["2025-01-01", "2025-03-01", "2025-08-01"]);
+ });
+
+ it("labels a Total that is not on the grid's unit by emitting its tick", () => {
+ // Daily data with a two-year grid: the Total sits a day after the last
+ // point and is labeled, while the year boundary three months before it
+ // gives way.
+ const options = getTicksOptions(
+ waterfallModel("day", "2019-03-01", "2026-04-02"),
+ layout(300),
+ );
+
+ expect(
+ rendered(options, [
+ "2024-01-01",
+ "2026-01-01",
+ "2026-04-02",
+ "2026-04-03",
+ ]),
+ ).toEqual(["2024-01-01", "2026-04-02"]);
+ expect(options.customValues).toContain(utc("2026-04-02").valueOf());
+ });
+});
diff --git a/frontend/src/metabase/viz-core/echarts/cartesian/utils/timeseries.ts b/frontend/src/metabase/viz-core/echarts/cartesian/utils/timeseries.ts
index 48f10e06da9..0300e1c53fa 100644
--- a/frontend/src/metabase/viz-core/echarts/cartesian/utils/timeseries.ts
+++ b/frontend/src/metabase/viz-core/echarts/cartesian/utils/timeseries.ts
@@ -192,50 +192,133 @@ export function getTimeSeriesIntervalDuration(interval: TimeSeriesInterval) {
return dayjs(0).add(interval.count, interval.unit).valueOf();
}
-// Counts interval boundary crossings within the domain
-export function expectedTickCount(
- interval: TimeSeriesInterval,
- xDomain: ContinuousDomain,
-): number {
- const { unit, count } = interval;
- const start = dayjs.utc(xDomain[0]);
- const end = dayjs.utc(xDomain[1]);
+export interface TickGrid {
+ unit: TimeSeriesInterval["unit"];
+ step: number;
+}
- const startTrunc = start.startOf(unit);
- const endTrunc = end.startOf(unit);
+type SubDayUnit = "hour" | "minute" | "second";
+const SUB_DAY_UNITS: ReadonlySet<TimeSeriesInterval["unit"]> = new Set([
+ "hour",
+ "minute",
+ "second",
+]);
+const isSubDayUnit = (unit: TimeSeriesInterval["unit"]): unit is SubDayUnit =>
+ SUB_DAY_UNITS.has(unit);
- const diffUnits = endTrunc.diff(startTrunc, unit);
+/**
+ * The grid of labeled ticks for a tick interval: every `step` boundaries of
+ * `unit`, starting from the first boundary in range (see getGridTickDates).
+ * Quarter grids over finer data step three months from the first month in
+ * range rather than from a calendar quarter; quarterly data starts on quarter
+ * boundaries anyway, so its labels stay calendar quarters. `null` leaves the
+ * ticks to ECharts.
+ */
+export function getTickGrid(
+ { unit, count }: TimeSeriesInterval,
+ dataUnit: TimeSeriesInterval["unit"],
+ isSingleItem: boolean,
+): TickGrid | null {
+ switch (unit) {
+ case "quarter":
+ // With a single point ECharts picks the quarter tick itself.
+ if (isSingleItem) {
+ return null;
+ }
+ return dataUnit === "quarter"
+ ? { unit, step: count }
+ : { unit: "month", step: 3 * count };
+ case "year":
+ case "month":
+ case "week":
+ case "day":
+ case "hour":
+ case "minute":
+ case "second":
+ return { unit, step: count };
+ default:
+ return null;
+ }
+}
- let startIdx: number;
- if (unit === "year") {
- startIdx = startTrunc.year();
- } else if (unit === "quarter") {
- startIdx = startTrunc.quarter() - 1;
- } else if (unit === "month") {
- startIdx = startTrunc.month();
- } else if (unit === "week") {
- startIdx = startTrunc.week();
- } else if (unit === "day") {
- startIdx = startTrunc.day();
- } else if (unit === "hour") {
- startIdx = startTrunc.hour();
- } else if (unit === "minute") {
- startIdx = startTrunc.minute();
- } else if (unit === "second") {
- startIdx = startTrunc.second();
- } else {
- startIdx = startTrunc.valueOf();
+// Sub-day grids stay on round clock values (03:00, 06:00… for a 3-hour grid),
+// as every step of those units divides its parent unit evenly.
+function isGridBoundary(
+ date: Dayjs,
+ { unit, step }: TickGrid,
+ weekday: number,
+) {
+ if (unit === "week") {
+ return date.day() === weekday && date.startOf("day").isSame(date);
}
+ if (!date.startOf(unit).isSame(date)) {
+ return false;
+ }
+ return isSubDayUnit(unit) ? date.get(unit) % step === 0 : true;
+}
- const startAligned = Math.ceil(startIdx / count) * count;
- const endAligned = Math.floor((startIdx + diffUnits) / count) * count;
+function findFirstBoundary(
+ from: Dayjs,
+ grid: TickGrid,
+ weekday: number,
+ inclusive: boolean,
+) {
+ const step = grid.unit === "week" ? "day" : grid.unit;
+ let boundary = from.startOf(step);
+ while (
+ (inclusive ? boundary.isBefore(from) : !boundary.isAfter(from)) ||
+ !isGridBoundary(boundary, grid, weekday)
+ ) {
+ boundary = boundary.add(1, step);
+ }
+ return boundary;
+}
- const diffAligned = (endAligned - startAligned) / count;
+/**
+ * The dates the axis labels for `grid` between `start` and `end`: the first
+ * boundary in range, then every `step` units from it. Weeks start on
+ * `weekday`, the first data point's weekday, rather than on calendar weeks.
+ */
+export function getGridTickDates(
+ grid: TickGrid,
+ start: Dayjs,
+ end: Dayjs,
+ weekday: number,
+ inclusive: boolean,
+): Dayjs[] {
+ const anchor = findFirstBoundary(start, grid, weekday, inclusive);
+ const ticks: Dayjs[] = [];
+ for (let index = 0; ; index++) {
+ const tick = anchor.add(index * grid.step, grid.unit);
+ if (inclusive ? tick.isAfter(end) : !tick.isBefore(end)) {
+ return ticks;
+ }
+ ticks.push(tick);
+ }
+}
- if (start.valueOf() === startTrunc.valueOf() || startIdx < startAligned) {
- return diffAligned + 1;
+// Counts the ticks the axis will label (see getTicksOptions) without
+// materializing them: candidate intervals far finer than the range (seconds
+// over years) would otherwise allocate millions of dates.
+export function expectedTickCount(
+ interval: TimeSeriesInterval,
+ xDomain: ContinuousDomain,
+ dataUnit: TimeSeriesInterval["unit"] = interval.unit,
+): number {
+ if (interval.unit === "ms") {
+ return Math.floor((xDomain[1] - xDomain[0]) / interval.count) + 1;
+ }
+ const grid = getTickGrid(interval, dataUnit, false);
+ if (grid == null) {
+ return 0;
}
- return diffAligned;
+ const start = dayjs.utc(xDomain[0]);
+ const end = dayjs.utc(xDomain[1]);
+ const anchor = findFirstBoundary(start, grid, start.day(), true);
+ const stepsInRange = Math.floor(
+ end.diff(anchor, grid.unit, true) / grid.step,
+ );
+ return stepsInRange < 0 ? 0 : stepsInRange + 1;
}
/// Get the appropriate tick interval option from the TIMESERIES_INTERVALS above based on the xAxis bucketing
@@ -272,7 +355,11 @@ export function computeTimeseriesTicksInterval(
interval.unit,
getFormatter(formatter, xInterval.unit, interval.unit),
);
- const intervalTicksCount = expectedTickCount(interval, xDomain);
+ const intervalTicksCount = expectedTickCount(
+ interval,
+ xDomain,
+ xInterval.unit,
+ );
if (intervalTicksCount > maxTickCount) {
continue;
@@ -313,7 +400,7 @@ function maxTicksForChartWidth(
chartLayout.outerWidth -
chartLayout.padding.left -
chartLayout.padding.right;
- const TICK_BUFFER_PIXELS = 10;
+ const TICK_BUFFER_PIXELS = 4;
const representativeDates = getRepresentativeDates(unit).map((date) =>
getPaddedAxisLabel(formatter(date)),
);
diff --git a/test/metabase/channel/render/body_test.clj b/test/metabase/channel/render/body_test.clj
index 58f2c31405b..01e0d69644a 100644
--- a/test/metabase/channel/render/body_test.clj
+++ b/test/metabase/channel/render/body_test.clj
@@ -1355,7 +1355,7 @@
(map str/trim)
first)]
(testing "Renders with correct day of week first"
- (is (= "2017/1" label))))))))))
+ (is (= "2018/4" label))))))))))
(deftest render-correct-whitelabel-colors
(when config/ee-available?