提交 0984b093 编写于 作者: S SHUANG SU 提交者: sushuang

fix: remove BrushController clamp if drag out of zrender area. And add test case for geo scatter.

上级 534ad9b5
......@@ -919,12 +919,12 @@ function handleDragEnd(controller, e) {
function getLocalMouseXY(event, zr) {
var x = event.offsetX;
var y = event.offsetY;
var w = zr.getWidth();
var h = zr.getHeight();
x < 0 && (x = 0);
x > w && (x = w);
y < 0 && (y = 0);
y > h && (y = h);
// var w = zr.getWidth();
// var h = zr.getHeight();
// x < 0 && (x = 0);
// x > w && (x = w);
// y < 0 && (y = 0);
// y > h && (y = h);
return [x, y];
}
......
......@@ -76,6 +76,7 @@ under the License.
<div id="main0"></div>
</div>
<div id="main1"></div>
<div id="main2"></div>
......@@ -222,6 +223,146 @@ under the License.
</script>
<script>
require(['echarts', 'map/js/china'], function (echarts) {
var testGeoJson1 = {
'type': 'FeatureCollection',
'features': [
{
'geometry': {
'type': 'Polygon',
'coordinates': [
[
[
2000,
3000
],
[
5000,
3000
],
[
5000,
8000
],
[
2000,
8000
]
]
]
},
'properties': {
'name': 'Some Area',
'childNum': 1
}
}
]
};
echarts.registerMap('test1', testGeoJson1);
var data = [];
var step = 200;
var lngStart = 2000;
var latStart = 4000;
for (var i = 0; i < 10; i++) {
for (var j = 0; j < 20; j++) {
data.push({
value: [lngStart + j * step, latStart + i * step],
symbolSize: 5 + j * 2
});
}
}
var option = {
geo: [{
map: 'test1',
zoom: 8,
roam: true
}],
brush: {
geoIndex: 0
},
series: [{
type: 'scatter',
coordinateSystem: 'geo',
symbol: 'roundRect',
symbolSize: 30,
data: data
}, {
type: 'bar',
data: []
}],
xAxis: {},
yAxis: {},
};
var chart = testHelper.create(echarts, 'main2', {
title: [
'brush out of the area, the points that out of the chart area should be selected.',
],
option: option,
width: 350,
height: 260
});
if (!chart) {
return;
}
chart.on('brushselected', function (params) {
var selectedDataIndices = fetchSelected(params);
txtEl.style.text = 'selected data indices: ' + selectedDataIndices.join(', ');
txtEl.dirty();
});
function fetchSelected(params) {
var selectedDataIndices = [];
for (var i = 0; i < params.batch.length; i++) {
var item = params.batch[i];
var selected = item.selected;
for (var j = 0; j < selected.length; j++) {
selectedDataIndices = selectedDataIndices.concat(selected[j].dataIndex);
}
}
return selectedDataIndices;
}
var txtEl = new echarts.graphic.Text({
style: {
x: 10,
y: 10,
color: 'blue',
fontSize: 9
},
z: 9999
});
var zr = chart.getZr();
zr.add(txtEl);
});
</script>
</body>
</html>
......@@ -68,7 +68,7 @@
"dataZoom-sync": 1,
"dataZoom-toolbox": 6,
"dataZoomHighPrecision": 3,
"drag-out": 2,
"drag-out": 3,
"dynamic-splitNumber": 1,
"ec-event": 4,
"funnel": 2,
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册