Skip to content

Commit 7731729

Browse files
authored
Merge pull request #19197 from apache/feat-pictorialBar-clip
feat(pictorialBar): support clip for pictorialBar series
2 parents 80525ed + 71799e9 commit 7731729

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

src/chart/bar/PictorialBarSeries.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ export interface PictorialBarSeriesOption
119119
coordinateSystem?: 'cartesian2d'
120120

121121
data?: (PictorialBarDataItemOption | OptionDataValue | OptionDataValue[])[]
122+
123+
clip?: boolean
122124
}
123125

124126
class PictorialBarSeriesModel extends BaseBarSeriesModel<PictorialBarSeriesOption> {
@@ -150,6 +152,10 @@ class PictorialBarSeriesModel extends BaseBarSeriesModel<PictorialBarSeriesOptio
150152

151153
barGap: '-100%', // In most case, overlap is needed.
152154

155+
// Pictorial bar do not clip by default because in many cases
156+
// xAxis and yAxis are not displayed and it's expected not to clip
157+
clip: false,
158+
153159
// z can be set in data item, which is z2 actually.
154160

155161
// Disable progressive

src/chart/bar/PictorialBarView.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { PathProps, PathStyleProps } from 'zrender/src/graphic/Path';
3838
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
3939
import ZRImage from 'zrender/src/graphic/Image';
4040
import { getECData } from '../../util/innerStore';
41+
import { createClipPath } from '../helper/createClipPathFromCoordSys';
4142

4243
const BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'borderWidth'] as const;
4344

@@ -214,6 +215,17 @@ class PictorialBarView extends ChartView {
214215
})
215216
.execute();
216217

218+
// Do clipping
219+
const clipPath = seriesModel.get('clip', true)
220+
? createClipPath(seriesModel.coordinateSystem, false, seriesModel)
221+
: null;
222+
if (clipPath) {
223+
group.setClipPath(clipPath);
224+
}
225+
else {
226+
group.removeClipPath();
227+
}
228+
217229
this._data = data;
218230

219231
return this.group;
@@ -915,6 +927,7 @@ function updateCommon(
915927

916928
const barPositionOutside = opt.valueDim.posDesc[+(symbolMeta.boundingLength > 0)];
917929
const barRect = bar.__pictorialBarRect;
930+
barRect.ignoreClip = true;
918931

919932
setLabelStyle(
920933
barRect, getLabelStatesModels(itemModel),

test/pictorial-single.html

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)