clip.html 7.9 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 53 54 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 101 102
        <div class="chart" id="large-scatter-clip"></div>
        <div class="chart" id="scatter-clip-polar"></div>

        <h1>Lines</h1>
        <div class="chart" id="lines-clip"></div>
        <h1>Bar</h1>
        <div class="chart" id="bar-clip"></div>

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





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

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

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


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

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

    </body>
</html>