diff --git a/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-0.png b/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-0.png index a831d6b77c..4471e12a8c 100644 Binary files a/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-0.png and b/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-0.png differ diff --git a/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-1.png b/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-1.png index 7f478dab3c..e021314006 100644 Binary files a/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-1.png and b/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-1.png differ diff --git a/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-2.png b/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-2.png index 021bc8be13..7027080b96 100644 Binary files a/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-2.png and b/__tests__/integration/snapshots/animation/os-area-stack-enter/interval0-2.png differ diff --git a/__tests__/integration/snapshots/api/chart-emit-brush-highlight-axis-cross/step0.png b/__tests__/integration/snapshots/api/chart-emit-brush-highlight-axis-cross/step0.png index 50f2a73bd2..772449c4ee 100644 Binary files a/__tests__/integration/snapshots/api/chart-emit-brush-highlight-axis-cross/step0.png and b/__tests__/integration/snapshots/api/chart-emit-brush-highlight-axis-cross/step0.png differ diff --git a/__tests__/integration/snapshots/api/chart-emit-brush-highlight-axis-cross/step1.png b/__tests__/integration/snapshots/api/chart-emit-brush-highlight-axis-cross/step1.png index 861e1bc091..8c989353f3 100644 Binary files a/__tests__/integration/snapshots/api/chart-emit-brush-highlight-axis-cross/step1.png and b/__tests__/integration/snapshots/api/chart-emit-brush-highlight-axis-cross/step1.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-axis/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-axis/step0.png index ed66589f31..b0f783a118 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-axis/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-axis/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-axis/step1.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-axis/step1.png index 9138d670ea..45af81b7b4 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-axis/step1.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-axis/step1.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step0.png index 00d0ab91e4..176c90099a 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step1.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step1.png index ce7fb6b472..279f3e61ca 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step1.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step1.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step2.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step2.png index b9a68656df..b25091e847 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step2.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-filter/step2.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step0.png index 1e526ca8a4..a05604f668 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step1.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step1.png index 512bc93f14..5081a3c0ac 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step1.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step1.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step10.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step10.png index 8bd84d48c6..d513566620 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step10.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step10.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step11.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step11.png index 77343e4eff..c5d5c61a9f 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step11.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step11.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step2.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step2.png index e25af66dbe..f5f93516e9 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step2.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step2.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step3.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step3.png index b110102873..1337b5216f 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step3.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step3.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step4.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step4.png index 7fd708baed..997009e1e8 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step4.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step4.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step5.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step5.png index c4f2e2b77c..01e0fe81de 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step5.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step5.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step6.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step6.png index 3a3e4430ff..a7b24e4450 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step6.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step6.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step7.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step7.png index fe486e251e..4112819955 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step7.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step7.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step8.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step8.png index cfae114a0a..ce25ad4326 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step8.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step8.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step9.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step9.png index 1b0f749241..81059ead5b 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step9.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-custom/step9.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-style/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-style/step0.png index 158273225a..565fa21e37 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-style/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-handle-style/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step0.png index ce4713fe4c..2d70a1edb2 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step1.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step1.png index 959e7f5f82..e529955354 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step1.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-reverse/step1.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-x-filter/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-x-filter/step0.png index c168db76fb..bc9e1d27cb 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-x-filter/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-x-filter/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-x/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-x/step0.png index f0a3e502d1..6438329a10 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-x/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-x/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-y-filter/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-y-filter/step0.png index f0b7262701..f801227fcd 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-y-filter/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-y-filter/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush-y/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush-y/step0.png index 7b1dfff16e..dad46811c3 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush-y/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush-y/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step0.png index aa0c8a6c75..cdbc7c1e4e 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step0.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step1.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step1.png index 303756af92..118bfc8f7d 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step1.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step1.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step10.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step10.png index edf0207ccd..001a07d9ac 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step10.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step10.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step11.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step11.png index d07d21b5eb..11a0e2adb3 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step11.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step11.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step2.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step2.png index 1d3a725be0..747eab12a8 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step2.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step2.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step3.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step3.png index b318595b82..85233ae1f7 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step3.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step3.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step4.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step4.png index 0474520c29..ae97212736 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step4.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step4.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step5.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step5.png index e1fa1e3c22..7d2d5f1dd6 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step5.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step5.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step6.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step6.png index 3db4fd7374..02b282676a 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step6.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step6.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step7.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step7.png index fa7461851a..31b4e402c8 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step7.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step7.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step8.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step8.png index ee5cab9278..6d6966450d 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step8.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step8.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-brush/step9.png b/__tests__/integration/snapshots/interaction/penguins-point-brush/step9.png index fda0258503..f4b12f7732 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-brush/step9.png and b/__tests__/integration/snapshots/interaction/penguins-point-brush/step9.png differ diff --git a/__tests__/integration/snapshots/interaction/penguins-point-highlight/step0.png b/__tests__/integration/snapshots/interaction/penguins-point-highlight/step0.png index 92c6b07369..94d20dc555 100644 Binary files a/__tests__/integration/snapshots/interaction/penguins-point-highlight/step0.png and b/__tests__/integration/snapshots/interaction/penguins-point-highlight/step0.png differ diff --git a/__tests__/integration/snapshots/static/agesIntervalRadialStacked.png b/__tests__/integration/snapshots/static/agesIntervalRadialStacked.png index 2413a2ae52..7397bbee3c 100644 Binary files a/__tests__/integration/snapshots/static/agesIntervalRadialStacked.png and b/__tests__/integration/snapshots/static/agesIntervalRadialStacked.png differ diff --git a/__tests__/integration/snapshots/static/agesIntervalRadialStackedSorted.png b/__tests__/integration/snapshots/static/agesIntervalRadialStackedSorted.png index ea90efb332..31fb4e029d 100644 Binary files a/__tests__/integration/snapshots/static/agesIntervalRadialStackedSorted.png and b/__tests__/integration/snapshots/static/agesIntervalRadialStackedSorted.png differ diff --git a/__tests__/integration/snapshots/static/cars2PointConstantColorSize.png b/__tests__/integration/snapshots/static/cars2PointConstantColorSize.png index c1940c06b4..53e1c5124d 100644 Binary files a/__tests__/integration/snapshots/static/cars2PointConstantColorSize.png and b/__tests__/integration/snapshots/static/cars2PointConstantColorSize.png differ diff --git a/__tests__/integration/snapshots/static/cars2PointJitterY.png b/__tests__/integration/snapshots/static/cars2PointJitterY.png index 62c3c8d4a1..78f6a349e1 100644 Binary files a/__tests__/integration/snapshots/static/cars2PointJitterY.png and b/__tests__/integration/snapshots/static/cars2PointJitterY.png differ diff --git a/__tests__/integration/snapshots/static/cars2PointOrdinalSize.png b/__tests__/integration/snapshots/static/cars2PointOrdinalSize.png index 2a3cb40fa0..8b24fb8d20 100644 Binary files a/__tests__/integration/snapshots/static/cars2PointOrdinalSize.png and b/__tests__/integration/snapshots/static/cars2PointOrdinalSize.png differ diff --git a/__tests__/integration/snapshots/static/irisPointShapesDefaults.png b/__tests__/integration/snapshots/static/irisPointShapesDefaults.png index 9f5c99dc61..1668a1730a 100644 Binary files a/__tests__/integration/snapshots/static/irisPointShapesDefaults.png and b/__tests__/integration/snapshots/static/irisPointShapesDefaults.png differ diff --git a/__tests__/integration/snapshots/static/titanic2PointPack.png b/__tests__/integration/snapshots/static/titanic2PointPack.png index e02e618f66..6cac90c5c4 100644 Binary files a/__tests__/integration/snapshots/static/titanic2PointPack.png and b/__tests__/integration/snapshots/static/titanic2PointPack.png differ diff --git a/__tests__/integration/snapshots/static/titanicPointPack.png b/__tests__/integration/snapshots/static/titanicPointPack.png index 4661e68102..f9519b7f13 100644 Binary files a/__tests__/integration/snapshots/static/titanicPointPack.png and b/__tests__/integration/snapshots/static/titanicPointPack.png differ diff --git a/__tests__/integration/snapshots/static/titanicPointPackNested.png b/__tests__/integration/snapshots/static/titanicPointPackNested.png index 4dc3561769..d0a5c00abc 100644 Binary files a/__tests__/integration/snapshots/static/titanicPointPackNested.png and b/__tests__/integration/snapshots/static/titanicPointPackNested.png differ diff --git a/__tests__/integration/snapshots/static/titanicPointPackSharedData.png b/__tests__/integration/snapshots/static/titanicPointPackSharedData.png index c671b8e856..34a280c052 100644 Binary files a/__tests__/integration/snapshots/static/titanicPointPackSharedData.png and b/__tests__/integration/snapshots/static/titanicPointPackSharedData.png differ diff --git a/__tests__/integration/snapshots/static/titanicPointPackSharedSize.png b/__tests__/integration/snapshots/static/titanicPointPackSharedSize.png index bbf1e7df29..c28e9ba949 100644 Binary files a/__tests__/integration/snapshots/static/titanicPointPackSharedSize.png and b/__tests__/integration/snapshots/static/titanicPointPackSharedSize.png differ diff --git a/__tests__/integration/snapshots/static/weatherLineRepeatMatrixCol.png b/__tests__/integration/snapshots/static/weatherLineRepeatMatrixCol.png index 4407741d3d..c6329f54bb 100644 Binary files a/__tests__/integration/snapshots/static/weatherLineRepeatMatrixCol.png and b/__tests__/integration/snapshots/static/weatherLineRepeatMatrixCol.png differ diff --git a/__tests__/plots/static/cars2-point-constant-color-size.ts b/__tests__/plots/static/cars2-point-constant-color-size.ts index 1df6e2b87f..316e8a35f7 100644 --- a/__tests__/plots/static/cars2-point-constant-color-size.ts +++ b/__tests__/plots/static/cars2-point-constant-color-size.ts @@ -1,6 +1,5 @@ import { G2Spec } from '../../../src'; -// @todo Fix marker stroke of @antv/gui. export function cars2PointConstantColorSize(): G2Spec { return { type: 'point', diff --git a/__tests__/plots/static/cars2-point-ordinal-size.ts b/__tests__/plots/static/cars2-point-ordinal-size.ts index 1522576b4b..37d4b9a640 100644 --- a/__tests__/plots/static/cars2-point-ordinal-size.ts +++ b/__tests__/plots/static/cars2-point-ordinal-size.ts @@ -1,6 +1,5 @@ import { G2Spec } from '../../../src'; -// @todo Fix category item align in @antv/gui. export function cars2PointOrdinalSize(): G2Spec { return { type: 'point', @@ -16,6 +15,10 @@ export function cars2PointOrdinalSize(): G2Spec { size: 'Origin', shape: 'point', }, - scale: { x: { nice: true }, y: { nice: true } }, + scale: { + x: { nice: true }, + y: { nice: true }, + size: { rangeMax: 20 }, + }, }; } diff --git a/src/component/legendCategory.ts b/src/component/legendCategory.ts index 0ca118d891..3ad3097c60 100644 --- a/src/component/legendCategory.ts +++ b/src/component/legendCategory.ts @@ -38,19 +38,6 @@ export type LegendCategoryOptions = { [key: string]: any; }; -function createShape( - shape: string, - library: G2Library, - coordinate: Coordinate, - theme: G2Theme, - style: Record = {}, -) { - const marker = - (library[`shape.${shape}`]?.props?.defaultMarker as string) || - last(shape.split('.')); - return () => useMarker(marker, style)(0, 0, 6); -} - function inferShape(scales: Scale[], markState: Map) { const shapeScale = scaleOf(scales, 'shape'); const colorScale = scaleOf(scales, 'color'); @@ -93,28 +80,35 @@ function inferShape(scales: Scale[], markState: Map) { function inferItemMarker( options, - { scales, library, coordinate, theme, markState }: GuideComponentContext, + context: GuideComponentContext, ): ((datum: any, i: number, data: any) => () => DisplayObject) | undefined { + const { scales, library, markState } = context; const [namespace, shapes] = inferShape(scales, markState); - const create = (name, color) => - createShape(name, library, coordinate, theme, { - color, - }); + + const { itemMarker, itemMarkerSize: size } = options; + + const create = (name, d) => { + const marker = + (library[`shape.${name}`]?.props?.defaultMarker as string) || + last(name.split('.')); + const radius = typeof size === 'function' ? size(d) : size; + return () => useMarker(marker, { color: d.color })(0, 0, radius); + }; + const shapeOf = (i) => `${namespace}.${shapes[i]}`; - const { itemMarker } = options; const shapeScale = scaleOf(scales, 'shape'); - if (shapeScale && !itemMarker) return (d, i) => create(shapeOf(i), d.color); + if (shapeScale && !itemMarker) return (d, i) => create(shapeOf(i), d); if (typeof itemMarker === 'function') { return (d, i) => { // @todo Fix this in GUI. // It should pass primitive value rather object. const node = itemMarker(d.id, i); - if (typeof node === 'string') return create(node, d.color); + if (typeof node === 'string') return create(node, d); return node; }; } - return (d, i) => create(itemMarker || shapeOf(i), d.color); + return (d, i) => create(itemMarker || shapeOf(i), d); } function inferItemMarkerOpacity(scales: Scale[]) { @@ -129,19 +123,17 @@ function inferItemMarkerOpacity(scales: Scale[]) { function inferItemMarkerSize(scales: Scale[], defaults: number) { const scale = scaleOf(scales, 'size'); if (scale instanceof Identity) return scale.map(NaN) * 2; - if (scale instanceof Point) return ({ id }) => scale.map(id) * 2; return defaults; } function inferCategoryStyle(options, context: GuideComponentContext) { const { labelFormatter = (d) => `${d}` } = options; const { scales, theme } = context; + const defaultSize = theme.legendCategory.itemMarkerSize; + const itemMarkerSize = inferItemMarkerSize(scales, defaultSize); const baseStyle = { - itemMarker: inferItemMarker(options, context), - itemMarkerSize: inferItemMarkerSize( - scales, - theme.legendCategory.itemMarkerSize, - ), + itemMarker: inferItemMarker({ ...options, itemMarkerSize }, context), + itemMarkerSize: itemMarkerSize, itemMarkerOpacity: inferItemMarkerOpacity(scales), }; diff --git a/src/runtime/component.ts b/src/runtime/component.ts index 703d2c8e28..416cca5f47 100644 --- a/src/runtime/component.ts +++ b/src/runtime/component.ts @@ -757,20 +757,9 @@ function computeCategoryLegendSize( theme: G2Theme, library: G2Library, ) { - const itemMakerSizeOf = () => { - const { itemMarkerSize } = component.style || {}; - if (itemMarkerSize) return itemMarkerSize; - const { scales } = component; - const size = scales.find((d) => d.name === 'size'); - if (!size) return itemMarkerSize; - return size.range[1] * 2; - }; - const styleOf = () => { const { legendCategory } = theme; - return deepMix({}, legendCategory, component.style, { - itemMarkerSize: itemMakerSizeOf(), - }); + return deepMix({}, legendCategory, component.style); }; const {