diff --git a/__tests__/integration/snapshots/static/singlePointBasic.svg b/__tests__/integration/snapshots/static/singlePointBasic.svg new file mode 100644 index 0000000000..021449205d --- /dev/null +++ b/__tests__/integration/snapshots/static/singlePointBasic.svg @@ -0,0 +1,1034 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 124.9979274466 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 156.2049208855 + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 140.7391648118 + + + + + + + + + y + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/__tests__/plots/static/index.ts b/__tests__/plots/static/index.ts index 8cf5c9d2f0..fb30c833dc 100644 --- a/__tests__/plots/static/index.ts +++ b/__tests__/plots/static/index.ts @@ -303,3 +303,4 @@ export { mockLineZeroX } from './mock-line-zero-x'; export { mockLineZeroY } from './mock-line-zero-y'; export { mockLineCloseX } from './mock-line-close-x'; export { premierLeagueTable } from './premier-league-table'; +export { singlePointBasic } from './single-point-basic'; diff --git a/__tests__/plots/static/single-point-basic.ts b/__tests__/plots/static/single-point-basic.ts new file mode 100644 index 0000000000..3997e37c97 --- /dev/null +++ b/__tests__/plots/static/single-point-basic.ts @@ -0,0 +1,21 @@ +import { G2Spec } from '../../../src'; + +export function singlePointBasic(): G2Spec { + return { + type: 'point', + data: [ + { + x: 156.2049208855, + y: 140.7391648118, + z: 124.9979274466, + }, + ], + encode: { + x: 'x', + y: 'y', + size: 'z', + }, + }; +} + +singlePointBasic.maxError = 100; diff --git a/src/component/legendContinuous.ts b/src/component/legendContinuous.ts index 6a7fcb0d3b..858a4864b8 100644 --- a/src/component/legendContinuous.ts +++ b/src/component/legendContinuous.ts @@ -161,7 +161,7 @@ function getLinearConfig( data: scale.getTicks().map((value) => ({ value })), color: new Array(Math.floor(length)).fill(0).map((d, i) => { const value = ((max - min) / (length - 1)) * i + min; - const color = scale.map(value); + const color = scale.map(value) || defaultColor; const opacity = opacityScale ? opacityScale.map(value) : 1; return color.replace( /rgb[a]*\(([\d]{1,3}) *, *([\d]{1,3}) *, *([\d]{1,3})[\S\s]*\)/,