hoverStyle.html 34.9 KB
Newer Older
S
sushuang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<!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/esl.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>
        <link rel="stylesheet" href="lib/reset.css" />
    </head>
    <body>
        <style>
            .test-title {
                background: #146402;
                color: #fff;
            }
S
sushuang 已提交
39 40 41 42
            #info {
                position: fixed;
                left: 0;
                top: 0;
S
sushuang 已提交
43 44
                background: #333;
                color: #fff;
S
sushuang 已提交
45 46 47 48
                padding: 2px 5px;
                z-index: 9999;
                box-shadow: 0 0 2px #333;
            }
S
sushuang 已提交
49 50
        </style>

S
sushuang 已提交
51 52 53 54
        <br>
        <br>
        <br>

S
sushuang 已提交
55
        <div id="info"></div>
S
sushuang 已提交
56

57
        <div id="maina1"></div>
S
sushuang 已提交
58 59
        <div id="mainb1"></div>
        <div id="mainb2"></div>
S
sushuang 已提交
60
        <div id="mainb3"></div>
61
        <div id="mainb4"></div>
S
sushuang 已提交
62

S
sushuang 已提交
63 64 65 66
        <div id="main0"></div>
        <div id="main1"></div>
        <div id="main2"></div>
        <div id="main3"></div>
S
sushuang 已提交
67
        <div id="main4"></div>
S
sushuang 已提交
68
        <div id="main5"></div>
69
        <div id="main6"></div>
S
Tweak  
sushuang 已提交
70 71
        <div id="main7"></div>
        <div id="main8"></div>
S
sushuang 已提交
72 73


S
sushuang 已提交
74 75


S
sushuang 已提交
76
        <script>
S
sushuang 已提交
77 78 79
            var USE_HOVER_LAYER_KEY = '__EC_TEST_USE_HOVER_LAYER_KEY___';

            var useHoverLayer = getUseHoverLayer();
S
sushuang 已提交
80 81 82 83
            var hoverLayerThreshold = useHoverLayer ? 0 : null;
            var infoEl = document.getElementById('info');
            genInfo();

S
sushuang 已提交
84 85 86 87 88 89 90
            function setUseHoverLayer(useHoverLayer) {
                window.localStorage.setItem(USE_HOVER_LAYER_KEY, useHoverLayer ? 'true' : '');
            }
            function getUseHoverLayer() {
                return !!window.localStorage.getItem(USE_HOVER_LAYER_KEY);
            }

S
sushuang 已提交
91 92
            function genInfo(zrRefreshTimestamp) {
                infoEl.innerHTML = [
S
sushuang 已提交
93 94 95
                    '<span style="color:yellow">'
                        + (useHoverLayer ? 'Using HoverLayer' : 'NOT using HoverLayer')
                    + '</span>',
S
sushuang 已提交
96
                    'hoverLayerThreshold: ' + hoverLayerThreshold,
S
sushuang 已提交
97
                    'zr refresh base layer at: <span style="color:yellow">' + (zrRefreshTimestamp || null) + '</span>'
S
sushuang 已提交
98 99 100 101 102
                ].join('<br>');
            }

            function genHoverLayerBtns() {
                return [{
S
sushuang 已提交
103
                    text: 'NOT use hoverLayer',
S
sushuang 已提交
104
                    onclick: function () {
S
sushuang 已提交
105 106
                        setUseHoverLayer(false);
                        location.reload();
S
sushuang 已提交
107 108
                    }
                }, {
S
sushuang 已提交
109
                    text: 'Use hoverLayer',
S
sushuang 已提交
110
                    onclick: function () {
S
sushuang 已提交
111 112
                        setUseHoverLayer(true);
                        location.reload();
S
sushuang 已提交
113 114 115 116 117 118
                    }
                }]
            }

            var originalCreate = testHelper.create;
            testHelper.create = function (echarts, dom, opt) {
S
sushuang 已提交
119 120 121 122
                if (opt.option.hoverLayerThreshold === void 0) {
                    throw new Error('"hoverLayerThreshold" should be set');
                }

S
sushuang 已提交
123 124 125 126
                var buttons = opt.buttons || [];
                opt.buttons = buttons = genHoverLayerBtns().concat(buttons);
                var chart = originalCreate.call(this, echarts, dom, opt);

127 128 129 130 131 132 133 134 135 136
                if (chart) {
                    var zr = chart.getZr();
                    var originalRefreshImmediately = zr.refreshImmediately;
                    zr.refreshImmediately = function () {
                        var result = originalRefreshImmediately.apply(this, arguments);
                        // Make sure refreshImmediately is not called when `useHoverLayer`.
                        genInfo(+new Date());
                        return result;
                    };
                }
S
sushuang 已提交
137 138 139 140 141 142 143 144 145 146

                return chart;
            }
        </script>






