jesco-absolut opened a new pull request, #21658:
URL: https://github.com/apache/echarts/pull/21658

   <!-- Please fill in the following information to help us review your PR more 
efficiently. -->
   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   
   
   ### What does this PR do?
   
   Guard dataZoom slider data-shadow normalization so a single-point time-axis 
series does not generate NaN shadow geometry.
   
   
   
   ### Fixed issues
   
   - close #21649
   
   
   ## Details
   
   ### Before: What was the problem?
   
   For slider dataZoom with `showDataShadow: true`, `_renderDataShadow` 
computes a time-axis shadow coordinate with:
   
   ```ts
   (+thisValue - thisDataExtent[0]) * normalizationConstant
   ```
   
   `normalizationConstant` was calculated as:
   
   ```ts
   size[0] / (thisDataExtent[1] - thisDataExtent[0])
   ```
   
   When the shadow-source series has only one point on a time axis, 
`thisDataExtent[0] === thisDataExtent[1]`, so the divisor is `0`. This makes 
`normalizationConstant` become `Infinity`, and the single point computes `0 * 
Infinity`, producing `NaN`. The NaN coordinate then reaches the shadow 
polygon/polyline and the slider shadow renders blank/broken.
   
   
   
   ### After: How does it behave after the fixing?
   
   The normalization divisor is guarded for zero-width extents. In that 
degenerate single-point case, `normalizationConstant` becomes `0`, so the 
time-axis shadow coordinate remains finite and maps to the left edge of the 
slider, consistent with the existing non-time single-point step path.
   
   A visual test was added to `test/dataZoom-single-datapoint.html` covering:
   
   - single-point series on a time axis with `showDataShadow: true`;
   - multi-point series on a time axis with `showDataShadow: true`;
   - single-point series on a value axis with `showDataShadow: true`.
   
   
   
   ## Document Info
   
   One of the following should be checked.
   
   - [x] This PR doesn't relate to document changes
   - [ ] The document should be updated later
   - [ ] The document changes have been made in apache/echarts-doc#xxx
   
   
   
   ## Misc
   
   ### Security Checking
   
   - [ ] This PR uses security-sensitive Web APIs.
   
   <!-- PLEASE CHECK IT AGAINST: 
<https://github.com/apache/echarts/wiki/Security-Checklist-for-Code-Contributors>
 -->
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   `test/dataZoom-single-datapoint.html`
   
   Validation run:
   
   ```sh
   npm run checktype
   npx eslint src/component/dataZoom/SliderZoomView.ts
   npm run lint
   git diff --check
   ```
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### Other information
   
   N.A.
   


-- 
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