clip.html 12.4 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 52
        <div class="chart" id="large-scatter-clip"></div>
        <div class="chart" id="lines-clip"></div>
        <div class="chart" id="bar-clip"></div>
53 54
        <div class="chart" id="custom-clip"></div>
        <div class="chart" id="candlestick-clip"></div>
55 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

        <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 已提交
101
                    title: 'Scatter Clip on Cartesian',
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
                    option: option,
                    height: 400,
                    buttons: makeToggleChartButtons(function (clip) {
                        chart.setOption({
                            series: [{
                                clip: clip
                            }]
                        })
                    })
                });
            })
        </script>





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

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

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


        <script>
            require([
                'echarts'
            ], function (echarts) {
P
pissang 已提交
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 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
                // 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
                                }]
                            })
                        }

                    }])
                });
237 238 239
            })
        </script>

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 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
        <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 = {
                        name: "测试直线"+i+1,
                        coords: [
                            [0, 0],
                            [x, y]
                        ],
                        label: {
                            show:false
                        },
                        lineStyle: {
                            normal: {
                                color: getColor(),
                                width: 1
                            }
                        }
                    };
                    lineData.push(obj);
                }

                option = {
                    animation: false,
                    title: {
                        text: '网络拓扑图'
                    },
                    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>

359 360
    </body>
</html>