From 08e112d20bbd3156b650cd44361aa5e9723aaa71 Mon Sep 17 00:00:00 2001 From: xile611 Date: Wed, 25 Dec 2024 11:51:46 +0800 Subject: [PATCH 1/6] perf: remove duplicated code in range-column --- .../src/series/range-column/range-column.ts | 74 ++++++------------- 1 file changed, 22 insertions(+), 52 deletions(-) diff --git a/packages/vchart/src/series/range-column/range-column.ts b/packages/vchart/src/series/range-column/range-column.ts index f8eef2d6a0..f27430fbbc 100644 --- a/packages/vchart/src/series/range-column/range-column.ts +++ b/packages/vchart/src/series/range-column/range-column.ts @@ -79,65 +79,35 @@ export class RangeColumnSeries { - const min = - this._spec.direction === Direction.horizontal ? datum[this._spec.xField[0]] : datum[this._spec.yField[0]]; - if (minLabelSpec?.formatMethod) { - return minLabelSpec.formatMethod(min, datum); - } - return min; - } - }); - const position = minLabelSpec?.position ?? 'end'; - const offset = minLabelSpec?.offset ?? (this._direction === 'vertical' ? -20 : -25); - setRectLabelPos( - this, - minLabelMark, - position, - offset, - (datum: Datum) => this._barMark.getAttribute('x', datum) as number, - (datum: Datum) => { - return this._direction === 'vertical' - ? (this._barMark.getAttribute('x', datum) as number) + - (this._barMark.getAttribute('width', datum) as number) - : (this._barMark.getAttribute('x1', datum) as number); - }, - (datum: Datum) => this._barMark.getAttribute('y', datum) as number, - (datum: Datum) => { - return this._direction === 'vertical' - ? (this._barMark.getAttribute('y1', datum) as number) - : (this._barMark.getAttribute('y', datum) as number) + - (this._barMark.getAttribute('height', datum) as number); - }, - () => this._direction - ); - } - - const maxLabelMark = this._maxLabelMark; - const maxLabelSpec = this._spec.label?.maxLabel; - if (maxLabelMark) { - this.setMarkStyle(maxLabelMark, { - fill: maxLabelSpec?.style?.fill ?? this.getColorAttribute(), + _initLabelMarkPos( + labelMark: ITextMark, + labelSpec: IRangeColumnSeriesSpec['label']['minLabel'], + fieldIndex: number, + defaultPosition: string + ): void { + if (labelMark) { + this.setMarkStyle(labelMark, { + fill: labelSpec?.style?.fill ?? this.getColorAttribute(), text: (datum: Datum) => { - const max = - this._spec.direction === Direction.horizontal ? datum[this._spec.xField[1]] : datum[this._spec.yField[1]]; - if (maxLabelSpec?.formatMethod) { - return maxLabelSpec.formatMethod(max, datum); + const val = + this._spec.direction === Direction.horizontal + ? datum[this._spec.xField[fieldIndex]] + : datum[this._spec.yField[fieldIndex]]; + if (labelSpec?.formatMethod) { + return labelSpec.formatMethod(val, datum); } - return max; + return val; } }); - const position = maxLabelSpec?.position ?? 'start'; - const offset = maxLabelSpec?.offset ?? (this._direction === 'vertical' ? -20 : -25); + const position = labelSpec?.position ?? defaultPosition; + const offset = labelSpec?.offset ?? (this._direction === 'vertical' ? -20 : -25); setRectLabelPos( this, - maxLabelMark, + labelMark, position, offset, (datum: Datum) => this._barMark.getAttribute('x', datum) as number, From a0850132fed4be434ae0d148a839b678fd547296 Mon Sep 17 00:00:00 2001 From: xile611 Date: Wed, 25 Dec 2024 12:02:34 +0800 Subject: [PATCH 2/6] perf: reduce duplicated code in theme --- .../builtin/common/component/mark-area.ts | 22 ++-------------- .../builtin/common/component/mark-line.ts | 26 ++++--------------- .../theme/builtin/common/component/mark.ts | 24 +++++++++++++++++ 3 files changed, 31 insertions(+), 41 deletions(-) create mode 100644 packages/vchart/src/theme/builtin/common/component/mark.ts diff --git a/packages/vchart/src/theme/builtin/common/component/mark-area.ts b/packages/vchart/src/theme/builtin/common/component/mark-area.ts index ba86060c0a..e153965fb5 100644 --- a/packages/vchart/src/theme/builtin/common/component/mark-area.ts +++ b/packages/vchart/src/theme/builtin/common/component/mark-area.ts @@ -1,4 +1,5 @@ import type { IMarkAreaTheme } from '../../../../component/marker/mark-area/interface'; +import { getCommonLabelTheme } from './mark'; export const markArea: IMarkAreaTheme = { area: { @@ -6,24 +7,5 @@ export const markArea: IMarkAreaTheme = { fill: { type: 'palette', key: 'axisDomainColor', a: 0.25 } } }, - label: { - style: { - fontSize: { type: 'token', key: 'l4FontSize' }, - fontWeight: 'normal', - fontStyle: 'normal', - fill: { type: 'palette', key: 'primaryFontColor' } - }, - labelBackground: { - padding: { - top: 2, - bottom: 2, - right: 4, - left: 4 - }, - style: { - cornerRadius: 3, - fill: { type: 'palette', key: 'markLabelBackgroundColor' } - } - } - } + label: getCommonLabelTheme() }; diff --git a/packages/vchart/src/theme/builtin/common/component/mark-line.ts b/packages/vchart/src/theme/builtin/common/component/mark-line.ts index 65f3efab7a..5803020ef8 100644 --- a/packages/vchart/src/theme/builtin/common/component/mark-line.ts +++ b/packages/vchart/src/theme/builtin/common/component/mark-line.ts @@ -1,5 +1,6 @@ import type { IMarkerSymbol } from '../../../../component/marker/interface'; import type { IMarkLineTheme } from '../../../../component/marker/mark-line/interface'; +import { getCommonLabelTheme } from './mark'; const getSymbolTheme = (visible?: boolean): IMarkerSymbol => { return { @@ -14,6 +15,9 @@ const getSymbolTheme = (visible?: boolean): IMarkerSymbol => { }; }; +const labelTheme = getCommonLabelTheme(); +labelTheme.refY = 5; + export const markLine: IMarkLineTheme = { line: { style: { @@ -23,25 +27,5 @@ export const markLine: IMarkLineTheme = { }, startSymbol: getSymbolTheme(false), endSymbol: getSymbolTheme(true), - label: { - refY: 5, - style: { - fontSize: { type: 'token', key: 'l4FontSize' }, - fontWeight: 'normal', - fontStyle: 'normal', - fill: { type: 'palette', key: 'primaryFontColor' } - }, - labelBackground: { - padding: { - top: 2, - bottom: 2, - right: 4, - left: 4 - }, - style: { - cornerRadius: 3, - fill: { type: 'palette', key: 'markLabelBackgroundColor' } - } - } - } + label: labelTheme }; diff --git a/packages/vchart/src/theme/builtin/common/component/mark.ts b/packages/vchart/src/theme/builtin/common/component/mark.ts new file mode 100644 index 0000000000..523c683ea5 --- /dev/null +++ b/packages/vchart/src/theme/builtin/common/component/mark.ts @@ -0,0 +1,24 @@ +import type { IMarkerLabelSpec } from '../../../../component/marker/interface'; + +export const getCommonLabelTheme = (): IMarkerLabelSpec => { + return { + style: { + fontSize: { type: 'token', key: 'l4FontSize' }, + fontWeight: 'normal', + fontStyle: 'normal', + fill: { type: 'palette', key: 'primaryFontColor' } + }, + labelBackground: { + padding: { + top: 2, + bottom: 2, + right: 4, + left: 4 + }, + style: { + cornerRadius: 3, + fill: { type: 'palette', key: 'markLabelBackgroundColor' } + } + } + }; +}; From cda84fdadb2df32537b8d89f2aa843e1de548fc4 Mon Sep 17 00:00:00 2001 From: xile611 Date: Wed, 25 Dec 2024 12:03:33 +0800 Subject: [PATCH 3/6] perf: reduce duplicated code in scatter --- packages/vchart/src/series/scatter/scatter.ts | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/packages/vchart/src/series/scatter/scatter.ts b/packages/vchart/src/series/scatter/scatter.ts index 49032cdedd..cd8ec146f2 100644 --- a/packages/vchart/src/series/scatter/scatter.ts +++ b/packages/vchart/src/series/scatter/scatter.ts @@ -382,28 +382,8 @@ export class ScatterSeries ex } handlePan(e: any) { - this.getMarksWithoutRoot().forEach(mark => { - const vGrammarMark = mark.getProduct(); - - if (!vGrammarMark || !vGrammarMark.elements || !vGrammarMark.elements.length) { - return; - } - const elements = vGrammarMark.elements; - - elements.forEach((el: IElement, i: number) => { - const graphicItem = el.getGraphicItem(); - const datum = el.getDatum(); - const newPosition = this.dataToPosition(datum); - if (newPosition && graphicItem) { - graphicItem.translateTo(newPosition.x, newPosition.y); - } - }); - }); - const vgrammarLabel = this._labelMark?.getComponent()?.getProduct(); - - if (vgrammarLabel) { - (vgrammarLabel as any).evaluate(null, null); - } + // TODO 现在处理好像一模一样 + this.handleZoom(e); } getDefaultShapeType() { From d538ece9e724046dbc5dbd9292f106fb44c7818c Mon Sep 17 00:00:00 2001 From: xile611 Date: Wed, 25 Dec 2024 16:45:04 +0800 Subject: [PATCH 4/6] perf: remove duplicated code in treemap --- packages/vchart/src/series/treemap/treemap.ts | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/packages/vchart/src/series/treemap/treemap.ts b/packages/vchart/src/series/treemap/treemap.ts index 339eeba415..3b6a6efc2c 100644 --- a/packages/vchart/src/series/treemap/treemap.ts +++ b/packages/vchart/src/series/treemap/treemap.ts @@ -338,6 +338,21 @@ export class TreemapSeries extends CartesianSeries { ); } + _initRichStyleOfLabelMark(labelMark: ILabelMark) { + if (labelMark.getTextType() === 'rich') { + this.setMarkStyle( + labelMark, + { + maxWidth: datum => Math.abs(datum.x0 - datum.x1), + maxHeight: datum => Math.abs(datum.y0 - datum.y1), + ellipsis: true + }, + STATE_VALUE_ENUM.STATE_NORMAL, + AttributeLevel.Series + ); + } + } + initLabelMarkStyle(labelMark: ILabelMark) { if (!labelMark) { return; @@ -359,18 +374,8 @@ export class TreemapSeries extends CartesianSeries { STATE_VALUE_ENUM.STATE_NORMAL, AttributeLevel.Series ); - if (labelMark.getTextType() === 'rich') { - this.setMarkStyle( - labelMark, - { - maxWidth: datum => Math.abs(datum.x0 - datum.x1), - maxHeight: datum => Math.abs(datum.y0 - datum.y1), - ellipsis: true - }, - STATE_VALUE_ENUM.STATE_NORMAL, - AttributeLevel.Series - ); - } + + this._initRichStyleOfLabelMark(labelMark); } protected initNonLeafLabelMarkStyle(labelMark: ILabelMark) { @@ -404,18 +409,7 @@ export class TreemapSeries extends CartesianSeries { STATE_VALUE_ENUM.STATE_NORMAL, AttributeLevel.Series ); - if (labelMark.getTextType() === 'rich') { - this.setMarkStyle( - labelMark, - { - maxWidth: datum => Math.abs(datum.x0 - datum.x1), - maxHeight: datum => Math.abs(datum.y0 - datum.y1), - ellipsis: true - }, - STATE_VALUE_ENUM.STATE_NORMAL, - AttributeLevel.Series - ); - } + this._initRichStyleOfLabelMark(labelMark); } initAnimation(): void { From 1d9835c665c44d79df799a2914a9a9c647d56583 Mon Sep 17 00:00:00 2001 From: xile611 Date: Wed, 25 Dec 2024 17:07:38 +0800 Subject: [PATCH 5/6] perf: reduce duplicated code about hierarchy series --- .../series/circle-packing/circle-packing.ts | 23 ++------------- packages/vchart/src/series/polar/polar.ts | 3 +- .../vchart/src/series/sunburst/sunburst.ts | 23 ++------------- packages/vchart/src/series/treemap/treemap.ts | 23 ++------------- packages/vchart/src/series/util/hierarchy.ts | 29 +++++++++++++++++++ 5 files changed, 40 insertions(+), 61 deletions(-) create mode 100644 packages/vchart/src/series/util/hierarchy.ts diff --git a/packages/vchart/src/series/circle-packing/circle-packing.ts b/packages/vchart/src/series/circle-packing/circle-packing.ts index 092f77f39a..7ad17e82d4 100644 --- a/packages/vchart/src/series/circle-packing/circle-packing.ts +++ b/packages/vchart/src/series/circle-packing/circle-packing.ts @@ -19,7 +19,7 @@ import { MarkTypeEnum } from '../../mark/interface/type'; import { STATE_VALUE_ENUM } from '../../compile/mark/interface'; import { DEFAULT_DATA_KEY } from '../../constant/data'; import { AttributeLevel } from '../../constant/attribute'; -import { DEFAULT_HIERARCHY_DEPTH, DEFAULT_HIERARCHY_ROOT } from '../../constant/hierarchy'; +import { DEFAULT_HIERARCHY_ROOT } from '../../constant/hierarchy'; import type { CirclePackingNodeElement } from '@visactor/vgrammar-hierarchy'; import { flatten } from '../../data/transforms/flatten'; import { CirclePackingTooltipHelper } from './tooltip-helper'; @@ -34,6 +34,7 @@ import { Drillable } from '../../interaction/drill/drillable'; import { registerArcMark } from '../../mark/arc'; import { registerTextMark } from '../../mark/text'; import { circlePackingSeriesMark } from './constant'; +import { appendHierarchyFields } from '../util/hierarchy'; export class CirclePackingSeries< T extends ICirclePackingSeriesSpec = ICirclePackingSeriesSpec @@ -251,25 +252,7 @@ export class CirclePackingSeries< } getStatisticFields() { - const fields = super.getStatisticFields(); - return fields.concat([ - { - key: this._categoryField, - operations: ['values'] - }, - { - key: this._valueField, - operations: ['max', 'min'] - }, - { - key: DEFAULT_HIERARCHY_DEPTH, - operations: ['max', 'min', 'values'] - }, - { - key: DEFAULT_HIERARCHY_ROOT, - operations: ['values'] - } - ]); + return appendHierarchyFields(super.getStatisticFields(), this._categoryField, this._valueField); } protected initTooltip() { diff --git a/packages/vchart/src/series/polar/polar.ts b/packages/vchart/src/series/polar/polar.ts index 65cf28956e..b4c3e07ac5 100644 --- a/packages/vchart/src/series/polar/polar.ts +++ b/packages/vchart/src/series/polar/polar.ts @@ -11,6 +11,7 @@ import type { IPolarSeriesSpec } from './interface'; import type { Datum, StringOrNumber } from '../../typings'; import { sortDataInAxisHelper } from '../util/utils'; import { ChartEvent } from '../../constant/event'; +import type { StatisticOperations } from '../../data/transforms/interface'; export abstract class PolarSeries extends BaseSeries @@ -165,7 +166,7 @@ export abstract class PolarSeries } getStatisticFields() { - const fields: { key: string; operations: Array<'max' | 'min' | 'values'> }[] = []; + const fields: { key: string; operations: StatisticOperations }[] = []; if (this.radiusAxisHelper?.getScale) { this._radiusField.forEach(f => { const result: { key: string; operations: Array<'max' | 'min' | 'values'> } = { key: f, operations: [] }; diff --git a/packages/vchart/src/series/sunburst/sunburst.ts b/packages/vchart/src/series/sunburst/sunburst.ts index e6aeb99309..eb1984c0f5 100644 --- a/packages/vchart/src/series/sunburst/sunburst.ts +++ b/packages/vchart/src/series/sunburst/sunburst.ts @@ -23,7 +23,7 @@ import { MarkTypeEnum } from '../../mark/interface/type'; import { DEFAULT_DATA_KEY } from '../../constant/data'; import { AttributeLevel } from '../../constant/attribute'; import { STATE_VALUE_ENUM } from '../../compile/mark/interface'; -import { DEFAULT_HIERARCHY_DEPTH, DEFAULT_HIERARCHY_ROOT } from '../../constant/hierarchy'; +import { DEFAULT_HIERARCHY_ROOT } from '../../constant/hierarchy'; import { registerFadeInOutAnimation } from '../../animation/config'; import { addHierarchyDataKey, initHierarchyKeyMap } from '../../data/transforms/data-key'; import { addVChartProperty } from '../../data/transforms/add-property'; @@ -38,6 +38,7 @@ import { registerArcMark } from '../../mark/arc'; import { registerTextMark } from '../../mark/text'; import { sunburstSeriesMark } from './constant'; import { Factory } from '../../core/factory'; +import { appendHierarchyFields } from '../util/hierarchy'; export class SunburstSeries extends PolarSeries { protected declare _spec: ISunburstSeriesSpec; @@ -202,25 +203,7 @@ export class SunburstSeries extends PolarSeries { } getStatisticFields() { - const fields = super.getStatisticFields(); - return fields.concat([ - { - key: this._categoryField, - operations: ['values'] - }, - { - key: this._valueField, - operations: ['max', 'min'] - }, - { - key: DEFAULT_HIERARCHY_DEPTH, - operations: ['max', 'min', 'values'] - }, - { - key: DEFAULT_HIERARCHY_ROOT, - operations: ['values'] - } - ]); + return appendHierarchyFields(super.getStatisticFields(), this._categoryField, this._valueField); } protected _addDataIndexAndKey() { diff --git a/packages/vchart/src/series/treemap/treemap.ts b/packages/vchart/src/series/treemap/treemap.ts index 3b6a6efc2c..599357feca 100644 --- a/packages/vchart/src/series/treemap/treemap.ts +++ b/packages/vchart/src/series/treemap/treemap.ts @@ -21,7 +21,7 @@ import { DataView } from '@visactor/vdataset'; import { hierarchyDimensionStatistics } from '../../data/transforms/hierarchy-dimension-statistics'; import { addVChartProperty } from '../../data/transforms/add-property'; import { addHierarchyDataKey, initHierarchyKeyMap } from '../../data/transforms/data-key'; -import { DEFAULT_HIERARCHY_DEPTH, DEFAULT_HIERARCHY_ROOT } from '../../constant/hierarchy'; +import { DEFAULT_HIERARCHY_ROOT } from '../../constant/hierarchy'; import { TreemapTooltipHelper } from './tooltip-helper'; import { animationConfig, userAnimationConfig } from '../../animation/utils'; import { registerFadeInOutAnimation } from '../../animation/config'; @@ -37,6 +37,7 @@ import { Factory } from '../../core/factory'; import { registerTreemapAnimation } from './animation'; import { TreemapSeriesSpecTransformer } from './treemap-transform'; import { registerFilterTransform, registerMapTransform } from '@visactor/vgrammar-core'; +import { appendHierarchyFields } from '../util/hierarchy'; export class TreemapSeries extends CartesianSeries { static readonly type: string = SeriesTypeEnum.treemap; @@ -229,25 +230,7 @@ export class TreemapSeries extends CartesianSeries { } getStatisticFields() { - const fields = super.getStatisticFields(); - return fields.concat([ - { - key: this._categoryField, - operations: ['values'] - }, - { - key: this._valueField, - operations: ['max', 'min'] - }, - { - key: DEFAULT_HIERARCHY_DEPTH, - operations: ['max', 'min', 'values'] - }, - { - key: DEFAULT_HIERARCHY_ROOT, - operations: ['values'] - } - ]); + return appendHierarchyFields(super.getStatisticFields(), this._categoryField, this._valueField); } initMark() { diff --git a/packages/vchart/src/series/util/hierarchy.ts b/packages/vchart/src/series/util/hierarchy.ts new file mode 100644 index 0000000000..4bd48ca02c --- /dev/null +++ b/packages/vchart/src/series/util/hierarchy.ts @@ -0,0 +1,29 @@ +import type { StatisticOperations } from '../../data/transforms/interface'; +import { DEFAULT_HIERARCHY_DEPTH, DEFAULT_HIERARCHY_ROOT } from '../../constant/hierarchy'; + +export const appendHierarchyFields = ( + fields: { key: string; operations: StatisticOperations }[], + catField: string, + valueField: string +) => { + fields.push({ + key: catField, + operations: ['values'] + }); + fields.push({ + key: valueField, + operations: ['max', 'min'] + }); + + fields.push({ + key: DEFAULT_HIERARCHY_DEPTH, + operations: ['max', 'min', 'values'] + }); + + fields.push({ + key: DEFAULT_HIERARCHY_ROOT, + operations: ['values'] + }); + + return fields; +}; From 76cb8f25db616bd267164dc64a0fb4d6c42aac36 Mon Sep 17 00:00:00 2001 From: xile611 Date: Wed, 25 Dec 2024 17:47:29 +0800 Subject: [PATCH 6/6] perf: reduce duplicated about dataView --- .../src/component/marker/base-marker.ts | 33 ++++++++++++++++++- .../marker/mark-area/base-mark-area.ts | 31 +---------------- .../marker/mark-line/base-mark-line.ts | 3 +- .../marker/mark-point/base-mark-point.ts | 29 +--------------- packages/vchart/src/series/radar/radar.ts | 2 -- 5 files changed, 35 insertions(+), 63 deletions(-) diff --git a/packages/vchart/src/component/marker/base-marker.ts b/packages/vchart/src/component/marker/base-marker.ts index 5db91bc3de..9dd0adf385 100644 --- a/packages/vchart/src/component/marker/base-marker.ts +++ b/packages/vchart/src/component/marker/base-marker.ts @@ -13,7 +13,8 @@ import type { IDataPosCallback, IMarkerAttributeContext, IMarkerSpec, - IMarkerSupportSeries + IMarkerSupportSeries, + IMarkProcessOptions } from './interface'; import type { IGraphic, IGroup } from '@visactor/vrender-core'; import { calcLayoutNumber } from '../../util/space'; @@ -22,6 +23,9 @@ import { getFirstSeries } from '../../util'; import { arrayParser } from '../../data/parser/array'; import { getSpecInfo } from '../util'; import type { IOptionWithCoordinates } from '../../data/transforms/interface'; +import { registerDataSetInstanceTransform } from '../../data/register'; +import { markerAggregation } from '../../data/transforms/aggregation'; +import { markerFilter } from '../../data/transforms/marker-filter'; export abstract class BaseMarker extends BaseComponent { layoutType: ILayoutType | 'none' = 'none'; @@ -56,6 +60,7 @@ export abstract class BaseMarker extends BaseComponent protected abstract _initDataView(): void; protected abstract _createMarkerComponent(): IGroup; protected abstract _markerLayout(): void; + protected abstract _computeOptions(): IMarkProcessOptions; // 该方法需要子组件复写 static _getMarkerCoordinateType(markerSpec: any): string { return 'cartesian'; @@ -269,4 +274,30 @@ export abstract class BaseMarker extends BaseComponent } return result; } + + _initCommonDataView() { + const { options } = this._computeOptions(); + + const seriesData = this._getRelativeDataView(); + registerDataSetInstanceTransform(this._option.dataSet, 'markerAggregation', markerAggregation); + registerDataSetInstanceTransform(this._option.dataSet, 'markerFilter', markerFilter); + const data = new DataView(this._option.dataSet, { name: `${this.type}_${this.id}_data` }); + data.parse([seriesData], { + type: 'dataview' + }); + data.transform({ + type: 'markerAggregation', + options + }); + + data.transform({ + type: 'markerFilter', + options: this._getAllRelativeSeries() + }); + + data.target.on('change', () => { + this._markerLayout(); + }); + this._markerData = data; + } } diff --git a/packages/vchart/src/component/marker/mark-area/base-mark-area.ts b/packages/vchart/src/component/marker/mark-area/base-mark-area.ts index b6002e3533..b7e99c906f 100644 --- a/packages/vchart/src/component/marker/mark-area/base-mark-area.ts +++ b/packages/vchart/src/component/marker/mark-area/base-mark-area.ts @@ -1,6 +1,4 @@ -import { DataView } from '@visactor/vdataset'; import type { IMarkArea, IMarkAreaSpec } from './interface'; -import { markerAggregation } from '../../../data/transforms/aggregation'; import { computeClipRange, transformLabelAttributes, @@ -8,7 +6,6 @@ import { transformStyle, getMarkAreaProcessInfo } from '../utils'; -import { registerDataSetInstanceTransform } from '../../../data/register'; import type { MarkArcAreaAttrs, MarkAreaAttrs } from '@visactor/vrender-components'; // eslint-disable-next-line no-duplicate-imports import type { MarkArea as MarkAreaComponent, MarkArcArea as MarkArcAreaComponent } from '@visactor/vrender-components'; @@ -16,9 +13,6 @@ import { transformToGraphic } from '../../../util/style'; import { BaseMarker } from '../base-marker'; import { LayoutZIndex } from '../../../constant/layout'; import type { IGroup } from '@visactor/vrender-core'; -import { markerFilter } from '../../../data/transforms/marker-filter'; -import type { IMarkProcessOptions } from '../interface'; - export abstract class BaseMarkArea extends BaseMarker implements IMarkArea { static specKey = 'markArea'; specKey = 'markArea'; @@ -30,7 +24,6 @@ export abstract class BaseMarkArea extends BaseMarker implements attr: MarkAreaAttrs | MarkArcAreaAttrs ): MarkAreaComponent | MarkArcAreaComponent; protected abstract _computePointsAttr(): any; - protected abstract _computeOptions(): IMarkProcessOptions; static _getMarkerCoordinateType(markerSpec: any): string { const { doAngleProcess, doRadiusProcess, doRadAngProcess } = getMarkAreaProcessInfo(markerSpec); @@ -159,28 +152,6 @@ export abstract class BaseMarkArea extends BaseMarker implements return null; } - const { options } = this._computeOptions(); - - const seriesData = this._getRelativeDataView(); - registerDataSetInstanceTransform(this._option.dataSet, 'markerAggregation', markerAggregation); - registerDataSetInstanceTransform(this._option.dataSet, 'markerFilter', markerFilter); - const data = new DataView(this._option.dataSet, { name: `${this.type}_${this.id}_data` }); - data.parse([seriesData], { - type: 'dataview' - }); - data.transform({ - type: 'markerAggregation', - options - }); - - data.transform({ - type: 'markerFilter', - options: this._getAllRelativeSeries() - }); - - data.target.on('change', () => { - this._markerLayout(); - }); - this._markerData = data; + this._initCommonDataView(); } } diff --git a/packages/vchart/src/component/marker/mark-line/base-mark-line.ts b/packages/vchart/src/component/marker/mark-line/base-mark-line.ts index c717dc62a7..8312250c81 100644 --- a/packages/vchart/src/component/marker/mark-line/base-mark-line.ts +++ b/packages/vchart/src/component/marker/mark-line/base-mark-line.ts @@ -15,7 +15,7 @@ import type { MarkLine as MarkLineComponent, MarkArcLine as MarkArcLineComponent import { transformToGraphic } from '../../../util/style'; import { BaseMarker } from '../base-marker'; import type { IGroup } from '@visactor/vrender-core'; -import type { IMarkProcessOptions, IMarkerSymbol } from '../interface'; +import type { IMarkerSymbol } from '../interface'; import { markerRegression } from '../../../data/transforms/regression'; import { LayoutZIndex } from '../../../constant/layout'; import { markerFilter } from '../../../data/transforms/marker-filter'; @@ -30,7 +30,6 @@ export abstract class BaseMarkLine extends BaseMarker implements attr: MarkLineAttrs | MarkArcLineAttrs ): MarkLineComponent | MarkArcLineComponent; protected abstract _computePointsAttr(): any; - protected abstract _computeOptions(): IMarkProcessOptions; static _getMarkerCoordinateType(markerSpec: any): string { const { doAngleProcess, doRadiusProcess, doAngRadRad1Process, doRadAngAng1Process, doRadAngProcess } = diff --git a/packages/vchart/src/component/marker/mark-point/base-mark-point.ts b/packages/vchart/src/component/marker/mark-point/base-mark-point.ts index 3f00025e87..4f259a75af 100644 --- a/packages/vchart/src/component/marker/mark-point/base-mark-point.ts +++ b/packages/vchart/src/component/marker/mark-point/base-mark-point.ts @@ -1,6 +1,4 @@ -import { DataView } from '@visactor/vdataset'; import type { IMarkPoint, IMarkPointSpec } from './interface'; -import { markerAggregation } from '../../../data/transforms/aggregation'; import { computeClipRange, computeOffsetFromRegion, @@ -10,7 +8,6 @@ import { transformState, transformStyle } from '../utils'; -import { registerDataSetInstanceTransform } from '../../../data/register'; import type { MarkPointAttrs } from '@visactor/vrender-components'; // eslint-disable-next-line no-duplicate-imports import { MarkPoint as MarkPointComponent } from '@visactor/vrender-components'; @@ -19,8 +16,6 @@ import { transformToGraphic } from '../../../util/style'; import { BaseMarker } from '../base-marker'; import { LayoutZIndex } from '../../../constant/layout'; import type { IGroup } from '@visactor/vrender-core'; -import { markerFilter } from '../../../data/transforms/marker-filter'; -import type { IMarkProcessOptions } from '../interface'; export abstract class BaseMarkPoint extends BaseMarker implements IMarkPoint { static specKey = 'markPoint'; @@ -30,7 +25,6 @@ export abstract class BaseMarkPoint extends BaseMarker implement protected declare _markerComponent: MarkPointComponent; protected abstract _computePointsAttr(): any; - protected abstract _computeOptions(): IMarkProcessOptions; static _getMarkerCoordinateType(markerSpec: any): string { const { doPolarProcess, doGeoProcess } = getMarkPointProcessInfo(markerSpec); @@ -202,27 +196,6 @@ export abstract class BaseMarkPoint extends BaseMarker implement return; } - registerDataSetInstanceTransform(this._option.dataSet, 'markerAggregation', markerAggregation); - registerDataSetInstanceTransform(this._option.dataSet, 'markerFilter', markerFilter); - - const { options } = this._computeOptions(); - - const data = new DataView(this._option.dataSet, { name: `${this.type}_${this.id}_data` }); - data.parse([this._getRelativeDataView()], { - type: 'dataview' - }); - data.transform({ - type: 'markerAggregation', - options - }); - - data.transform({ - type: 'markerFilter', - options: this._getAllRelativeSeries() - }); - data.target.on('change', () => { - this._markerLayout(); - }); - this._markerData = data; + this._initCommonDataView(); } } diff --git a/packages/vchart/src/series/radar/radar.ts b/packages/vchart/src/series/radar/radar.ts index e7c1677452..d6b93f7cc1 100644 --- a/packages/vchart/src/series/radar/radar.ts +++ b/packages/vchart/src/series/radar/radar.ts @@ -19,7 +19,6 @@ import { registerLineMark } from '../../mark/line'; import { registerSymbolMark } from '../../mark/symbol'; import { radarSeriesMark } from './constant'; import { Factory } from '../../core/factory'; -import { registerMarkOverlapTransform } from '@visactor/vgrammar-core'; import { LineLikeSeriesSpecTransformer } from '../mixin/line-mixin-transformer'; import { registerPolarBandAxis, registerPolarLinearAxis } from '../../component/axis/polar'; @@ -246,7 +245,6 @@ mixin(RadarSeries, LineLikeSeriesMixin); export const registerRadarSeries = () => { Factory.registerSeries(RadarSeries.type, RadarSeries); - registerMarkOverlapTransform(); registerAreaMark(); registerLineMark(); registerSymbolMark();