
<!--
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">
        <title>calendar</title>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="stylesheet" href="lib/reset.css">
        <script src="lib/simpleRequire.js"></script>
        <script src="lib/config.js"></script>
        <script src="lib/jquery.min.js"></script>
    </head>
    <body>
        <style>
            html, body, #main {
                width: 100%;
                height: 100%;
            }
        </style>
        <div id="main"></div>
        <script>


            var getVirtulData =  function(year) {

                year = year || '2017';

                var datas = [];

                var arr31 = [1, 3, 5, 7, 8, 10, 12];
                var arr30 = [4, 6, 9, 11];
                for (var i = 1; i <= 31; i++) {
                    for (var j = arr31.length - 1; j >= 0; j--) {
                        datas.push([year + '-' + arr31[j] + '-' + i, Math.floor(Math.random() * 1000)]);
                    }
                }
                for (var i = 1; i <= 30; i++) {
                    for (var j = arr30.length - 1; j >= 0; j--) {
                        datas.push([year + '-' + arr30[j] + '-' + i, Math.floor(Math.random() * 1000)]);
                    }
                }
                for (var i = 1; i <= 29; i++) {
                    datas.push([year + '-2-' + i, Math.floor(Math.random() * 1000)]);
                }
                return datas;
            }
            require(['echarts'], function (echarts) {

                var chart = echarts.init(document.getElementById('main'));

                chart.setOption({
                    title: {
                        left: 'center',
                        text: '2017年北京空气质量情况',
                        subtext: '数据纯属虚构'
                    },
                    tooltip: {
                        formatter: function (p) {
                            var format = echarts.format.formatTime('yyyy-MM-dd', p.data[0])
                            return format + ': ' + p.data[1];
                        }
                    },
                    calendar: {
                        top: 70,
                        range: '2017'
                    },
                    legend: {
                        top: 'top',
                        data: ['pm2.5', 'AQI'],
                        textStyle: {
                            color: '#fff',
                            fontSize: 16
                        }
                    },
                    /*visualMap: [{
                        text: ['北京pm2.5'],
                        min: 0,
                        max: 1000,
                        seriesIndex: 0,
                        calculable: true,
                        orient: 'horizontal',
                        left: 260,
                        top: 500
                    },
                    {
                        text: ['北京AQI'],
                        min: 0,
                        max: 1000,
                        seriesIndex: 1,
                        calculable: true,
                        orient: 'horizontal',
                        left: 500,
                        top: 500
                    }],*/
                    series: [{
                        name: '北京pm2.5',
                        type: 'scatter',
                        symbolSize: function (val) {
                            return val[1] / 100;
                        },
                        coordinateSystem: 'calendar',
                        data: getVirtulData(2017)
                    }/*,
                    {
                        name: '北京AQI',
                        type: 'scatter',
                        symbolSize: function (val) {
                            return val[1] / 100;
                        },
                        coordinateSystem: 'calendar',
                        data: getVirtulData(2017)
                    }*/]
                });

                $(window).resize(function() {
                    chart.resize();
                });

                $(window).resize(function() {
                    chart.resize();
                });
            });
        </script>
    </body>
</html>
