Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/chart/helper/Line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { isArray, each } from 'zrender/src/core/util';
import { isArray, each, retrieve2 } from 'zrender/src/core/util';
import * as vector from 'zrender/src/core/vector';
import * as symbolUtil from '../../util/symbol';
import ECLinePath from './LinePath';
Expand Down Expand Up @@ -164,9 +164,11 @@ class Line extends graphic.Group {
_createLine(lineData: LineList, idx: number, seriesScope?: LineDrawSeriesScope) {
const seriesModel = lineData.hostModel;
const linePoints = lineData.getItemLayout(idx);
const z2 = lineData.getItemVisual(idx, 'z2');
const line = createLine(linePoints);
line.shape.percent = 0;
graphic.initProps(line, {
z2: retrieve2(z2, 0),
shape: {
percent: 1
}
Expand Down
11 changes: 8 additions & 3 deletions src/chart/helper/Symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { ColorString, BlurScope, AnimationOption, ZRColor, AnimationOptionMixin
import SeriesModel from '../../model/Series';
import { PathProps } from 'zrender/src/graphic/Path';
import { SymbolDrawSeriesScope, SymbolDrawItemModelOption } from './SymbolDraw';
import { extend } from 'zrender/src/core/util';
import { extend, retrieve2 } from 'zrender/src/core/util';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import ZRImage from 'zrender/src/graphic/Image';
import { saveOldStyle } from '../../animation/basicTransition';
Expand Down Expand Up @@ -64,6 +64,7 @@ class Symbol extends graphic.Group {
data: SeriesData,
idx: number,
symbolSize: number[],
z2: number,
keepAspect: boolean
) {
// Remove paths created before
Expand All @@ -80,7 +81,7 @@ class Symbol extends graphic.Group {
);

symbolPath.attr({
z2: 100,
Copy link
Member

@100pah 100pah Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Symbol is used not only by markPoint, but also by line series, scatter series, etc.
    In the current PR, only markPoint allows users to set z2, which results in z2: 100 being missing in other cases. Is it intentional? If not, backward compatibility should be maintained.

  2. If users do not specify z2, here a undefined-z2 will be set to an zr element, which is error-prone (z2 is not meant to be a non-number yet in zrender) and might degrade the performance (theoretically).

Summary: I think every place a z2 is about to set to a zr element, use a default number value to make sure it's a number.
e.g.,

symbolPath.attr({
    zr: retrieve2(z2, 100),
    ...
})
graphic.updateProps(polygon, {
    retrieve2(z2, 0),
    // ...
})

The other place that sets z2 to zr elements in this PR follows this suggestion.

z2: retrieve2(z2, 100),
culling: true,
scaleX: symbolSize[0] / 2,
scaleY: symbolSize[1] / 2
Expand Down Expand Up @@ -156,12 +157,13 @@ class Symbol extends graphic.Group {
const symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
const seriesModel = data.hostModel as SeriesModel;
const symbolSize = Symbol.getSymbolSize(data, idx);
const z2 = Symbol.getSymbolZ2(data, idx);
const isInit = symbolType !== this._symbolType;
const disableAnimation = opts && opts.disableAnimation;

if (isInit) {
const keepAspect = data.getItemVisual(idx, 'symbolKeepAspect');
this._createSymbol(symbolType as string, data, idx, symbolSize, keepAspect);
this._createSymbol(symbolType as string, data, idx, symbolSize, z2, keepAspect);
}
else {
const symbolPath = this.childAt(0) as ECSymbol;
Expand Down Expand Up @@ -405,6 +407,9 @@ class Symbol extends graphic.Group {
static getSymbolSize(data: SeriesData, idx: number) {
return normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
}
static getSymbolZ2(data: SeriesData, idx: number) {
return data.getItemVisual(idx, 'z2');
}
}


Expand Down
1 change: 1 addition & 0 deletions src/component/marker/MarkAreaModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import GlobalModel from '../../model/Global';
interface MarkAreaStateOption {
itemStyle?: ItemStyleOption
label?: SeriesLabelOption
z2?: number
}

interface MarkAreaDataItemOptionBase extends MarkAreaStateOption,
Expand Down
12 changes: 9 additions & 3 deletions src/component/marker/MarkAreaView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import * as graphic from '../../util/graphic';
import { toggleHoverEmphasis, setStatesStylesFromModel } from '../../util/states';
import * as markerHelper from './markerHelper';
import MarkerView from './MarkerView';
import { retrieve, mergeAll, map, curry, filter, HashMap, extend, isString } from 'zrender/src/core/util';
import { retrieve, mergeAll, map, curry, filter, HashMap, extend, isString, retrieve2 } from 'zrender/src/core/util';
import { ScaleDataValue, ZRColor } from '../../util/types';
import { CoordinateSystem, isCoordinateSystemType } from '../../coord/CoordinateSystem';
import MarkAreaModel, { MarkArea2DDataItemOption } from './MarkAreaModel';
Expand Down Expand Up @@ -301,8 +301,9 @@ class MarkAreaView extends MarkerView {
allClipped: allClipped
});


const style = areaData.getItemModel<MarkAreaMergedItemOption>(idx).getModel('itemStyle').getItemStyle();
const itemModel = areaData.getItemModel<MarkAreaMergedItemOption>(idx);
const style = itemModel.getModel('itemStyle').getItemStyle();
const z2 = itemModel.get('z2');
const color = getVisualFromData(seriesData, 'color') as ZRColor;
if (!style.fill) {
style.fill = color;
Expand All @@ -315,14 +316,17 @@ class MarkAreaView extends MarkerView {
}
// Visual
areaData.setItemVisual(idx, 'style', style);
areaData.setItemVisual(idx, 'z2', retrieve2(z2, 0));
});


areaData.diff(inner(polygonGroup).data)
.add(function (idx) {
const layout = areaData.getItemLayout(idx);
const z2 = areaData.getItemVisual(idx, 'z2');
if (!layout.allClipped) {
const polygon = new graphic.Polygon({
z2: retrieve2(z2, 0),
shape: {
points: layout.points
}
Expand All @@ -334,9 +338,11 @@ class MarkAreaView extends MarkerView {
.update(function (newIdx, oldIdx) {
let polygon = inner(polygonGroup).data.getItemGraphicEl(oldIdx) as graphic.Polygon;
const layout = areaData.getItemLayout(newIdx);
const z2 = areaData.getItemVisual(newIdx, 'z2');
if (!layout.allClipped) {
if (polygon) {
graphic.updateProps(polygon, {
z2: retrieve2(z2, 0),
shape: {
points: layout.points
}
Expand Down
3 changes: 2 additions & 1 deletion src/component/marker/MarkLineModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ interface MarkLineStateOption {
* itemStyle for symbol
*/
itemStyle?: ItemStyleOption
label?: SeriesLineLabelOption
label?: SeriesLineLabelOption,
z2?: number
}
interface MarkLineDataItemOptionBase extends MarkLineStateOption,
StatesOptionMixin<MarkLineStateOption, StatesMixinBase> {
Expand Down
6 changes: 4 additions & 2 deletions src/component/marker/MarkLineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,21 +349,23 @@ class MarkLineView extends MarkerView {

// Update visual and layout of line
lineData.each(function (idx) {
const lineStyle = lineData.getItemModel<MarkLineMergedItemOption>(idx)
.getModel('lineStyle').getLineStyle();
const itemModel = lineData.getItemModel<MarkLineMergedItemOption>(idx);
const lineStyle = itemModel.getModel('lineStyle').getLineStyle();
// lineData.setItemVisual(idx, {
// color: lineColor || fromData.getItemVisual(idx, 'color')
// });
lineData.setItemLayout(idx, [
fromData.getItemLayout(idx),
toData.getItemLayout(idx)
]);
const z2 = itemModel.get('z2');

if (lineStyle.stroke == null) {
lineStyle.stroke = fromData.getItemVisual(idx, 'style').fill;
}

lineData.setItemVisual(idx, {
z2: retrieve2(z2, 0),
fromSymbolKeepAspect: fromData.getItemVisual(idx, 'symbolKeepAspect'),
fromSymbolOffset: fromData.getItemVisual(idx, 'symbolOffset'),
fromSymbolRotate: fromData.getItemVisual(idx, 'symbolRotate'),
Expand Down
1 change: 1 addition & 0 deletions src/component/marker/MarkPointModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
interface MarkPointStateOption {
itemStyle?: ItemStyleOption
label?: SeriesLabelOption
z2?: number
}
export interface MarkPointDataItemOption extends
MarkPointStateOption, StatesOptionMixin<MarkPointStateOption, StatesMixinBase>,
Expand Down
4 changes: 3 additions & 1 deletion src/component/marker/MarkPointView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import MarkPointModel, {MarkPointDataItemOption} from './MarkPointModel';
import GlobalModel from '../../model/Global';
import MarkerModel from './MarkerModel';
import ExtensionAPI from '../../core/ExtensionAPI';
import { HashMap, isFunction, map, filter, curry, extend } from 'zrender/src/core/util';
import { HashMap, isFunction, map, filter, curry, extend, retrieve2 } from 'zrender/src/core/util';
import { getECData } from '../../util/innerStore';
import { getVisualFromData } from '../../visual/helper';
import { ZRColor } from '../../util/types';
Expand Down Expand Up @@ -143,12 +143,14 @@ class MarkPointView extends MarkerView {
}

const style = itemModel.getModel('itemStyle').getItemStyle();
const z2 = itemModel.get('z2');
const color = getVisualFromData(seriesData, 'color') as ZRColor;
if (!style.fill) {
style.fill = color;
}

mpData.setItemVisual(idx, {
z2: retrieve2(z2, 0),
symbol: symbol,
symbolSize: symbolSize,
symbolRotate: symbolRotate,
Expand Down
2 changes: 1 addition & 1 deletion src/data/SeriesData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export interface DefaultDataVisual {
symbolRotate?: number
symbolKeepAspect?: boolean
symbolOffset?: string | number | (string | number)[]

z2: number,
liftZ?: number
// For legend.
legendIcon?: string
Expand Down
Loading