LoCs / echarts-5.5.0-rc.2 /test /dataSelect.html
ZoeDuan's picture
Upload 1382 files
4bb817b verified
raw
history blame
5.67 kB
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="lib/simpleRequire.js"></script>
<script src="lib/config.js"></script>
<script src="lib/jquery.min.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/testHelper.js"></script>
<script src="data/basicChartsOptions.js"></script>
<script src="lib/dat.gui.min.js"></script>
<!-- <script src="ut/lib/canteen.js"></script> -->
<link rel="stylesheet" href="lib/reset.css" />
</head>
<body>
<style>
body {
background: #eee;
margin: 0;
text-align: center;
}
#main {
box-sizing: border-box;
margin: 0 auto;
width: 800px;
max-width: 100%;
text-align: center;
}
.chart {
height: 400px;
border-radius: 5px;
margin: 20px 0;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
background: #fff;
}
#log {
position: fixed;
right: 0;
top: 0;
width: 200px;
height: 200px;
background: rgba(0, 0, 0, 0.5);
color: #fff;
text-align: left;
}
</style>
<div id="main">
<h1>Tests for focus and blurScope</h1>
</div>
<pre id="log"></pre>
<script>
require(['echarts'/*, 'map/js/china' */], function (echarts) {
const charts = [];
allChartsOptions.forEach(function (chartOption) {
chartOption.series.forEach(function (series) {
series.selectedMode = 'single';
series.select = {
itemStyle: {
borderWidth: 3
}
}
if (series.renderItem) {
const oldRenderItem = series.renderItem;
series.renderItem = function () {
const ret = oldRenderItem.apply(this, arguments);
ret.focus = 'self';
return ret;
}
}
if (series.type === 'treemap') {
series.itemStyle = {
borderColor: 'rgba(100, 100, 200, 0.1)',
};
series.nodeClick = null;
series.select = {
itemStyle: {
strokeColor: '#000',
strokeWidth: 1
}
}
}
else if (series.type === 'pie') {
series.data[0].selected = true;
}
});
const dom = document.createElement('div');
dom.className = 'chart';
document.querySelector('#main').appendChild(dom);
const chart = echarts.init(dom);
chart.setOption(chartOption);
chart.on('selectchanged', function (e) {
document.querySelector('#log').innerHTML = JSON.stringify(e.selected, null, 2);
});
charts.push(chart);
});
const selectOpts = {
selectRed: false
}
function update() {
allChartsOptions.forEach(function (chartOption, idx) {
chartOption.series.forEach(function (series) {
series.select = {
itemStyle: {
borderWidth: 3,
color: selectOpts.selectRed ? '#f00' : null
},
lineStyle: {
color: selectOpts.selectRed ? '#f00' : null
},
areaStyle: {
color: selectOpts.selectRed ? '#f00' : null
}
}
});
charts[idx].setOption(chartOption);
});
}
var gui = new dat.GUI();
gui.add(selectOpts, 'selectRed').onChange(update);
window.addEventListener('resize', function () {
charts.forEach(function (chart) {
chart.resize();
});
});
});
</script>
</body>
</html>