NHanser opened a new pull request, #41859:
URL: https://github.com/apache/superset/pull/41859

   <!---
   Please write the PR title following the conventions at 
https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   ### SUMMARY
   PR #39141 fixed bar overflow on numeric x-axes by always treating bar charts 
as categorical in `getAxisType()`, which made the **Force categorical** control 
ineffective and removed the ability to use a continuous numeric x-axis (e.g. to 
show gaps for missing years on a `year` column).
   This PR restores explicit user control while keeping the overflow fix as the 
default:
   - **`getAxisType()`**: remove the implicit `seriesType === Bar` coercion; 
axis type is again driven by `xAxisForceCategorical`, column data type, and 
stack mode.
   - **Bar chart**: default **Force categorical** to `true` in the chart 
control panel, with an updated description explaining the trade-off (overflow 
prevention vs. continuous numeric scale).
   - **Mixed Time-Series chart**:
     - expose **Force categorical** (and x-axis sort controls) in shared query 
fields;
     - default **Force categorical** to `true` when Query A or Query B uses a 
bar series, `false` for line-only charts;
     - move **Truncate X Axis** and **X-axis bounds** under the **X Axis** 
customize subsection (they were incorrectly listed under **Y Axis**).
   Users who need a numeric x-axis with spacing for missing values can uncheck 
**Force categorical**. Bar overflow on numeric axes is still mitigated by 
existing options (`truncateXAxis`, `barMaxWidth`, etc.) when users opt in to a 
value axis.
   
   Related: #39141, discussion #41027
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Example of a dataset with no value for year 2015.
   
   **Before (6.0.0, numeric `year` x-axis, bar chart):**
   - When **Force categorical** checked, no overflow but no gap for 2015 data.
   <img width="1660" height="606" alt="image" 
src="https://github.com/user-attachments/assets/758d841a-9e6d-48ad-8dca-b711dec8422f";
 />
   
   - Unchecking **Force categorical** restores a continuous numeric x-axis and 
visible gaps for missing values, BUT overflow on the left and the right of the 
graph
   <img width="1672" height="608" alt="image" 
src="https://github.com/user-attachments/assets/2f8e8dbe-2cd8-492f-bc1f-3bfc7246afe4";
 />
   
   **Before (6.1.0, numeric `year` x-axis, bar chart):**
   - **Force categorical** has no effect when unchecked; axis stays categorical.
   <img width="1648" height="600" alt="image" 
src="https://github.com/user-attachments/assets/de8029d7-fbbf-4cd0-927a-b743bd44bea6";
 />
   
   - Missing years (e.g. 2015) are not visible as gaps on the x-axis (even when 
 **Force categorical** is unchecked)
   <img width="1661" height="593" alt="image" 
src="https://github.com/user-attachments/assets/af88eaad-b0de-42ef-b657-bfa9df013399";
 />
   
   
   **After PR (numeric `year` x-axis, bar chart):**
   - New bar charts default to **Force categorical** checked (same visual as 
today, no overflow).
   <img width="1683" height="593" alt="image" 
src="https://github.com/user-attachments/assets/781af270-6db8-4565-b502-990921235da9";
 />
   
   - Unchecking **Force categorical** restores a continuous numeric x-axis and 
visible gaps for missing values, without overflow
   <img width="1668" height="585" alt="image" 
src="https://github.com/user-attachments/assets/3b90f443-2ff3-4537-aa5c-6529f69b55e1";
 />
   
   Also fixed in Mixed Chart : 
   - Unchecked **Force categorical**:
   <img width="1663" height="593" alt="image" 
src="https://github.com/user-attachments/assets/e5085eb3-7940-49ee-94b4-9c4c747d042e";
 />
   
   - **Force categorical** checked:
   <img width="1663" height="599" alt="image" 
src="https://github.com/user-attachments/assets/54fd3637-e6ed-4d90-9beb-462296f1c79e";
 />
   
   
   ### TESTING INSTRUCTIONS
   1. Use a dataset with a numeric x-axis column (e.g. `year` / `fiscal_year`) 
and a metric such as `SUM(sales)`.
   2. **Bar chart**
      - Create a bar chart with `year` on the x-axis.
      - Confirm **Force categorical** is checked by default for new charts.
      - With it checked: one bar per year, no intermediate ticks (e.g. 
`2003.5`).
      - Uncheck it: numeric value axis; verify gaps appear when a year is 
missing from the data.
      - Re-check it: bars align per category again.
   3. **Mixed Time-Series chart**
      - Query A: bar series; Query B: line series (same x-axis).
      - Confirm **Force categorical** appears under **Shared query fields** and 
defaults to checked.
      - Switch both queries to line: default should be unchecked (numeric 
x-axis available).
      - Under **Customize → X Axis**, confirm **Truncate X Axis** and **X-axis 
bounds** appear under **X Axis**, not **Y Axis**.
   4. **Regression**
      - Stacked bar chart with numeric x-axis + **Force categorical** checked: 
bars should not overflow chart edges (same as current 6.1 behavior).
   5. **Unit tests**
      ```bash
      cd superset-frontend
      npm run test -- 
--testPathPatterns="MixedTimeseries/controlPanel|Timeseries/Bar/controlPanel|utils/series.test"
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to