Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pictorialBar): support clip for pictorialBar series #19197

Merged
merged 3 commits into from Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/chart/bar/PictorialBarSeries.ts
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
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.