sunburst.html 4.7 KB
Newer Older
O
Ovilia 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<html>
    <head>
        <meta charset="utf-8">
        <script src="lib/esl.js"></script>
        <script src="lib/config.js"></script>
    </head>
    <body>
        <style>
            html, body, #main {
                width: 100%;
                height: 100%;
                /* background-image: url(old_mathematics.png); */
                /* background-repeat: repeat; */
            }
        </style>
        <div id="main"></div>
        <script>
            var chart;
            require([
                'echarts'
            ], function (echarts) {

23 24 25
                chart = echarts.init(document.getElementById('main'), null, {
                    // renderer: 'svg'
                });
O
Ovilia 已提交
26

27 28 29 30 31 32 33 34 35 36 37 38 39 40
                var data = [{
                    name: 'Grandpa',
                    children: [{
                        name: 'Uncle Leo',
                        value: 15,
                        children: [{
                            name: 'Cousin Jack',
                            value: 2
                        }, {
                            name: 'Cousin Mary',
                            value: 5,
                            itemStyle: {
                                normal: {
                                    opacity: 0.2
41
                                }
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
                            }
                        }, {
                            name: 'Cousin Ben',
                            value: 4
                        }],
                        itemStyle: {
                            normal: {
                                color: '#660'
                            }
                        }
                    }, {
                        name: 'Aunt Jane',
                        children: [{
                            name: 'Cousin Kate',
                            value: 4,
57
                            itemStyle: {
58 59
                                normal: {
                                    color: 'blue'
60 61
                                }
                            }
62 63 64 65 66 67 68
                        }]
                    }, {
                        name: 'Father',
                        value: 10,
                        children: [{
                            name: 'Me',
                            value: 5
69
                        }, {
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
                            name: 'Brother Peter',
                            value: 1
                        }],
                        itemStyle: {
                            downplay: {
                                opacity: 0.1
                            }
                        }
                    }],
                    itemStyle: {
                        downplay: {
                            opacity: 0.8
                        }
                    }
                }, {
                    name: 'Grandpa\'s friend Mike',
                    children: [{
                        name: 'Uncle Dan',
                        children: [{
                            name: 'Cousin Lucy',
                            value: 3
91
                        }, {
92 93
                            name: 'Cousin Luck',
                            value: 4
94
                        }]
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
                    }]
                }, {
                    name: 'Grandpa\'s friend Nancy',
                    children: [{
                        name: 'Uncle Dan',
                        children: [{
                            name: 'Cousin Lucy',
                            value: 1
                        }, {
                            name: 'Cousin Luck',
                            value: 2
                        }]
                    }]
                }];

                chart.setOption({
                    series: {
                        type: 'sunburst',
                        // highlightPolicy: 'ancestor',
                        data: data
O
Ovilia 已提交
115 116 117
                    }
                });

118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
                setTimeout(function () {
                    data.push({
                        name: 'Stranger',
                        children: [{
                            name: 'S1',
                            value: 4
                        }, {
                            name: 'S2',
                            value: 1
                        }]
                    });
                    chart.setOption({
                        series: {
                            data: data
                        }
                    });
                }, 3000);

                setTimeout(function () {
                    data.splice(1, 1);
                    data[0].value = 32;
                    chart.setOption({
                        series: {
                            data: data
                        }
                    });
                }, 6000);

O
Ovilia 已提交
146 147 148 149 150
            });

        </script>
    </body>
</html>