Skip to content

Commit

Permalink
feat(pictorialBar): support clip for pictorialBar series
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovilia committed Oct 12, 2023
1 parent ea28e44 commit f38c2a6
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/chart/bar/PictorialBarSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export interface PictorialBarSeriesOption
coordinateSystem?: 'cartesian2d'

data?: (PictorialBarDataItemOption | OptionDataValue | OptionDataValue[])[]

clip?: boolean
}

class PictorialBarSeriesModel extends BaseBarSeriesModel<PictorialBarSeriesOption> {
Expand Down Expand Up @@ -150,6 +152,10 @@ class PictorialBarSeriesModel extends BaseBarSeriesModel<PictorialBarSeriesOptio

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

// Pictorial bar do not clip by default because in many cases
// xAxis and yAxis are not displayed and it's expected not to clip
clip: false,

// z can be set in data item, which is z2 actually.

// Disable progressive
Expand Down
12 changes: 12 additions & 0 deletions src/chart/bar/PictorialBarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { PathProps, PathStyleProps } from 'zrender/src/graphic/Path';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import ZRImage from 'zrender/src/graphic/Image';
import { getECData } from '../../util/innerStore';
import { createClipPath } from '../helper/createClipPathFromCoordSys';

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

Expand Down Expand Up @@ -214,6 +215,17 @@ class PictorialBarView extends ChartView {
})
.execute();

// Do clipping
const clipPath = seriesModel.get('clip', true)
? createClipPath(seriesModel.coordinateSystem, false, seriesModel)
: null;
if (clipPath) {
group.setClipPath(clipPath);
}
else {
group.removeClipPath();
}

this._data = data;

return this.group;
Expand Down
95 changes: 95 additions & 0 deletions test/pictorial-single.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f38c2a6

Please sign in to comment.