diff --git a/__tests__/integration/snapshots/static/aaplLineIllegalDataSlider.svg b/__tests__/integration/snapshots/static/aaplLineIllegalDataSlider.svg new file mode 100644 index 0000000000..134a4ecd95 --- /dev/null +++ b/__tests__/integration/snapshots/static/aaplLineIllegalDataSlider.svg @@ -0,0 +1,2259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (东北, 长春) + + + + + + + + + + + + + + + + + + + + + + (华东, 江西) + + + + + + + + + + + + + + value + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10000 + + + + + + + 15000 + + + + + + + 20000 + + + + + + + 25000 + + + + + + + 30000 + + + + + + + 35000 + + + + + + + 40000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (东北, 长春) + + + + + + + (东北, 辽宁) + + + + + + + (, 辽宁) + + + + + + + (华东, 上海) + + + + + + + (华东, 山东) + + + + + + + (华东, 江苏) + + + + + + + (华东, 江西) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10000 + + + + + + + 15000 + + + + + + + 20000 + + + + + + + 25000 + + + + + + + 30000 + + + + + + + 35000 + + + + + + + 40000 + + + + + + + + + value + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/__tests__/plots/static/aapl-line-illegal-data-slider.ts b/__tests__/plots/static/aapl-line-illegal-data-slider.ts new file mode 100644 index 0000000000..ad6a6c3788 --- /dev/null +++ b/__tests__/plots/static/aapl-line-illegal-data-slider.ts @@ -0,0 +1,54 @@ +import { G2Spec } from '../../../src'; + +export function aaplLineIllegalDataSlider(): G2Spec { + return { + type: 'line', + data: [ + { + area: '东北', + province: '长春', + value: 10000, + }, + { + area: '东北', + province: '辽宁', + value: 10000, + }, + { + area: '', + province: '辽宁', + value: null, + }, + { + area: '华东', + province: '上海', + value: 10000, + }, + { + area: '华东', + province: '山东', + value: 40000, + }, + { + area: '华东', + province: '江苏', + value: 10000, + }, + { + area: '华东', + province: '江西', + value: 10000, + }, + ], + encode: { + x: (x) => `(${x.area}, ${x.province})`, + y: 'value', + color: 'value', + }, + scale: { + color: { type: 'linear', unknown: '#fff' }, + }, + style: { gradient: 'y', lineWidth: 2 }, + slider: { x: true }, + }; +} diff --git a/__tests__/plots/static/index.ts b/__tests__/plots/static/index.ts index 2a36c3bd6e..349b4a4744 100644 --- a/__tests__/plots/static/index.ts +++ b/__tests__/plots/static/index.ts @@ -316,4 +316,5 @@ export { titanicPointPackSharedDataPadding } from './titanic-point-pack-shared-d export { scoreByItemAreaBasicRadar } from './score-by-item-area-basic-radar'; export { scoreByItemAreaLineRadar } from './score-by-item-area-line-radar'; export { mockComplexRadar } from './mock-complex-radar'; +export { aaplLineIllegalDataSlider } from './aapl-line-illegal-data-slider'; export { mockSquareRadar } from './mock-square-radar'; diff --git a/src/shape/utils.ts b/src/shape/utils.ts index db39b148be..46828c05d1 100644 --- a/src/shape/utils.ts +++ b/src/shape/utils.ts @@ -1,6 +1,6 @@ import { Coordinate } from '@antv/coord'; import { Linear } from '@antv/scale'; -import { lowerFirst } from '@antv/util'; +import { isNumber, lowerFirst } from '@antv/util'; import { extent } from 'd3-array'; import { Path as D3Path } from 'd3-path'; import { Primitive, Vector2, Vector3 } from '../runtime'; @@ -148,7 +148,8 @@ export function computeGradient( range: [0, 100], }); - const percentage = (i) => p.map(P[i]); + const percentage = (i) => + isNumber(P[i]) && !Number.isNaN(P[i]) ? p.map(P[i]) : 0; const gradientMode = { // Interpolate the colors for this segment.