area-stack.html 7.7 KB
Newer Older
L
lang 已提交
1 2 3
<html>
    <head>
        <meta charset="utf-8">
L
lang 已提交
4
        <script src="http://requirejs.org/docs/release/2.2.0/minified/require.js"></script>
S
sushuang 已提交
5
        <script src="lib/config.js"></script>
P
pah100 已提交
6
        <meta name="viewport" content="user-scalable=no,width=device-width,height=device-height">
L
lang 已提交
7 8 9 10 11 12 13 14 15 16 17 18
    </head>
    <body>
        <style>
            html, body, #main {
                width: 100%;
                height: 100%;
            }
        </style>
        <div id="main"></div>
        <script>

            require([
S
sushuang 已提交
19 20 21 22 23 24
                'echarts'
                // 'echarts/chart/line',
                // 'echarts/component/legend',
                // 'echarts/component/gridSimple',
                // 'echarts/component/tooltip',
                // 'zrender/vml/vml'
L
lang 已提交
25 26
            ], function (echarts) {

S
sushuang 已提交
27
                var chart = echarts.init(document.getElementById('main'));
L
lang 已提交
28 29 30 31 32

                var xAxisData = [];
                var data1 = [];
                var data2 = [];
                var data3 = [];
S
sushuang 已提交
33 34 35
                var data4 = [];
                var data5 = [];
                var data6 = [];
L
lang 已提交
36

L
lang 已提交
37 38 39 40
                xAxisData.push('类目' + -1);
                data1.push('-');
                data2.push('-');
                data3.push('-');
S
sushuang 已提交
41 42 43
                data4.push('-');
                data5.push('-');
                data6.push('-');
L
lang 已提交
44

L
lang 已提交
45
                for (var i = 0; i < 5; i++) {
L
lang 已提交
46
                    xAxisData.push('类目' + i);
L
lang 已提交
47 48 49
                    data1.push((-Math.random() - 0.2).toFixed(3));
                    data2.push((Math.random() + 0.3).toFixed(3));
                    data3.push((Math.random() + 0.2).toFixed(3));
S
sushuang 已提交
50 51 52
                    data4.push((-Math.random() - 0.2).toFixed(3));
                    data5.push((-Math.random() - 0.2).toFixed(3));
                    data6.push((Math.random() + 0.2).toFixed(3));
L
lang 已提交
53 54
                }

P
pah100 已提交
55
                xAxisData.push('类目' + i);
L
lang 已提交
56 57 58
                data1.push('-');
                data2.push('-');
                data3.push('-');
S
sushuang 已提交
59 60 61
                data4.push('-');
                data5.push('-');
                data6.push('-');
L
lang 已提交
62 63 64 65 66 67

                for (; i < 10; i++) {
                    xAxisData.push('类目' + i);
                    data1.push((-Math.random() - 0.2).toFixed(3));
                    data2.push((Math.random() + 0.3).toFixed(3));
                    data3.push((Math.random() + 0.2).toFixed(3));
S
sushuang 已提交
68 69 70
                    data4.push((-Math.random() - 0.2).toFixed(3));
                    data5.push((-Math.random() - 0.2).toFixed(3));
                    data6.push((Math.random() + 0.2).toFixed(3));
L
lang 已提交
71
                }
L
lang 已提交
72 73 74 75
                xAxisData.push('类目' + i);
                data1.push('-');
                data2.push('-');
                data3.push('-');
S
sushuang 已提交
76 77 78
                data4.push('-');
                data5.push('-');
                data6.push('-');
L
lang 已提交
79

L
lang 已提交
80 81
                var itemStyle = {
                    normal: {
L
lang 已提交
82 83
                        // borderColor: 'white',
                        // borderWidth: 3,
L
lang 已提交
84 85 86 87 88
                        // shadowBlur: 10,
                        // shadowOffsetX: 0,
                        // shadowOffsetY: 5,
                        // shadowColor: 'rgba(0, 0, 0, 0.4)',
                        lineStyle: {
P
pah100 已提交
89
                            width: 2
L
lang 已提交
90 91 92 93 94 95 96 97 98 99 100 101
                            // shadowBlur: 10,
                            // shadowOffsetX: 0,
                            // shadowOffsetY: 5,
                            // shadowColor: 'rgba(0, 0, 0, 0.4)'
                        },
                        areaStyle: {
                        }
                    }
                };

                chart.setOption({
                    legend: {
S
sushuang 已提交
102 103 104 105 106 107 108
                    },
                    toolbox: {
                        feature: {
                            magicType: {
                                type: ['line', 'bar', 'stack', 'tiled']
                            }
                        }
L
lang 已提交
109 110 111
                    },
                    tooltip: {
                        trigger: 'axis',
L
lang 已提交
112 113 114
                        position: function (point) {
                            return [point[0], '10%'];
                        },
L
lang 已提交
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
                        axisPointer: {
                            type: 'line'
                        }
                    },
                    xAxis: {
                        // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
                        data: xAxisData,
                        boundaryGap: false,
                        // inverse: true,
                        splitArea: {
                            show: true
                        }
                    },
                    yAxis: {
                        splitLine: {
                            // show: false
                        }
                    },
S
sushuang 已提交
133 134 135 136 137
                    dataZoom: [{
                        type: 'inside'
                    }, {
                        type: 'slider'
                    }],
L
lang 已提交
138 139 140 141 142 143
                    series: [{
                        name: 'line',
                        type: 'line',
                        stack: 'all',
                        symbolSize: 10,
                        data: data1,
L
lang 已提交
144
                        itemStyle: itemStyle,
L
lang 已提交
145 146
                        smooth: true,
                        connectNulls: true
L
lang 已提交
147 148 149 150 151 152
                    }, {
                        name: 'line2',
                        type: 'line',
                        stack: 'all',
                        symbolSize: 10,
                        data: data2,
L
lang 已提交
153
                        itemStyle: itemStyle,
L
lang 已提交
154
                        connectNulls: true,
L
lang 已提交
155
                        smooth: true
L
lang 已提交
156
                    }, {
S
sushuang 已提交
157
                        name: '+connectNulls:true',
L
lang 已提交
158 159 160 161
                        type: 'line',
                        stack: 'all',
                        symbolSize: 10,
                        data: data3,
L
lang 已提交
162
                        itemStyle: itemStyle,
163 164 165 166 167
                        label: {
                            normal: {
                                show: true
                            }
                        },
L
lang 已提交
168
                        connectNulls: true,
L
lang 已提交
169
                        smooth: true
S
sushuang 已提交
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
                    }, {
                        name: '-connectNulls:false',
                        type: 'line',
                        stack: 'all',
                        symbolSize: 10,
                        data: data4,
                        itemStyle: itemStyle,
                        label: {
                            normal: {
                                show: true
                            }
                        },
                        connectNulls: false,
                        smooth: true
                    }, {
                        name: '-connectNulls:true',
                        type: 'line',
                        stack: 'all',
                        symbolSize: 10,
                        data: data5,
                        itemStyle: itemStyle,
                        label: {
                            normal: {
                                show: true
                            }
                        },
                        connectNulls: true,
                        smooth: true
                    }, {
                        name: '+connectNulls:false',
                        type: 'line',
                        stack: 'all',
                        symbolSize: 10,
                        data: data6,
                        itemStyle: itemStyle,
                        label: {
                            normal: {
                                show: true
                            }
                        },
                        connectNulls: false,
                        smooth: true
L
lang 已提交
212 213 214 215 216 217 218
                    }]
                });
            })

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