clip.html 17.8 KB
Newer Older
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 39 40 41 42 43 44 45 46 47

<!--
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/facePrint.js"></script>
        <script src="lib/testHelper.js"></script>
        <link rel="stylesheet" href="lib/reset.css" />
    </head>
    <body>
        <style>
            h1 {
                line-height: 60px;
                height: 60px;
                background: #ddd;
                text-align: center;
                font-weight: bold;
                font-size: 14px;
            }
            .chart {
                height: 500px;
            }
        </style>

        <div class="chart" id="scatter-clip-cartesian"></div>
        <div class="chart" id="scatter-clip-polar"></div>
P
pissang 已提交
48 49
        <!-- <h1>Scatter Clip with Incremental Rendering</h1>
        <div class="chart" id="scatter-clip-incremental"></div> -->
50 51
        <div class="chart" id="large-scatter-clip"></div>
        <div class="chart" id="lines-clip"></div>
52
        <div class="chart" id="line-dataZoom"></div>
53
        <div class="chart" id="bar-clip"></div>
54 55
        <div class="chart" id="custom-clip"></div>
        <div class="chart" id="candlestick-clip"></div>
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101

        <script>
            function makeToggleChartButtons(toggleClip) {
                return  [{
                    text: 'Set Clip',
                    onclick: function () {
                        toggleClip(true);
                    }
                }, {
                    text: 'Set Visible',
                    onclick: function () {
                        toggleClip(false);
                    }
                }];
            }
        </script>

        <script>
            require([
                'echarts'
            ], function (echarts) {
                var option = {
                    xAxis: {},
                    yAxis: {
                        min: 5,
                        max: 10
                    },
                    series: [{
                        symbolSize: 20,
                        data: [
                            [10.0, 8.04],
                            [8.0, 6.95],
                            [13.0, 7.58],
                            [9.0, 8.81],
                            [11.0, 8.33],
                            [14.0, 9.96],
                            [6.0, 7.24],
                            [4.0, 4.26],
                            [12.0, 10.84],
                            [7.0, 4.82],
                            [5.0, 5.68]
                        ],
                        type: 'scatter'
                    }]
                };
                var chart = testHelper.create(echarts, 'scatter-clip-cartesian', {
P
pissang 已提交
102
                    title: 'Scatter Clip on Cartesian',
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
                    option: option,
                    height: 400,
                    buttons: makeToggleChartButtons(function (clip) {
                        chart.setOption({
                            series: [{
                                clip: clip
                            }]
                        })
                    })
                });
            })
        </script>





        <script>
            require([
                'echarts'
            ], function (echarts) {
P
pissang 已提交
124 125 126 127 128 129
                var data1 = [];

                for (var i = 0; i < 100; i++) {
                    data1.push([Math.random() * 10, Math.random() * 360]);
                }

130
                var option = {
P
pissang 已提交
131 132 133 134 135 136 137 138 139 140
                    polar: {},
                    angleAxis: {
                        type: 'value',
                        min: 50,
                        max: 180
                    },
                    radiusAxis: {
                        axisAngle: 0,
                        min: 0,
                        max: 5
141 142
                    },
                    series: [{
P
pissang 已提交
143 144 145 146 147
                        coordinateSystem: 'polar',
                        name: 'scatter',
                        type: 'scatter',
                        symbolSize: 10,
                        data: data1
148 149
                    }]
                };
P
pissang 已提交
150 151
                var chart = testHelper.create(echarts, 'scatter-clip-polar', {
                    title: 'Scatter Clip on Polar',
152 153 154 155 156 157 158 159 160 161 162 163 164 165
                    option: option,
                    height: 400,
                    buttons: makeToggleChartButtons(function (clip) {
                        chart.setOption({
                            series: [{
                                clip: clip
                            }]
                        })
                    })
                });
            })
        </script>


166 167 168



