Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/chart/bar/BarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,14 @@ class BarView extends ChartView {
}

if (drawBackground) {
let bgEl: Rect | Sector;
if (oldBgEls.length === 0) {
bgEl = createBackground(oldIndex);
// The old item may have had no background (`showBackground` was
// off, or it had no layout). Then create one for the new index;
// the old index may not exist in the new data.
let bgEl = oldBgEls && oldBgEls[oldIndex];
if (!bgEl) {
bgEl = createBackground(newIndex);
}
else {
bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getItemStyle());
// Only cartesian2d support borderRadius.
if (coord.type === 'cartesian2d') {
Expand All @@ -336,9 +338,11 @@ class BarView extends ChartView {
}
bgEls[newIndex] = bgEl;
}
const bgLayout = getLayout[coord.type](data, newIndex);
const shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
updateProps<RectProps | SectorProps>(bgEl, { shape }, animationModel, newIndex);
const bgLayout = bgEl && getLayout[coord.type](data, newIndex);
if (bgLayout) {
const shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
updateProps<RectProps | SectorProps>(bgEl, { shape }, animationModel, newIndex);
}
}

let el = oldData.getItemGraphicEl(oldIndex) as BarPossiblePath;
Expand Down
44 changes: 44 additions & 0 deletions test/ut/spec/series/bar.test.ts

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