Skip to content

Commit 6cba74c

Browse files
authored
Merge pull request #20782 from sz-p/feat-6691
feat(marker): markPoint markLine markArea add z2 option to support change level
2 parents 8180fae + f559a45 commit 6cba74c

10 files changed

+432
-12
lines changed

src/chart/helper/Line.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import { isArray, each } from 'zrender/src/core/util';
20+
import { isArray, each, retrieve2 } from 'zrender/src/core/util';
2121
import * as vector from 'zrender/src/core/vector';
2222
import * as symbolUtil from '../../util/symbol';
2323
import ECLinePath from './LinePath';
@@ -164,9 +164,11 @@ class Line extends graphic.Group {
164164
_createLine(lineData: LineList, idx: number, seriesScope?: LineDrawSeriesScope) {
165165
const seriesModel = lineData.hostModel;
166166
const linePoints = lineData.getItemLayout(idx);
167+
const z2 = lineData.getItemVisual(idx, 'z2');
167168
const line = createLine(linePoints);
168169
line.shape.percent = 0;
169170
graphic.initProps(line, {
171+
z2: retrieve2(z2, 0),
170172
shape: {
171173
percent: 1
172174
}

src/chart/helper/Symbol.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { ColorString, BlurScope, AnimationOption, ZRColor, AnimationOptionMixin
2727
import SeriesModel from '../../model/Series';
2828
import { PathProps } from 'zrender/src/graphic/Path';
2929
import { SymbolDrawSeriesScope, SymbolDrawItemModelOption } from './SymbolDraw';
30-
import { extend } from 'zrender/src/core/util';
30+
import { extend, retrieve2 } from 'zrender/src/core/util';
3131
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
3232
import ZRImage from 'zrender/src/graphic/Image';
3333
import { saveOldStyle } from '../../animation/basicTransition';
@@ -64,6 +64,7 @@ class Symbol extends graphic.Group {
6464
data: SeriesData,
6565
idx: number,
6666
symbolSize: number[],
67+
z2: number,
6768
keepAspect: boolean
6869
) {
6970
// Remove paths created before
@@ -80,7 +81,7 @@ class Symbol extends graphic.Group {
8081
);
8182

8283
symbolPath.attr({
83-
z2: 100,
84+
z2: retrieve2(z2, 100),
8485
culling: true,
8586
scaleX: symbolSize[0] / 2,
8687
scaleY: symbolSize[1] / 2
@@ -156,12 +157,13 @@ class Symbol extends graphic.Group {
156157
const symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
157158
const seriesModel = data.hostModel as SeriesModel;
158159
const symbolSize = Symbol.getSymbolSize(data, idx);
160+
const z2 = Symbol.getSymbolZ2(data, idx);
159161
const isInit = symbolType !== this._symbolType;
160162
const disableAnimation = opts && opts.disableAnimation;
161163

162164
if (isInit) {
163165
const keepAspect = data.getItemVisual(idx, 'symbolKeepAspect');
164-
this._createSymbol(symbolType as string, data, idx, symbolSize, keepAspect);
166+
this._createSymbol(symbolType as string, data, idx, symbolSize, z2, keepAspect);
165167
}
166168
else {
167169
const symbolPath = this.childAt(0) as ECSymbol;
@@ -405,6 +407,9 @@ class Symbol extends graphic.Group {
405407
static getSymbolSize(data: SeriesData, idx: number) {
406408
return normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
407409
}
410+
static getSymbolZ2(data: SeriesData, idx: number) {
411+
return data.getItemVisual(idx, 'z2');
412+
}
408413
}
409414

410415

src/component/marker/MarkAreaModel.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import GlobalModel from '../../model/Global';
2525
interface MarkAreaStateOption {
2626
itemStyle?: ItemStyleOption
2727
label?: SeriesLabelOption
28+
z2?: number
2829
}
2930

3031
interface MarkAreaDataItemOptionBase extends MarkAreaStateOption,

src/component/marker/MarkAreaView.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import * as graphic from '../../util/graphic';
2626
import { toggleHoverEmphasis, setStatesStylesFromModel } from '../../util/states';
2727
import * as markerHelper from './markerHelper';
2828
import MarkerView from './MarkerView';
29-
import { retrieve, mergeAll, map, curry, filter, HashMap, extend, isString } from 'zrender/src/core/util';
29+
import { retrieve, mergeAll, map, curry, filter, HashMap, extend, isString, retrieve2 } from 'zrender/src/core/util';
3030
import { ScaleDataValue, ZRColor } from '../../util/types';
3131
import { CoordinateSystem, isCoordinateSystemType } from '../../coord/CoordinateSystem';
3232
import MarkAreaModel, { MarkArea2DDataItemOption } from './MarkAreaModel';
@@ -301,8 +301,9 @@ class MarkAreaView extends MarkerView {
301301
allClipped: allClipped
302302
});
303303

304-
305-
const style = areaData.getItemModel<MarkAreaMergedItemOption>(idx).getModel('itemStyle').getItemStyle();
304+
const itemModel = areaData.getItemModel<MarkAreaMergedItemOption>(idx);
305+
const style = itemModel.getModel('itemStyle').getItemStyle();
306+
const z2 = itemModel.get('z2');
306307
const color = getVisualFromData(seriesData, 'color') as ZRColor;
307308
if (!style.fill) {
308309
style.fill = color;
@@ -315,14 +316,17 @@ class MarkAreaView extends MarkerView {
315316
}
316317
// Visual
317318
areaData.setItemVisual(idx, 'style', style);
319+
areaData.setItemVisual(idx, 'z2', retrieve2(z2, 0));
318320
});
319321

320322

321323
areaData.diff(inner(polygonGroup).data)
322324
.add(function (idx) {
323325
const layout = areaData.getItemLayout(idx);
326+
const z2 = areaData.getItemVisual(idx, 'z2');
324327
if (!layout.allClipped) {
325328
const polygon = new graphic.Polygon({
329+
z2: retrieve2(z2, 0),
326330
shape: {
327331
points: layout.points
328332
}
@@ -334,9 +338,11 @@ class MarkAreaView extends MarkerView {
334338
.update(function (newIdx, oldIdx) {
335339
let polygon = inner(polygonGroup).data.getItemGraphicEl(oldIdx) as graphic.Polygon;
336340
const layout = areaData.getItemLayout(newIdx);
341+
const z2 = areaData.getItemVisual(newIdx, 'z2');
337342
if (!layout.allClipped) {
338343
if (polygon) {
339344
graphic.updateProps(polygon, {
345+
z2: retrieve2(z2, 0),
340346
shape: {
341347
points: layout.points
342348
}

src/component/marker/MarkLineModel.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ interface MarkLineStateOption {
3434
* itemStyle for symbol
3535
*/
3636
itemStyle?: ItemStyleOption
37-
label?: SeriesLineLabelOption
37+
label?: SeriesLineLabelOption,
38+
z2?: number
3839
}
3940
interface MarkLineDataItemOptionBase extends MarkLineStateOption,
4041
StatesOptionMixin<MarkLineStateOption, StatesMixinBase> {

src/component/marker/MarkLineView.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -349,21 +349,23 @@ class MarkLineView extends MarkerView {
349349

350350
// Update visual and layout of line
351351
lineData.each(function (idx) {
352-
const lineStyle = lineData.getItemModel<MarkLineMergedItemOption>(idx)
353-
.getModel('lineStyle').getLineStyle();
352+
const itemModel = lineData.getItemModel<MarkLineMergedItemOption>(idx);
353+
const lineStyle = itemModel.getModel('lineStyle').getLineStyle();
354354
// lineData.setItemVisual(idx, {
355355
// color: lineColor || fromData.getItemVisual(idx, 'color')
356356
// });
357357
lineData.setItemLayout(idx, [
358358
fromData.getItemLayout(idx),
359359
toData.getItemLayout(idx)
360360
]);
361+
const z2 = itemModel.get('z2');
361362

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

366367
lineData.setItemVisual(idx, {
368+
z2: retrieve2(z2, 0),
367369
fromSymbolKeepAspect: fromData.getItemVisual(idx, 'symbolKeepAspect'),
368370
fromSymbolOffset: fromData.getItemVisual(idx, 'symbolOffset'),
369371
fromSymbolRotate: fromData.getItemVisual(idx, 'symbolRotate'),

src/component/marker/MarkPointModel.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
interface MarkPointStateOption {
3737
itemStyle?: ItemStyleOption
3838
label?: SeriesLabelOption
39+
z2?: number
3940
}
4041
export interface MarkPointDataItemOption extends
4142
MarkPointStateOption, StatesOptionMixin<MarkPointStateOption, StatesMixinBase>,

src/component/marker/MarkPointView.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import MarkPointModel, {MarkPointDataItemOption} from './MarkPointModel';
2929
import GlobalModel from '../../model/Global';
3030
import MarkerModel from './MarkerModel';
3131
import ExtensionAPI from '../../core/ExtensionAPI';
32-
import { HashMap, isFunction, map, filter, curry, extend } from 'zrender/src/core/util';
32+
import { HashMap, isFunction, map, filter, curry, extend, retrieve2 } from 'zrender/src/core/util';
3333
import { getECData } from '../../util/innerStore';
3434
import { getVisualFromData } from '../../visual/helper';
3535
import { ZRColor } from '../../util/types';
@@ -143,12 +143,14 @@ class MarkPointView extends MarkerView {
143143
}
144144

145145
const style = itemModel.getModel('itemStyle').getItemStyle();
146+
const z2 = itemModel.get('z2');
146147
const color = getVisualFromData(seriesData, 'color') as ZRColor;
147148
if (!style.fill) {
148149
style.fill = color;
149150
}
150151

151152
mpData.setItemVisual(idx, {
153+
z2: retrieve2(z2, 0),
152154
symbol: symbol,
153155
symbolSize: symbolSize,
154156
symbolRotate: symbolRotate,

src/data/SeriesData.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export interface DefaultDataVisual {
113113
symbolRotate?: number
114114
symbolKeepAspect?: boolean
115115
symbolOffset?: string | number | (string | number)[]
116-
116+
z2: number,
117117
liftZ?: number
118118
// For legend.
119119
legendIcon?: string

0 commit comments

Comments
 (0)