3
Licensed to the Apache Software Foundation (ASF) under one
4
or more contributor license agreements. See the NOTICE file
5
distributed with this work for additional information
6
regarding copyright ownership. The ASF licenses this file
7
to you under the Apache License, Version 2.0 (the
8
"License"); you may not use this file except in compliance
9
with the License. You may obtain a copy of the License at
11
http://www.apache.org/licenses/LICENSE-2.0
13
Unless required by applicable law or agreed to in writing,
14
software distributed under the License is distributed on an
15
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
KIND, either express or implied. See the License for the
17
specific language governing permissions and limitations
24
<meta charset="utf-8">
25
<meta name="viewport" content="width=device-width, initial-scale=1" />
26
<script src="lib/simpleRequire.js"></script>
27
<script src="lib/config.js"></script>
28
<script src="lib/jquery.min.js"></script>
29
<script src="lib/facePrint.js"></script>
30
<script src="lib/testHelper.js"></script>
31
<script src="data/basicChartsOptions.js"></script>
32
<script src="lib/dat.gui.min.js"></script>
33
<!-- <script src="ut/lib/canteen.js"></script> -->
34
<link rel="stylesheet" href="lib/reset.css" />
44
box-sizing: border-box;
54
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
65
<h1>Tests for focus and blurScope</h1>
70
require(['echarts'/*, 'map/js/china' */], function (echarts) {
72
const seriesFocusType = {
78
sunburst: 'descendant',
79
treemap: 'descendant',
82
allChartsOptions.forEach(function (chartOption) {
83
chartOption.series.forEach(function (series) {
84
series.emphasis = series.emphasis || {};
85
series.emphasis.focus = series.emphasis.focus || seriesFocusType[series.type] || 'series';
87
if (series.renderItem) {
88
const oldRenderItem = series.renderItem;
89
series.renderItem = function () {
90
const ret = oldRenderItem.apply(this, arguments);
101
if (series.type === 'treemap') {
103
borderColor: 'rgba(100, 100, 200, 0.1)',
106
series.upperLabel = {
112
else if (series.type === 'line') {
116
series.labelLayout = {
121
const dom = document.createElement('div');
122
dom.className = 'chart';
123
document.querySelector('#main').appendChild(dom);
125
const chart = echarts.init(dom);
126
chart.setOption(chartOption);
130
// testcases about dispatchAction: 'highlight'
131
(function addDispatchActionHighlightChart(){
132
// Basic options for all charts
134
for (var i = 0; i <= 100; i++) {
135
var theta = (i / 100) * 360;
136
var r = 5 * (1 + Math.sin((theta / 180) * Math.PI));
137
polarData.push([r, theta]);
140
var seriesBlurEmphasis = {
144
var globalBlurEmphasis = {
148
var coordinateSystemBlurEmphasis = {
150
blurScope: "coordinateSystem",
154
////////////// Hightlight multilple series(blurScope = 'series') //////////////
156
id: "highlightMultipleSeries(blurScope='series', focus='self')",
157
name: "Dispatch action to hightlight multiple series (with blurScope='series', focus='self')",
170
data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
182
emphasis: seriesBlurEmphasis,
183
data: [320, 302, 301, 334, 390, 330, 320],
191
emphasis: seriesBlurEmphasis,
192
data: [120, 132, 101, 134, 90, 230, 210],
195
name: "Affiliate Ad",
200
emphasis: seriesBlurEmphasis,
201
data: [220, 182, 191, 234, 290, 330, 310],
209
emphasis: seriesBlurEmphasis,
210
data: [150, 212, 201, 154, 190, 330, 410],
214
////////////// Hightlight multilple series(blurScope = 'global') //////////////
216
id: "highlightMultipleSeries(blurScope='global', focus='series')",
217
name: "Dispatch action to hightlight multiple series (with blurScope='global', focus='series')",
230
data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
242
data: [320, 302, 301, 334, 390, 330, 320],
243
emphasis: globalBlurEmphasis,
251
data: [120, 132, 101, 134, 90, 230, 210],
252
emphasis: globalBlurEmphasis,
255
name: "Affiliate Ad",
260
data: [220, 182, 191, 234, 290, 330, 310],
261
emphasis: globalBlurEmphasis,
269
data: [150, 212, 201, 154, 190, 330, 410],
270
emphasis: globalBlurEmphasis,
274
////////////// Hightlight multilple series(blurScope = 'coordinateSystem') //////////////
276
id: "highlightMultipleSeries(blurScope='coordinateSystem', focus='series')",
277
name: "Dispatch action to hightlight multiple series (with blurScope='coordinateSystem', focus='series')",
291
data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
306
coordinateSystem: 'polar',
310
emphasis: coordinateSystemBlurEmphasis,
318
data: [320, 302, 301, 334, 390, 330, 320],
319
emphasis: coordinateSystemBlurEmphasis,
327
data: [120, 132, 101, 134, 90, 230, 210],
328
emphasis: coordinateSystemBlurEmphasis,
331
name: "Affiliate Ad",
336
data: [220, 182, 191, 234, 290, 330, 310],
337
emphasis: coordinateSystemBlurEmphasis,
345
data: [150, 212, 201, 154, 190, 330, 410],
346
emphasis: coordinateSystemBlurEmphasis,
350
for(const chartOption of options){
351
const dom = document.createElement('div');
352
dom.className = 'chart';
353
document.querySelector('#main').appendChild(dom);
354
const chart = testHelper.create(echarts, dom, {
355
title: chartOption.name,
359
text: 'Dispatch highlight action({seriesIndex: [1, 2], dataIndex: [0,1,2]})',
360
onclick: function () {
361
chart.dispatchAction({
380
allChartsOptions.forEach(function (chartOption, idx) {
381
chartOption.series.forEach(function (series) {
384
color: blurOpts.grayColor ? '#aaa' : null,
385
opacity: blurOpts.opacity
388
color: blurOpts.grayColor ? '#aaa' : null,
389
opacity: blurOpts.opacity
392
color: blurOpts.grayColor ? '#aaa' : null,
393
opacity: blurOpts.opacity
396
color: blurOpts.grayColor ? '#aaa' : null,
397
opacity: blurOpts.opacity
401
charts[idx].setOption(chartOption);
405
var gui = new dat.GUI();
406
gui.add(blurOpts, 'opacity', 0, 1).onFinishChange(update);
407
gui.add(blurOpts, 'grayColor').onChange(update);
409
window.addEventListener('resize', function () {
410
charts.forEach(function (chart) {