Skip to content

Commit

Permalink
feat(dataZoom): custom brush style in toolbox.feature.dataZoom. close:
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuc123 committed May 1, 2020
1 parent 79919e7 commit d42f5cf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
30 changes: 24 additions & 6 deletions src/component/toolbox/feature/DataZoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ DataZoom.defaultOption = {
back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26'
},
// `zoom`, `back`
title: zrUtil.clone(dataZoomLang.title)
title: zrUtil.clone(dataZoomLang.title),
brushStyle: {
borderWidth: 0,
color: 'rgba(0,0,0,0.2)'
}
};

var proto = DataZoom.prototype;
Expand Down Expand Up @@ -236,16 +240,30 @@ function updateZoomBtnStatus(featureModel, ecModel, view, payload, api) {
zoomActive
? {
brushType: 'auto',
brushStyle: {
// FIXME user customized?
lineWidth: 0,
fill: 'rgba(0,0,0,0.2)'
}
brushStyle: mapBrushStyle(featureModel.option.brushStyle)
}
: false
);
}

function mapBrushStyle(brushStyle) {
var properties = [
['fill', 'color'],
['lineWidth', 'borderWidth'],
['stroke', 'borderColor'],
['opacity', 'opacity']
];
var style = {};
for (var i = 0; i < properties.length; i++) {
var propName = properties[i][1];
var val = brushStyle[propName];
if (val != null) {
style[properties[i][0]] = val;
}
}
return style;
}


featureManager.register('dataZoom', DataZoom);

Expand Down
8 changes: 7 additions & 1 deletion test/dataZoom-toolbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ <h2>Specify Y axis (yAxisIndex: false, should be 'lineX' brush)</h2>
dataView: {},
dataZoom: {
show: true,
yAxisIndex: null
yAxisIndex: null,
// brushStyle: {
// borderWidth: 2,
// color: 'blue',
// opacity: 0.1,
// borderColor: '#596A76',
// }
},
restore: {show: true},
saveAsImage: {}
Expand Down

0 comments on commit d42f5cf

Please sign in to comment.