S
sushuang 已提交
147

148 149 150 151 152 153 154







155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
        <script>


            var option;

            require([
                'echarts'
            ], function (echarts) {

                var option = {
                    hoverLayerThreshold: hoverLayerThreshold,
                    xAxis: {
                        axisLine: {show: false},
                        axisTick: {show: false},
                        splitLine: {show: false},
                        axisLabel: {show: false}
                    },
                    yAxis: {
                        axisLine: {show: false},
                        axisTick: {show: false},
                        splitLine: {show: false},
                        axisLabel: {show: false}
                    },
                    series: {
                        type: 'line',
                        markPoint: {
                            data: [{
                                type: 'max',
                                name: 'a'
                            }]
                        },
                        data: [[12,34]]
                    }
                };

                var chart = testHelper.create(echarts, 'maina1', {
                    option: option,
                    height: 150,
                    title: [
                        'Only a pin displayed',
                        'The text of the "pin" should be **inside**',
                        'Hover "pin", should be normal'
                    ]
                });
            });
        </script>





206

S
sushuang 已提交
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
        <script>
            require(['echarts'], function (echarts) {
                var option = {
                    hoverLayerThreshold: hoverLayerThreshold,
                    xAxis: {
                    },
                    yAxis: {
                    },
                    grid: {
                        right: 120
                    },
                    visualMap: {
                        min: 100,
                        max: 800,
                        top: 10,
                        right: 10,
                        splitNumber: 3,
                        type: 'piecewise',
225 226
                        demension: 1,
                        hoverLink: true,
S
sushuang 已提交
227 228 229 230 231 232 233 234 235 236 237
                        inRange: {
                            color: ['blue', 'red']
                        },
                        outOfRange: {
                            color: 'black'
                        }
                    },
                    series: [{
                        type: 'scatter',
                        symbolSize: 30,
                        data: [
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
                            [12, 331], [55, 131], [55, 531]
                        ]
                    }, {
                        type: 'scatter',
                        symbol: 'rect',
                        symbolSize: 40,
                        label: {
                            show: true,
                            formatter: 'label inside\nhover red\n{c}'
                        },
                        emphasis: {
                            label: {
                                color: 'red'
                            }
                        },
                        data: [
                            [112, 331], [115, 131], [165, 531]
                        ]
                    }, {
                        type: 'scatter',
                        symbol: 'triangle',
                        symbolSize: 40,
                        label: {
                            show: true,
                            formatter: 'label inside\n{c}'
                        },
                        emphasis: {
                            label: {
                                position: 'top',
                                formatter: 'hover become top\n{c}'
                            }
                        },
                        data: [
                            [212, 331], [215, 131], [265, 531]
S
sushuang 已提交
272
                        ]
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
                    }, {
                        type: 'scatter',
                        symbol: 'rect',
                        symbolSize: 40,
                        label: {
                            show: true,
                            formatter: 'label stroke orange hover blue\n{c}',
                            textBorderWidth: 3,
                            textBorderColor: 'orange'
                        },
                        emphasis: {
                            label: {
                                formatter: 'hover become stroke blue',
                                textBorderColor: 'blue'
                            }
                        },
                        data: [
                            [312, 51]
                        ]
                    }, {
                        type: 'custom',
                        renderItem: function (params, api) {
                            var coords = api.coord([312, 351]);
                            return {
                                type: 'rect',
                                shape: {
                                    x: coords[0],
                                    y: coords[1],
                                    width: 50,
                                    height: 50
                                },
                                // check api.style
                                style: api.style({
                                    text: 'label stroke orange hover blue',
                                    textStrokeWidth: 2,
                                    textStroke: 'orange'
                                }),
                                styleEmphasis: api.styleEmphasis({
                                    textStroke: 'blue'
                                })
                            };
                        },
                        data: [
                            [312, 151]
                        ]
S
sushuang 已提交
318 319 320
                    }]
                };

321
                var chart = testHelper.create(echarts, 'mainb1', {
S
sushuang 已提交
322
                    title: [
323 324 325
                        'visualMap should be normal (and hoverLink should **scale circles**)',
                        '(inRange: has color, outOfRange: "black")',
                        'Click visualMap when hoverlink, circle color should be changed, but **keep scaled**.',
S
sushuang 已提交
326 327
                        'Click button highlight dataIndex 0, only "middle blue" highlighted',
                        'Then hover **blue** visualMap, all blue highlighted, and then unhover, "middle blue" should keep highlighted'
S
sushuang 已提交
328 329
                    ],
                    option: option,
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
                    height: 300,
                    buttons: [{
                        text: 'highlight dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'highlight',
                                dataIndex: 0
                            });
                        }
                    }, {
                        text: 'downplay dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'downplay',
                                dataIndex: 0
                            });
                        }
                    }]
