You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "plainheart (via GitHub)" <gi...@apache.org> on 2026/09/12 03:01:50 UTC

[PR] fix(marker): fix mark line is not at the expected position due to default precision when it targets a specific axis value [echarts]

plainheart opened a new pull request, #21752:
URL: https://github.com/apache/echarts/pull/21752

   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   
   
   ### What does this PR do?
   
   Fix that the mark line is not at the expected position due to precision loss when it targets a specific axis value.
   
   For example: 
   ```ts
   {
     yAxis: 2.0156
   }
   ```
   
   Since `precision` defaults to `2`, the mark line above is rounded to `2.02`. So it appears in an unexpected position and even disappears when `yAxis.min` is `2.015`.
   
   I think we should retrieve precision from the value rather than using the default precision when it targets a specific axis value to ensure it is at the expected position.
   
   ### Fixed issues
   
   Fixes #21743
   
   ## Comparison
   
   | Before | After |
   | :----: | :----: |
   | <img width="800" height="600" alt="Before" src="https://github.com/user-attachments/assets/8645fb32-37ec-4c54-84ed-77b71f3c74d3" /> | <img width="800" height="600" alt="After" src="https://github.com/user-attachments/assets/f9738733-d58b-4237-bc77-db41034e2215" /> |
   
   ## 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/markLine-precision.html
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### Other information


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] fix(marker): fix mark line is not at the expected position due to default precision when it targets a specific axis value [echarts]

Posted by "echarts-bot[bot] (via GitHub)" <gi...@apache.org>.
echarts-bot[bot] commented on PR #21752:
URL: https://github.com/apache/echarts/pull/21752#issuecomment-5643030282

   Thanks for your contribution!
   The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/echarts/wiki/How-to-make-a-pull-request).
   
   The pull request is marked to be `PR: author is committer` because you are a committer of this project.


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] fix(marker): fix mark line is not at the expected position due to default precision when it targets a specific axis value [echarts]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #21752:
URL: https://github.com/apache/echarts/pull/21752#discussion_r3994880250


##########
src/component/marker/MarkLineView.ts:
##########
@@ -112,9 +120,11 @@ const markLineTransform = function (
             mlFrom.coord[baseIndex] = -Infinity;
             mlTo.coord[baseIndex] = Infinity;
 
-            const precision = mlModel.get('precision');
+            if (precision == null) {
+                precision = mlModel.get('precision');
+            }
             if (precision >= 0 && isNumber(value)) {
-                value = +value.toFixed(Math.min(precision, 20));
+                value = numberUtil.round(value, precision);

Review Comment:
   `numberUtil.round` clamps precision to 20, so a valid target such as `3.456e-100` has precision 103 but is converted to `0`; the mark line can therefore still move or disappear. Direct `xAxis`/`yAxis` targets should bypass rounding entirely, while statistic items can continue honoring `markLine.precision`.



-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] fix(marker): use raw value without precision rounding when the mark line targets a specific axis value or is in `min/max` type [echarts]

Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart commented on code in PR #21752:
URL: https://github.com/apache/echarts/pull/21752#discussion_r3994939318


##########
src/component/marker/MarkLineView.ts:
##########
@@ -112,9 +120,11 @@ const markLineTransform = function (
             mlFrom.coord[baseIndex] = -Infinity;
             mlTo.coord[baseIndex] = Infinity;
 
-            const precision = mlModel.get('precision');
+            if (precision == null) {
+                precision = mlModel.get('precision');
+            }
             if (precision >= 0 && isNumber(value)) {
-                value = +value.toFixed(Math.min(precision, 20));
+                value = numberUtil.round(value, precision);

Review Comment:
   Makes sense to me.



-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org