169 170 171 172
        <script>
            require([
                'echarts'
            ], function (echarts) {
P
pissang 已提交
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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
                // Standard Normal variate using Box-Muller transform.
                function rand() {
                    var u = 0, v = 0;
                    while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
                    while(v === 0) v = Math.random();
                    return Math.sqrt(-2.0 * Math.log( u )) * Math.cos(2.0 * Math.PI * v);
                }

                var data = [];

                for (let i = 0; i < 1e4; i++) {
                    data.push([
                        rand(),
                        rand()
                    ]);
                }
                var option = {
                    xAxis: {
                        type: 'value',
                        min: -2,
                        max: 2
                    },
                    yAxis: {
                        type: 'value',
                        min: -2,
                        max: 2
                    },
                    series: [{
                        symbolSize: 2,
                        large: true,
                        data: data,
                        symbol: 'rect',
                        type: 'scatter'
                    }]
                };
                var chart = testHelper.create(echarts, 'large-scatter-clip', {
                    title: 'Large Scatter Clip',
                    option: option,
                    height: 400,
                    buttons: makeToggleChartButtons(function (clip) {
                        chart.setOption({
                            series: [{
                                clip: clip
                            }]
                        })
                    }).concat([{
                        text: 'Set Large',
                        onclick: function () {
                            chart.setOption({
                                series: [{
                                    large: true,
                                    progressive: 0
                                }]
                            })
                        }
                    }, {
                        text: 'Set Stream',
                        onclick: function () {
                            chart.setOption({
                                series: [{
                                    large: false,
                                    progressive: 2000
                                }]
                            })
                        }

                    }])
                });
241 242 243
            })
        </script>

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 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 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
        <script>
            require([
                'echarts'
            ], function (echarts) {

                var lineData = []

                function getColor() {
                    //定义字符串变量colorValue存放可以构成十六进制颜色值的值
                    var colorValue = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f";
                    //以","为分隔符,将colorValue字符串分割为字符数组["0","1",...,"f"]
                    var colorArray = colorValue.split(",");
                    var color = "#";//定义一个存放十六进制颜色值的字符串变量,先将#存放进去
                    //使用for循环语句生成剩余的六位十六进制值
                    for (var i = 0; i < 6; i++) {
                        //colorArray[Math.floor(Math.random()*16)]随机取出
                        // 由16个元素组成的colorArray的某一个值,然后将其加在color中,
                        //字符串相加后,得出的仍是字符串
                        color += colorArray[Math.floor(Math.random() * 16)];
                    }
                    return color;
                }

                for (var i = 0; i < 20; ++i) {
                    var x = Math.floor(Math.random()*600+50)
                    var y = Math.floor(Math.random()*600+50)
                    var xSign = Math.floor(Math.random()*2+1)
                    var ySign = Math.floor(Math.random()*2+1)
                    //负数
                    if (xSign === 1) {
                        x *= -1;
                    }
                    if (ySign === 1) {
                        y *= -1;
                    }

                    var obj = {
                        coords: [
                            [0, 0],
                            [x, y]
                        ],
                        label: {
                            show:false
                        },
                        lineStyle: {
                            normal: {
                                color: getColor(),
                                width: 1
                            }
                        }
                    };
                    lineData.push(obj);
                }

                option = {
                    animation: false,
                    xAxis: {
                        type:'value',
                        min: -1000,
                        max: 1000,
                        splitLine:{
                        lineStyle: {
                            width: 1
                        }
                      }
                    },
                    yAxis: {
                        type:'value',
                        min: -1000,
                        max: 1000,
                        splitLine:{
                        lineStyle: {
                            width: 1
                        }
                      }
                    },
                    dataZoom: [{
                            type: 'inside',
                            xAxisIndex: 0,
                            filterMode: 'filter'
                        },
                        {
                            type: 'inside',
                            yAxisIndex: 0,
                            filterMode: 'weakFilter'
                        }
                    ],
                    series: [{
                        type: 'lines',
                        name: '网络拓扑图',
                        coordinateSystem: 'cartesian2d',
                        lineStyle: {
                            normal: {
                                color: '#F00',
                                width: 1
                            }
                        },
                        label: {
                        fontSize: 15
                        },
                        symbol: ['none', 'arrow'],
                        // 数据
                        data: lineData
                    }]
                };

                var chart = testHelper.create(echarts, 'lines-clip', {
                    title: 'Lines Clip,(case from #10748). Should not overflow after zoomed in',
                    option: option,
                    height: 400,
                    buttons: makeToggleChartButtons()
                });
            })
        </script>

