Ovilia commented on code in PR #21524:
URL: https://github.com/apache/echarts/pull/21524#discussion_r2875614362
##########
src/scale/helper.ts:
##########
@@ -128,48 +126,16 @@ export function contain(val: number, extent: [number,
number]): boolean {
return val >= extent[0] && val <= extent[1];
}
-export class ScaleCalculator {
-
- normalize: (val: number, extent: [number, number]) => number = normalize;
- scale: (val: number, extent: [number, number]) => number = scale;
-
- updateMethods(brkCtx: ScaleBreakContext) {
- if (brkCtx.hasBreaks()) {
- this.normalize = bind(brkCtx.normalize, brkCtx);
- this.scale = bind(brkCtx.scale, brkCtx);
- }
- else {
- this.normalize = normalize;
- this.scale = scale;
- }
- }
-}
-
-function normalize(
- val: number,
- extent: [number, number],
- // Dont use optional arguments for performance consideration here.
-): number {
+export function normalize(val: number, extent: [number, number]): number {
if (extent[1] === extent[0]) {
- return 0.5;
+ // When extent collapses to a single point, only values equal to that
point
+ // should be normalized to 0.5. All other values should return NaN to
indicate
+ // they are out of range and should not be rendered.
+ return isNaN(val) || val !== extent[0] ? NaN : 0.5;
Review Comment:
I'm not sure `val !== extent[0]` is expected, please also help test the
cases for markPoints to display correctly for single data.
--
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]