码迷,mamicode.com
首页 > 其他好文 > 详细

echarts(3.0)的基本使用(标签式导入)

时间:2016-09-02 13:12:24      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:

function loadRainFallCharts(msg) {
        var obj = {};
        obj.x = [];
        obj.y = [];
        obj.line = [];
        var accumulation = 0;
        $(msg).each(function () {
            obj.x.push(this.datatime);
            obj.y.push(this.avgvalue);
            accumulation += this.avgvalue;
            obj.line.push(accumulation);
        });
        var myChart = echarts.init(document.getElementById(‘inThePast6hours_rainfall‘));

        var option = {
            title: {
                text: ‘实时雨量曲线(过去6小时)‘,
                subtext: ‘‘,
                x: ‘center‘,
                align: ‘right‘
            },
            legend: {
                data: [‘时段降水‘, ‘累积降水‘],
                x: ‘left‘
            },
            tooltip: {
                trigger: ‘axis‘,
                axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                    type: ‘shadow‘        // 默认为直线,可选为:‘line‘ | ‘shadow‘
                }
            },
            grid: {
                left: ‘3%‘,
                right: ‘4%‘,
                bottom: ‘3%‘,
                containLabel: true
            },
            xAxis: [
                {
                    type: ‘category‘,
                    data: obj.x.map(function (str) {
                        return str.replace(‘ ‘, ‘\n‘)
                    }),
                    axisTick: {
                        alignWithLabel: true
                    }
                }
            ],
            yAxis: [
                {
                    type: ‘value‘,
                    name: ‘雨量(mm)‘,
                    nameLocation: ‘start‘,
                    inverse: true
                }
            ],
            series: [
                {
                    name: ‘时段降水‘,
                    type: ‘bar‘,
                    barWidth: ‘60%‘,
                    data: obj.y
                }, {
                    name: ‘累积降水‘,
                    type: ‘line‘,
                    stack: ‘广告‘,
                    data: obj.line
                },
            ]
        };

        myChart.setOption(option);
    }

 依赖:http://files.cnblogs.com/files/gaocong/echarts.js

echarts(3.0)的基本使用(标签式导入)

标签:

原文地址:http://www.cnblogs.com/gaocong/p/5832864.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!