363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 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 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509


        <script>
            require([
                'echarts'
            ], function (echarts) {

                var base = +new Date(2016, 9, 3);
                var oneDay = 24 * 3600 * 1000;
                var valueBase = Math.random() * 300;
                var valueBase2 = Math.random() * 50;
                var data = [];
                var data2 = [];

                for (var i = 1; i < 10; i++) {
                    var now = new Date(base += oneDay);
                    var dayStr = [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('-');

                    valueBase = Math.round((Math.random() - 0.5) * 20 + valueBase);
                    valueBase <= 0 && (valueBase = Math.random() * 300);
                    data.push([dayStr, valueBase]);

                    valueBase2 = Math.round((Math.random() - 0.5) * 20 + valueBase2);
                    valueBase2 <= 0 && (valueBase2 = Math.random() * 50);
                    data2.push([dayStr, valueBase2]);
                }

                option = {
                    animation: false,
                    legend: {
                        top: 'bottom',
                        data:['意向']
                    },
                    tooltip: {
                        triggerOn: 'none',
                        position: function (pt) {
                            return [pt[0], 130];
                        }
                    },
                    toolbox: {
                        left: 'center',
                        itemSize: 25,
                        top: 55,
                        feature: {
                            dataZoom: {
                                // Not filter the data.
                                filterMode: 'none',
                                yAxisIndex: 'none'
                            },
                            restore: {}
                        }
                    },
                    xAxis: {
                        type: 'time',
                        splitLine: {
                            show: false
                        }
                    },
                    yAxis: {
                        type: 'value',
                        axisTick: {
                            inside: true
                        },
                        splitLine: {
                            show: false
                        },
                        axisLabel: {
                            inside: true,
                            formatter: '{value}\n'
                        },
                        z: 10
                    },
                    grid: {
                        top: 110,
                        left: 15,
                        right: 15,
                        height: 160
                    },
                    dataZoom: [{
                        type: 'inside',
                        throttle: 50
                    }],
                    series: [
                        {
                            name:'模拟数据',
                            type:'line',
                            smooth: true,
                            symbol: 'circle',
                            symbolSize: 5,
                            sampling: 'average',
                            itemStyle: {
                                normal: {
                                    color: '#8ec6ad'
                                }
                            },
                            stack: 'a',
                            areaStyle: {
                                normal: {
                                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                        offset: 0,
                                        color: '#8ec6ad'
                                    }, {
                                        offset: 1,
                                        color: '#ffe'
                                    }])
                                }
                            },
                            data: data
                        },
                        {
                            name:'模拟数据',
                            type:'line',
                            smooth:true,
                            stack: 'a',
                            symbol: 'circle',
                            symbolSize: 5,
                            sampling: 'average',
                            itemStyle: {
                                normal: {
                                    color: '#d68262'
                                }
                            },
                            areaStyle: {
                                normal: {
                                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                        offset: 0,
                                        color: '#d68262'
                                    }, {
                                        offset: 1,
                                        color: '#ffe'
                                    }])
                                }
                            },
                            data: data2
                        }

                    ]
                };

                var chart = testHelper.create(echarts, 'line-dataZoom', {
                    title: 'Line with dataZoom,(#10224). Should not be blank when selected a small area',
                    option: option,
                    height: 400
                });
            })
        </script>

510 511
    </body>
</html>