S
sushuang 已提交
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
                });
            });
        </script>







        <script>
            require(['echarts'], function (echarts) {
                var option = {
                    hoverLayerThreshold: hoverLayerThreshold,
                    xAxis: {
                    },
                    yAxis: {
                    },
                    series: [{
                        type: 'scatter',
                        symbolSize: 30,
                        data: [
                            [12, 131],
                            [55, 431],
                            [55, 331]
                        ]
                    }]
                };

                var chart = testHelper.create(echarts, 'mainb2', {
                    title: [
                        'setOption onclick and hover animation should be normal:',
                        'click any symbol, all symbols should become blue'
                    ],
                    option: option,
                    height: 200
                });

386
                chart && chart.on('click', function () {
S
sushuang 已提交
387 388 389 390 391 392 393 394 395
                    chart.setOption({
                        color: ['blue']
                    });
                });
            });
        </script>



S
sushuang 已提交
396 397


S
sushuang 已提交
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
        <script>
            require(['echarts'], function (echarts) {
                var option = {
                    hoverLayerThreshold: hoverLayerThreshold,
                    xAxis: {
                    },
                    yAxis: {
                    },
                    series: [{
                        type: 'scatter',
                        symbolSize: 100,
                        data: [
                            {value: [0, 0], itemStyle: {color: 'blue'}},
                            {value: [0, 1], itemStyle: {color: 'red'}}
                        ]
                    }]
                };

                var chart = testHelper.create(echarts, 'mainb3', {
                    title: [
                        'hover the blue symbol, the z2 can be top',
                        'unhover, **z2 should be back** to bottom'
                    ],
                    option: option,
                    height: 200
                });
            });
        </script>



429 430 431 432 433 434 435 436 437 438 439 440 441 442


        <script>
            require(['echarts'], function (echarts) {
                var option = {
                    hoverLayerThreshold: hoverLayerThreshold,
                    series: [{
                        type: 'graph',
                        symbolSize: 20,
                        focusNodeAdjacency: true,
                        data: [
                            {value: 100, name: 'aa', x: 100, y: 200},
                            {value: 150, name: 'bb', x: 450, y: 300},
                            {value: 200, name: 'cc', x: 200, y: 100},
443
                            {value: 250, name: 'dd', x: 450, y: 250,
444 445 446 447 448 449
                                emphasis: {
                                    itemStyle: {
                                        color: 'blue'
                                    }
                                }
                            }
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
                        ],
                        links: [
                            {source: 'aa', target: 'bb'},
                            {source: 'aa', target: 'dd'},
                            {source: 'cc', target: 'bb'}
                        ],
                        lineStyle: {
                            color: 'green',
                            type: 'dashed', // [4, 6],
                            width: 3
                        },
                        emphasis: {
                            lineStyle: {
                                color: 'orange',
                                type: 'solid',
                                width: 8
                            }
                        }
                    }]
                };

                var chart = testHelper.create(echarts, 'mainb4', {
                    title: [
473
                        'normal style is **line: green dashed width 3, node: red**,',
474
                        'should become **line: orange solid width 8, node: only "dd" blue** when hovered'
475 476 477 478 479 480 481 482 483
                    ],
                    option: option,
                    height: 200
                });
            });
        </script>



S
sushuang 已提交
484 485 486
        <script>
            require(['echarts'], function (echarts) {
                var option = {
S
sushuang 已提交
487
                    hoverLayerThreshold: hoverLayerThreshold,
S
sushuang 已提交
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
                    tooltip: {},
                    xAxis: {
                    },
                    yAxis: {
                        splitNumber: 2,
                        scale: true
                    },
                    series: [{
                        type: 'scatter',
                        symbolSize: 30,
                        emphasis: {
                            label: {
                                show: true
                            }
                        },
                        data: [[12, 331221], [55, 331221]]
                    }]
                };

                testHelper.create(echarts, 'main0', {
                    title: [
                        'normal no label, hover show label inside',
S
sushuang 已提交
510
                        'TEST: hover twice, should be normal',
S
sushuang 已提交
511
                        'zrBaseLayer should not be refreshed if NOT using hoverLayer'
S
sushuang 已提交
512 513 514 515 516 517 518 519 520 521 522 523 524 525
                    ],
                    option: option,
                    height: 200
                });
            });
        </script>





        <script>
            require(['echarts'], function (echarts) {
                var option = {
S
sushuang 已提交
526
                    hoverLayerThreshold: hoverLayerThreshold,
S
sushuang 已提交
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
                    tooltip: {},
                    xAxis: {
                    },
                    yAxis: {
                        splitNumber: 2,
                        scale: true
                    },
                    series: [{
                        type: 'scatter',
                        symbolSize: 30,
                        label: {
                            show: true
                        },
                        itemStyle: {
                            color: 'green',
                            opacity: 1
                        },
                        emphasis: {
                            label: {
                                position: 'top'
                            }
                        },
S
sushuang 已提交
549
                        data: [[12, 331221], [20, 331221], [55, 331221]]
S
sushuang 已提交
550 551 552 553 554
                    }]
                };

                testHelper.create(echarts, 'main1', {
                    title: [
S
sushuang 已提交
555 556
                        'normal label inside, hover label outside top.',
                        'lifted color should be able to restore after hover twice.'
S
sushuang 已提交
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
                    ],
                    option: option,
                    height: 200
                });
            });
        </script>







        <script>
            require(['echarts'], function (echarts) {
                var option = {
S
sushuang 已提交
573
                    hoverLayerThreshold: hoverLayerThreshold,
S
sushuang 已提交
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
                    tooltip: {},
                    xAxis: {
                    },
                    yAxis: {
                        splitNumber: 2,
                        scale: true
                    },
                    series: [{
                        type: 'scatter',
                        symbolSize: 30,
                        label: {
                            show: true
                        },
                        itemStyle: {
                            color: 'green',
                            opacity: 1
                        },
                        emphasis: {
                            itemStyle: {
                                color: 'red'
                            },
                            label: {
                                position: 'top'
                            }
                        },
                        data: [[12, 331221], [55, 331221]]
                    }]
                };

                var chart = testHelper.create(echarts, 'main2', {
                    title: [
                        'normal style: green',
                        'trigger hover by API (red, text top).',
                        'Test mouse hover and leave, should NOT return to normal.',
                        'Only click downplay to return normal'
                    ],
                    option: option,
                    height: 200,
                    buttons: [{
                        text: 'highlight dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'highlight',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }, {
                        text: 'downplay dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'downplay',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }]
                });
            });
        </script>








        <script>
            require(['echarts'], function (echarts) {
                var option = {
S
sushuang 已提交
645
                    hoverLayerThreshold: hoverLayerThreshold,
S
sushuang 已提交
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
                    tooltip: {},
                    xAxis: {
                    },
                    yAxis: {
                        splitNumber: 2,
                        scale: true
                    },
                    series: [{
                        type: 'scatter',
                        id: 's',
                        symbolSize: 30,
                        label: {
                            show: true
                        },
                        itemStyle: {
                            color: 'green',
                            opacity: 1
                        },
                        emphasis: {
                            itemStyle: {
                                color: 'red'
                            },
                            label: {
                                position: 'top'
                            }
                        },
                        data: [[12, 331221], [55, 331221]]
                    }]
                };

                var chart = testHelper.create(echarts, 'main3', {
                    title: [
                        'trigger hover by API (red, text top).',
                        'setOption to change hoverStyle.'
                    ],
                    option: option,
                    height: 200,
                    buttons: [{
                        text: 'highlight dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'highlight',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }, {
S
sushuang 已提交
693
                        text: 'setOption to modify hoverStyle yellow',
S
sushuang 已提交
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708
                        onclick: function () {
                            chart.setOption({
                                series: [{
                                    id: 's',
                                    emphasis: {
                                        itemStyle: {
                                            color: 'yellow'
                                        },
                                        label: {
                                            fontSize: 30
                                        }
                                    }
                                }]
                            });
                        }
S
sushuang 已提交
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
                    }, {
                        text: 'setOption to modify hoverStyle blue',
                        onclick: function () {
                            chart.setOption({
                                series: [{
                                    id: 's',
                                    emphasis: {
                                        itemStyle: {
                                            color: 'blue'
                                        },
                                        label: {
                                            fontSize: 50
                                        }
                                    }
                                }]
                            });
                        }
S
sushuang 已提交
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742
                    }, {
                        text: 'downplay dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'downplay',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }]
                });
            });
        </script>




S
sushuang 已提交
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794


        <script>
            require(['echarts'], function (echarts) {
                var option = {
                    hoverLayerThreshold: hoverLayerThreshold,
                    tooltip: {},
                    xAxis: {
                    },
                    yAxis: {
                        splitNumber: 2,
                        scale: true
                    },
                    series: [{
                        type: 'custom',
                        renderItem: function (params, api) {
                            return {
                                type: 'group',
                                children: [{
                                    type: 'rect',
                                    shape: {x: 100, y: 30, width: 100, height: 50},
                                    style: {fill: '#333'}
                                }, {
                                    type: 'rect',
                                    shape: {x: 130, y: 50, width: 100, height: 50},
                                    style: {fill: '#555'}
                                }, {
                                    type: 'rect',
                                    shape: {x: 160, y: 70, width: 100, height: 50},
                                    style: {fill: '#777'}
                                }]
                            };
                        },
                        data: [[12, 331221], [55, 331221]]
                    }]
                };

                testHelper.create(echarts, 'main4', {
                    title: [
                        'custom series: all highlighted when hover, keep z correct'
                    ],
                    option: option,
                    height: 200
                });
            });
        </script>






S
sushuang 已提交
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817
        <script>
            require(['echarts'], function (echarts) {
                var option = {
                    hoverLayerThreshold: hoverLayerThreshold,
                    tooltip: {},
                    xAxis: {
                    },
                    yAxis: {
                        splitNumber: 2,
                        scale: true
                    },
                    series: [{
                        type: 'line',
                        symbolSize: 20,
                        data: [[21, 22], [44, 11]]
                    }]
                };

                var chart = testHelper.create(echarts, 'main5', {
                    title: [
                        'Test default symbol hover style (scale) (Only test **Not use hoverLayer**)',
                        'trigger hover by API: **should scaled**.',
                        'Test mouse hover and leave, should NOT return to normal.',
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858
                        'Only click downplay to return normal'
                    ],
                    option: option,
                    height: 200,
                    buttons: [{
                        text: 'highlight dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'highlight',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }, {
                        text: 'downplay dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'downplay',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }]
                });
            });
        </script>







        <script>
            require(['echarts'], function (echarts) {
                var option = {
                    hoverLayerThreshold: hoverLayerThreshold,
                    tooltip: {},
                    series: [{
                        type: 'pie',
                        data: [
859 860 861
                            {value: 12, name: 'Click this sector:\nit keep color-lifted and scaled'},
                            {value: 15, name: 'zxcv'},
                            {value: 17, name: 'Click this sector:\nit becomes yellow, keep color-lifted and scaled'}
862 863 864 865 866 867 868
                        ]
                    }]
                };

                var chart = testHelper.create(echarts, 'main6', {
                    title: [
                        'Pie **hightlight priority** of API and mouse:',
869 870
                        'Hover on sector, **should scaled and color lifted**.',
                        'trigger hover by API: **should scaled and color-lifted**.',
871
                        'Test mouse hover and leave, should NOT return to normal.',
872 873
                        'Only click downplay to return normal',
                        'Click the red sector, it **keep scaled and color-lifted**',
S
sushuang 已提交
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
                        'Only click downplay to return normal'
                    ],
                    option: option,
                    height: 200,
                    buttons: [{
                        text: 'highlight dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'highlight',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }, {
                        text: 'downplay dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'downplay',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }]
                });
898 899 900 901 902 903 904 905 906 907 908 909 910 911

                chart && chart.on('click', function (e) {
                    if (e.dataIndex === 0) {
                        chart.dispatchAction({
                            type: 'highlight',
                            seriesIndex: 0,
                            dataIndex: 0
                        });
                    }
                    else if (e.dataIndex === 2) {
                        option.series[0].data[2].itemStyle = {color: 'yellow'};
                        chart.setOption(option);
                    }
                });
S
sushuang 已提交
912 913 914 915 916 917
            });
        </script>




S
Tweak  
sushuang 已提交
918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022



        <script>
            require(['echarts'], function (echarts) {
                var option = {
                    hoverLayerThreshold: hoverLayerThreshold,
                    tooltip: {},
                    series: [{
                        type: 'funnel',
                        label: {
                            show: false
                        },
                        emphasis: {
                            label: {show: true}
                        },
                        data: [
                            {value: 12, name: 'poiu'},
                            {value: 15, name: 'zxcv'},
                            {value: 17, name: 'casdf'}
                        ]
                    }]
                };

                var chart = testHelper.create(echarts, 'main7', {
                    title: [
                        'Click button highlight dataIndex 0 show label',
                        'Then hover and unhover the sector, highlight state will not changed'
                    ],
                    option: option,
                    height: 200,
                    buttons: [{
                        text: 'highlight dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'highlight',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }, {
                        text: 'downplay dataIndex 0',
                        onclick: function () {
                            chart.dispatchAction({
                                type: 'downplay',
                                seriesIndex: 0,
                                dataIndex: 0
                            });
                        }
                    }]
                });
            });
        </script>





        <script>
            $.get('../map/json/china.json', function (chinaJson) {
                if (typeof chinaJson === 'string') {
                    chinaJson = eval('(' + chinaJson + ')');
                }
                require(['echarts'], function (echarts) {
                    echarts.registerMap('china', chinaJson);
                    var option = {
                        hoverLayerThreshold: hoverLayerThreshold,
                        tooltip: {},
                        legend: {},
                        geo: [{
                            type: 'map',
                            map: 'china',
                            roam: true,
                            scaleLimit: {
                                min: 1.5,
                                max: 10
                            },
                            selectedMode: 'multiple'
                        }]
                    };

                    var chart = testHelper.create(echarts, 'main8', {
                        title: [
                            'Click button toggleSelected 内蒙古',
                            'Then hover and unhover the region, highlight state will not changed'
                        ],
                        option: option,
                        height: 400,
                        buttons: [{
                            text: 'toggleSelected 内蒙古',
                            onclick: function () {
                                chart.dispatchAction({
                                    type: 'geoToggleSelect',
                                    geoIndex: 0,
                                    name: '内蒙古'
                                });
                            }
                        }]
                    });
                });
            });
        </script>



1023 1024 1025 1026 1027 1028






S
sushuang 已提交
1029 1030
    </body>
</html>