From 5bcd7d4ccc05d20ebbf628005361d9fe3aebbecd Mon Sep 17 00:00:00 2001 From: tiwarir Date: Wed, 8 Jul 2026 14:26:38 -0400 Subject: [PATCH] fix(line): keep labels above lines. close #15679 --- src/chart/line/LineView.ts | 2 +- test/ut/spec/series/line.test.ts | 72 ++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 test/ut/spec/series/line.test.ts diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts index 847a876495..5813f03fdc 100644 --- a/src/chart/line/LineView.ts +++ b/src/chart/line/LineView.ts @@ -1044,7 +1044,7 @@ class LineView extends ChartView { points }, segmentIgnoreThreshold: 2, - z2: 10 + z2: 1 }); this._lineGroup.add(polyline); diff --git a/test/ut/spec/series/line.test.ts b/test/ut/spec/series/line.test.ts new file mode 100644 index 0000000000..7dc11b2e1a --- /dev/null +++ b/test/ut/spec/series/line.test.ts @@ -0,0 +1,72 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +import { EChartsType } from '@/src/echarts'; +import { createChart, getGraphicElements } from '../../core/utHelper'; + + +describe('line_series', function () { + + let chart: EChartsType; + + beforeEach(function () { + chart = createChart(); + }); + + afterEach(function () { + chart.dispose(); + }); + + it('should render line under labels from mixed series', function () { + chart.setOption({ + animation: false, + xAxis: { + type: 'category', + data: ['A', 'B', 'C'] + }, + yAxis: {}, + series: [ + { + type: 'bar', + label: { + show: true, + position: 'top' + }, + data: [120, 120, 120] + }, + { + type: 'line', + showSymbol: false, + data: [140, 100, 140] + } + ] + }); + + const barItem = getGraphicElements(chart, 'series', 0).find(el => el.name === 'item'); + const barLabel = barItem && barItem.getTextContent(); + const linePolyline = getGraphicElements(chart, 'series', 1).find(el => el.type === 'ec-polyline'); + + expect(barItem).toBeDefined(); + expect(barLabel).toBeDefined(); + expect(linePolyline).toBeDefined(); + + expect((linePolyline as any).z2).toBeLessThan((barLabel as any).z2); + }); + +});