You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2022/01/07 03:11:33 UTC
[echarts] branch optimize-bar-performance updated: fix(bar): use rect instead of line to draw large paths.
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch optimize-bar-performance
in repository https://gitbox.apache.org/repos/asf/echarts.git
The following commit(s) were added to refs/heads/optimize-bar-performance by this push:
new 897081e fix(bar): use rect instead of line to draw large paths.
897081e is described below
commit 897081eb70e96d6ca7b2bbc1db6ebc1faba3e6b7
Author: pissang <bm...@gmail.com>
AuthorDate: Fri Jan 7 11:10:59 2022 +0800
fix(bar): use rect instead of line to draw large paths.
More consistent with normal mode. Can have border.
---
src/chart/bar/BarView.ts | 42 ++++++++----------------------------------
src/layout/barGrid.ts | 1 -
2 files changed, 8 insertions(+), 35 deletions(-)
diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts
index a317373..33c5bd6 100644
--- a/src/chart/bar/BarView.ts
+++ b/src/chart/bar/BarView.ts
@@ -1098,12 +1098,14 @@ class LargePath extends Path<LargePathProps> {
const baseDimIdx = this.baseDimIdx;
const valueDimIdx = 1 - this.baseDimIdx;
const startPoint: number[] = [];
+ const size = [];
for (let i = 0; i < points.length; i += 3) {
- startPoint[baseDimIdx] = points[i + baseDimIdx];
- startPoint[valueDimIdx] = points[i + valueDimIdx] + points[i + 2];
- ctx.moveTo(startPoint[0], startPoint[1]);
- ctx.lineTo(points[i], points[i + 1]);
+ size[baseDimIdx] = this.barWidth;
+ size[valueDimIdx] = points[i + 2];
+ startPoint[baseDimIdx] = points[i + baseDimIdx] - size[baseDimIdx] / 2;
+ startPoint[valueDimIdx] = points[i + valueDimIdx];
+ ctx.rect(startPoint[0], startPoint[1], size[0], size[1]);
}
}
}
@@ -1138,7 +1140,7 @@ function createLarge(
bgEl.baseDimIdx = baseDimIdx;
bgEl.largeDataIndices = largeDataIndices;
bgEl.barWidth = barWidth;
- setLargeBackgroundStyle(bgEl, backgroundModel, data);
+ bgEl.useStyle(backgroundModel.getItemStyle());
group.add(bgEl);
progressiveEls && progressiveEls.push(bgEl);
@@ -1153,7 +1155,7 @@ function createLarge(
el.largeDataIndices = largeDataIndices;
el.barWidth = barWidth;
group.add(el);
- setLargeStyle(el, seriesModel, data);
+ el.useStyle(data.getVisual('style'));
// Enable tooltip and user mouse/touch event handlers.
getECData(el).seriesIndex = seriesModel.seriesIndex;
@@ -1206,34 +1208,6 @@ function largePathFindDataIndex(largePath: LargePath, x: number, y: number) {
return -1;
}
-function setLargeStyle(
- el: LargePath,
- seriesModel: BarSeriesModel,
- data: SeriesData
-) {
- const globalStyle = data.getVisual('style');
-
- el.useStyle(extend({}, globalStyle));
- // Use stroke instead of fill.
- el.style.fill = null;
- el.style.stroke = globalStyle.fill;
- el.style.lineWidth = data.getLayout('barWidth');
-}
-
-function setLargeBackgroundStyle(
- el: LargePath,
- backgroundModel: Model<BarSeriesOption['backgroundStyle']>,
- data: SeriesData
-) {
- const borderColor = backgroundModel.get('borderColor') || backgroundModel.get('color');
- const itemStyle = backgroundModel.getItemStyle();
-
- el.useStyle(itemStyle);
- el.style.fill = null;
- el.style.stroke = borderColor;
- el.style.lineWidth = data.getLayout('barWidth') as number;
-}
-
function createBackgroundShape(
isHorizontalOrRadial: boolean,
layout: SectorLayout | RectLayout,
diff --git a/src/layout/barGrid.ts b/src/layout/barGrid.ts
index a8e54d9..0265e09 100644
--- a/src/layout/barGrid.ts
+++ b/src/layout/barGrid.ts
@@ -461,7 +461,6 @@ export function layout(seriesType: string, ecModel: GlobalModel) {
lastStackCoords[stackId] = lastStackCoords[stackId] || [];
-
const valueDim = data.mapDimension(valueAxis.dim);
const baseDim = data.mapDimension(baseAxis.dim);
const stacked = isDimensionStacked(data, valueDim);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org