Demo entry 6351504

dsada

   

Submitted by 大厦 on Mar 21, 2017 at 08:13
Language: JavaScript. Code size: 6.3 kB.

$(document).ready(function() {
    var map;
    var metrics = '[Measure][Pv]';

    function updateMapData() {
        if (!map) {
            map = $('#china-map').map();
        }yugjhbn

        var data = {"Rows":[{"Header":"福建","CellDictionary":{"[Measure][Pv]":1278.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"北京","CellDictionary":{"[Measure][Pv]":3769.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"重庆","CellDictionary":{"[Measure][Pv]":718.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"浙江","CellDictionary":{"[Measure][Pv]":3226.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"山东","CellDictionary":{"[Measure][Pv]":2907.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"辽宁","CellDictionary":{"[Measure][Pv]":2048.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"云南","CellDictionary":{"[Measure][Pv]":876.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"湖南","CellDictionary":{"[Measure][Pv]":1416.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"河北","CellDictionary":{"[Measure][Pv]":2333.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"贵州","CellDictionary":{"[Measure][Pv]":574.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"江苏","CellDictionary":{"[Measure][Pv]":2462.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"广东","CellDictionary":{"[Measure][Pv]":4225.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"四川","CellDictionary":{"[Measure][Pv]":1447.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"安徽","CellDictionary":{"[Measure][Pv]":1001.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"甘肃","CellDictionary":{"[Measure][Pv]":468.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"广西","CellDictionary":{"[Measure][Pv]":790.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"山西","CellDictionary":{"[Measure][Pv]":937.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"江西","CellDictionary":{"[Measure][Pv]":949.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"上海","CellDictionary":{"[Measure][Pv]":1706.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"天津","CellDictionary":{"[Measure][Pv]":858.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"青海","CellDictionary":{"[Measure][Pv]":96.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"黑龙江","CellDictionary":{"[Measure][Pv]":1205.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"海南","CellDictionary":{"[Measure][Pv]":123.0},"RowTime":"2017-02-16T06:44:30"},{"Header":"内蒙古","CellDictionary":{"[Measure][Pv]":1219.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"湖北","CellDictionary":{"[Measure][Pv]":1148.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"河南","CellDictionary":{"[Measure][Pv]":1788.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"吉林","CellDictionary":{"[Measure][Pv]":1185.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"陕西","CellDictionary":{"[Measure][Pv]":986.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"台湾","CellDictionary":{"[Measure][Pv]":18.0},"RowTime":"2017-02-16T06:43:30"},{"Header":"宁夏","CellDictionary":{"[Measure][Pv]":109.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"Lombardia","CellDictionary":{"[Measure][Pv]":1.0},"RowTime":"2017-02-16T06:38:00"},{"Header":"香港","CellDictionary":{"[Measure][Pv]":22.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"新疆","CellDictionary":{"[Measure][Pv]":18.0},"RowTime":"2017-02-16T06:44:30"},{"Header":"西藏","CellDictionary":{"[Measure][Pv]":20.0},"RowTime":"2017-02-16T06:45:30"},{"Header":"Melaka","CellDictionary":{"[Measure][Pv]":1.0},"RowTime":"2017-02-16T06:42:30"},{"Header":"Sonora","CellDictionary":{"[Measure][Pv]":1.0},"RowTime":"2017-02-16T06:21:00"},{"Header":"Varna","CellDictionary":{"[Measure][Pv]":1.0},"RowTime":"2017-02-16T06:45:00"},{"Header":"澳门","CellDictionary":{"[Measure][Pv]":2.0},"RowTime":"2017-02-16T06:43:00"}],"Columns":["[Measure][Pv]"],"TotalRowCount":38}

        handleMapData(data, map);
    }

    function handleMapData(data, map){
        var rows = data.Rows,
                i,
                len = rows.length,
                item,
                category = [],
                data = [],
                mapLines = [],
                mapPoints = [],
                citys = {
                    '北京': [116.4, 39.9],
                    '天津': [117.2, 39.12],
                    '河北': [114.52, 38.05],
                    '山西': [112.55, 37.87],
                    '内蒙古': [111.73, 40.83],
                    '辽宁': [123.43, 41.8],
                    '吉林': [125.32, 43.9],
                    '黑龙江': [126.53, 45.8],
                    '上海': [121.47, 31.23],
                    '江苏': [118.78, 32.07],
                    '浙江': [120.15, 30.28],
                    '安徽': [117.25, 31.83],
                    '福建': [119.3, 26.08],
                    '江西': [115.85, 28.68],
                    '山东': [116.98, 36.67],
                    '河南': [113.62, 34.75],
                    '湖北': [114.3, 30.6],
                    '湖南': [112.93, 28.23],
                    '广东': [113.27, 23.13],
                    '广西': [108.37, 22.82],
                    '海南': [110.32, 20.03],
                    '重庆': [106.55, 29.57],
                    '四川': [104.07, 30.67],
                    '贵州': [106.63, 26.65],
                    '云南': [102.72, 25.05],
                    '西藏': [91.13, 29.65],
                    '陕西': [08.93, 34.27],
                    '甘肃': [103.82, 36.07],
                    '青海': [101.78, 36.62],
                    '宁夏': [106.28, 38.47],
                    '新疆': [87.62, 43.82],
                    '香港': [114.08, 22.2],
                    '澳门': [113.33, 22.13],
                    '台湾': [121.5, 25.03]
                };
        rows.sort(function (a, b) {
            return b.CellDictionary[metrics] - a.CellDictionary[metrics];
        });

        for (i = 0; i < len; i++) {
            item = rows[i];

            if (citys[item.Header]) {
                if (category.length < 10) {
                    category.push(item.Header);
                    data.push(item.CellDictionary[metrics]);
                }

                mapLines.push([{ name: item.Header }, { name: '北京', value: item.CellDictionary[metrics] }]);
                mapPoints.push({ name: item.Header, value: item.CellDictionary[metrics] });
            }
        }

        map.update([{ name: '北京', selected: true }], mapLines, mapPoints);
    }

    updateMapData();

});

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).