You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2020/04/02 12:20:42 UTC
[incubator-echarts] 01/01: fix: bar background border radius. The
original PR is #12331 fbe73aec2b265c99e78aebcf575b23bc339b60c8 This commit
fixes: also update `r` when "update" rather than only in "add". Add more
test cases.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch fix/bar-background
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 2f59d2b5f35f0ff93cf0da4fa286e5e7411f86b1
Author: 100pah <su...@gmail.com>
AuthorDate: Thu Apr 2 20:19:44 2020 +0800
fix: bar background border radius.
The original PR is #12331
fbe73aec2b265c99e78aebcf575b23bc339b60c8
This commit fixes: also update `r` when "update" rather than only in "add".
Add more test cases.
---
package.json | 3 +++
src/chart/bar/BarView.js | 13 +++++++++----
test/bar-background.html | 18 +++++++++++++++++-
test/runTest/actions/__meta__.json | 1 +
test/runTest/actions/bar-background.json | 1 +
5 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 8111384..a6335d4 100644
--- a/package.json
+++ b/package.json
@@ -61,5 +61,8 @@
"serve-handler": "6.1.1",
"slugify": "1.3.4",
"socket.io": "2.2.0"
+ },
+ "peerDependencies": {
+ "puppeteer": "^2.1.1"
}
}
diff --git a/src/chart/bar/BarView.js b/src/chart/bar/BarView.js
index defaa90..747f4ad 100644
--- a/src/chart/bar/BarView.js
+++ b/src/chart/bar/BarView.js
@@ -130,6 +130,7 @@ export default echarts.extendChartView({
var drawBackground = seriesModel.get('showBackground', true);
var backgroundModel = seriesModel.getModel('backgroundStyle');
+ var barBorderRadius = backgroundModel.get('barBorderRadius') || 0;
var bgEls = [];
var oldBgEls = this._backgroundEls || [];
@@ -140,10 +141,10 @@ export default echarts.extendChartView({
var layout = getLayout[coord.type](data, dataIndex, itemModel);
if (drawBackground) {
- var bgLayout = getLayout[coord.type](data, dataIndex, backgroundModel);
+ var bgLayout = getLayout[coord.type](data, dataIndex);
var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getBarItemStyle());
- bgEl.setShape('r', backgroundModel.get('barBorderRadius'));
+ bgEl.setShape('r', barBorderRadius);
bgEls[dataIndex] = bgEl;
}
@@ -180,9 +181,11 @@ export default echarts.extendChartView({
if (drawBackground) {
var bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getBarItemStyle());
+ bgEl.setShape('r', barBorderRadius);
bgEls[newIndex] = bgEl;
- var shape = createBackgroundShape(isHorizontalOrRadial, layout, coord);
+ var bgLayout = getLayout[coord.type](data, newIndex);
+ var shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
graphic.updateProps(bgEl, { shape: shape }, animationModel, newIndex);
}
@@ -432,9 +435,11 @@ function removeSector(dataIndex, animationModel, el) {
}
var getLayout = {
+ // itemModel is only used to get borderWidth, which is not needed
+ // when calculating bar background layout.
cartesian2d: function (data, dataIndex, itemModel) {
var layout = data.getItemLayout(dataIndex);
- var fixedLineWidth = getLineWidth(itemModel, layout);
+ var fixedLineWidth = itemModel ? getLineWidth(itemModel, layout) : 0;
// fix layout with lineWidth
var signX = layout.width > 0 ? 1 : -1;
diff --git a/test/bar-background.html b/test/bar-background.html
index d685566..1ca94f3 100644
--- a/test/bar-background.html
+++ b/test/bar-background.html
@@ -533,6 +533,10 @@ under the License.
series: [{
data: [110, 120, 150, 250, 350, 400, 500, 600],
type: 'bar',
+ itemStyle: {
+ barBorderWidth: 20,
+ barBorderColor: 'rgba(50,50,50,0.3)'
+ },
showBackground: true,
backgroundStyle: {
color: 'green',
@@ -545,7 +549,19 @@ under the License.
option: option,
title: [
'background barBorderRadius'
- ]
+ ],
+ buttons: [{
+ text: 'update barBorderRadius to [30, 40, 0, 60]',
+ onclick: function () {
+ chart.setOption({
+ series: {
+ backgroundStyle: {
+ barBorderRadius: [30, 40, 0, 60]
+ }
+ }
+ });
+ }
+ }]
});
});
</script>
diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json
index 1669540..4915a31 100644
--- a/test/runTest/actions/__meta__.json
+++ b/test/runTest/actions/__meta__.json
@@ -17,6 +17,7 @@
"axis-style": 2,
"axisPosition": 2,
"bar": 2,
+ "bar-background": 3,
"bar-label-rotation": 2,
"bar-large": 2,
"bar-overflow-time-plot": 3,
diff --git a/test/runTest/actions/bar-background.json b/test/runTest/actions/bar-background.json
new file mode 100644
index 0000000..38595b6
--- /dev/null
+++ b/test/runTest/actions/bar-background.json
@@ -0,0 +1 @@
+[{"name":"Action 1","ops":[{"type":"mousemove","time":560,"x":793,"y":238},{"type":"mousemove","time":761,"x":444,"y":258},{"type":"mousewheel","time":1526,"x":444,"y":258,"deltaY":1},{"type":"mousewheel","time":1592,"x":444,"y":258,"deltaY":24},{"type":"mousewheel","time":1626,"x":444,"y":258,"deltaY":10},{"type":"mousewheel","time":1671,"x":444,"y":258,"deltaY":11},{"type":"mousewheel","time":1691,"x":444,"y":258,"deltaY":8},{"type":"mousewheel","time":1713,"x":444,"y":258,"deltaY":3}, [...]
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org