Skip to content

Conversation

@lzl0304
Copy link
Contributor

@lzl0304 lzl0304 commented Jul 15, 2025

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Fixed issues

#21098

Details

Before: What was the problem?

After: How does it behave after the fixing?

Document Info

One of the following should be checked.

  • 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

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

  • Please squash the commits into a single one when merging.

Other information

@100pah
Copy link
Member

100pah commented Jul 16, 2025

The currently behavior is by design. Historically, the visualMap "range" (which represents the selected range of data values) has a special meaning when it reaches both upper and lower bounds (i.e., option visualMap.min/max): it indicates "select all" (i.e., all data values are considered "in range", or, the range becomes [-Infinity, Infinity]). This strategy was introduced because otherwise, there is no way to express "select all" if some data values is outside the visualMap.min/max. I think this is also a compromise due to the fact that visualMap.min/max only support absolute numeric values - percentage values or keyword values like "dataMin"/"dataMax" are not supported.

I think in most cases that doesn't matter, but there would be some scenarios overlooked.
In your demo (codepen, I notice that the visualMap.max is set to be 98, so a node 100 can not be selected under the behavior proposed in this PR. Is it expected? Could we know the core requirements here - why need to always exclude the 100 from visualMap range? @lzl0304

image

Nevertheless, I think a strict mapping is supposed to be supported - as proposed in this PR. But changing this behavior by default would introduce a breaking change: user would no longer to be able to "select all" if some data values fall outside visualMap.min/max, unless they manually calculate and set those bounds in advance - that's not a easy fix.

Therefore, I suggest that introduce an extra option, such as visualMap.strictRange: boolean or visualMap.disableAutoFullRange: boolean to prevent the current behavior.

@Ovilia
Copy link
Contributor

Ovilia commented Jul 17, 2025

Since this issue was opened by @abdurrahmanyildirim , please try to answer the above questions to help us better understand the requirement. Thanks!

@lzl0304
Copy link
Contributor Author

lzl0304 commented Jul 17, 2025

The currently behavior is by design. Historically, the visualMap "range" (which represents the selected range of data values) has a special meaning when it reaches both upper and lower bounds (i.e., option visualMap.min/max): it indicates "select all" (i.e., all data values are considered "in range", or, the range becomes [-Infinity, Infinity]). This strategy was introduced because otherwise, there is no way to express "select all" if some data values is outside the visualMap.min/max. I think this is also a compromise due to the fact that visualMap.min/max only support absolute numeric values - percentage values or keyword values like "dataMin"/"dataMax" are not supported.

I think in most cases that doesn't matter, but there would be some scenarios overlooked. In your demo (codepen, I notice that the visualMap.max is set to be 98, so a node 100 can not be selected under the behavior proposed in this PR. Is it expected? Could we know the core requirements here - why need to always exclude the 100 from visualMap range? @lzl0304

image Nevertheless, I think a strict mapping is supposed to be supported - as proposed in this PR. But changing this behavior by default would introduce a breaking change: user would no longer to be able to "select all" if some data values fall outside `visualMap.min/max`, unless they manually calculate and set those bounds in advance - that's not a easy fix.

Therefore, I suggest that introduce an extra option, such as visualMap.strictRange: boolean or visualMap.disableAutoFullRange: boolean to prevent the current behavior.

Thank you for your patience and detailed technical explanation! Your explanation of the historical design philosophy of visualMap has given me a deeper understanding of this issue.
My specific use case:
My data is usually distributed within a normal range (e.g., 0-100), but occasionally there are extreme values that exceed the max (e.g., outliers like 120, 150). I would like the data within the 0-100 range to display with a normal gradient color, while the outliers above 100 are shown with a red warning color.
The problem I encountered:
However, in practice, the outOfRange configuration doesn't seem to take effect. Through debugging, I found that when I manually drag the range to [0, 100], the data points outside the range are still displayed within the normal color range, instead of the red color specified by outOfRange.
I've looked through the documentation but couldn't find more detailed usage instructions, and I discovered this issue while searching through existing issues. It seems I don't fully understand the comments for the function, and I couldn't find any relevant test cases to verify the handling of edge cases. I will close the current PR shortly.
Thank you again for your professional guidance and patient explanation!

@100pah
Copy link
Member

100pah commented Jul 17, 2025

The currently behavior is by design. Historically, the visualMap "range" (which represents the selected range of data values) has a special meaning when it reaches both upper and lower bounds (i.e., option visualMap.min/max): it indicates "select all" (i.e., all data values are considered "in range", or, the range becomes [-Infinity, Infinity]). This strategy was introduced because otherwise, there is no way to express "select all" if some data values is outside the visualMap.min/max. I think this is also a compromise due to the fact that visualMap.min/max only support absolute numeric values - percentage values or keyword values like "dataMin"/"dataMax" are not supported.
I think in most cases that doesn't matter, but there would be some scenarios overlooked. In your demo (codepen, I notice that the visualMap.max is set to be 98, so a node 100 can not be selected under the behavior proposed in this PR. Is it expected? Could we know the core requirements here - why need to always exclude the 100 from visualMap range? @lzl0304
image
Nevertheless, I think a strict mapping is supposed to be supported - as proposed in this PR. But changing this behavior by default would introduce a breaking change: user would no longer to be able to "select all" if some data values fall outside visualMap.min/max, unless they manually calculate and set those bounds in advance - that's not a easy fix.
Therefore, I suggest that introduce an extra option, such as visualMap.strictRange: boolean or visualMap.disableAutoFullRange: boolean to prevent the current behavior.

Thank you for your patience and detailed technical explanation! Your explanation of the historical design philosophy of visualMap has given me a deeper understanding of this issue. My specific use case: My data is usually distributed within a normal range (e.g., 0-100), but occasionally there are extreme values that exceed the max (e.g., outliers like 120, 150). I would like the data within the 0-100 range to display with a normal gradient color, while the outliers above 100 are shown with a red warning color. The problem I encountered: However, in practice, the outOfRange configuration doesn't seem to take effect. Through debugging, I found that when I manually drag the range to [0, 100], the data points outside the range are still displayed within the normal color range, instead of the red color specified by outOfRange. I've looked through the documentation but couldn't find more detailed usage instructions, and I discovered this issue while searching through existing issues. It seems I don't fully understand the comments for the function, and I couldn't find any relevant test cases to verify the handling of edge cases. I will close the current PR shortly. Thank you again for your professional guidance and patient explanation!

Thank you for your detailed explanation.
In this scenario, a strict range, as proposed in this PR, is reasonable. I prefer to accept this change, but adding an option, strictRange: boolean to enable it.

 visualMap: [
    {
      show: true,
      type: 'continuous',
      inverse: false,
      seriesIndex: [0],
      min: 50,
      max: 98,
      range: [50, 98],
      strictRange: true,
      // ...

will meet your requirement.

@abdurrahmanyildirim
Copy link

abdurrahmanyildirim commented Jul 17, 2025

The currently behavior is by design. Historically, the visualMap "range" (which represents the selected range of data values) has a special meaning when it reaches both upper and lower bounds (i.e., option visualMap.min/max): it indicates "select all" (i.e., all data values are considered "in range", or, the range becomes [-Infinity, Infinity]). This strategy was introduced because otherwise, there is no way to express "select all" if some data values is outside the visualMap.min/max. I think this is also a compromise due to the fact that visualMap.min/max only support absolute numeric values - percentage values or keyword values like "dataMin"/"dataMax" are not supported.

I think in most cases that doesn't matter, but there would be some scenarios overlooked. In your demo (codepen, I notice that the visualMap.max is set to be 98, so a node 100 can not be selected under the behavior proposed in this PR. Is it expected? Could we know the core requirements here - why need to always exclude the 100 from visualMap range? @lzl0304

image Nevertheless, I think a strict mapping is supposed to be supported - as proposed in this PR. But changing this behavior by default would introduce a breaking change: user would no longer to be able to "select all" if some data values fall outside `visualMap.min/max`, unless they manually calculate and set those bounds in advance - that's not a easy fix.

Therefore, I suggest that introduce an extra option, such as visualMap.strictRange: boolean or visualMap.disableAutoFullRange: boolean to prevent the current behavior.

Thanks for the detailed explanation. When I use a range, I expect it to prevent values outside of the defined limits.

It only works as expected when I input a value smaller than the max, like in the screenshot:

image

That said, your approach makes sense. At least it won’t introduce breaking changes.
We can move forward with the strictRange: true option—this way, the default behavior remains unchanged.

Alternatively, the range could be enforced strictly if outOfRange is provided.

@100pah 100pah merged commit a71fdb5 into apache:master Jul 17, 2025
@100pah 100pah mentioned this pull request Jul 17, 2025
3 tasks
@Ovilia Ovilia added this to the 6.0.0 milestone Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants