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

折线图

时间:2018-05-31 11:30:03      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:code   ado   average   数据   art   平均值   async   height   nbsp   

<body>
    <div id="main" style="height:300px;width:800px"></div>
    <script src="~/assets/js/echarts.js"></script>
    <script>
    $(function () {

        var rootid = $.Query("rootid");

        var xdrift = [];
        var ypull = [];

        var charts = echarts.init(document.getElementById("main"));

        Option = {
            title: { text: 钢绞线数据, subtext: ‘‘ },
            tooltip: { trigger: axis, axisPointer: { type: shadow } },
            toolbox: { show: true },
            legend: {
                show: true,
                orient: horizontal,
                x: center,
                y: top,
                data:[位移,力值]
            },
            toolbox: { itemGap: 5 },
            grid: { left: 3%, right: 10%, bottom: 3%, containLabel: true },
            xAxis: {
                data: [],//X轴参数
                show: true,
                name: 位移(MM),
                boundaryGap: false,
                axisLabel: {
                    interval: 0,
                    textStyle: {
                        color: #FF0000
                    }
                },
                axisLine: {
                    color: #FF0000,
                    width: 2
                },
                splitLine: {
                    show: true
                }
            },
            yAxis: {
                show: true,
                name: 力值(KN),
                axisLabel: {
                    textStyle: {
                        color: #FF0000
                    }
                }, axisLine: {
                    lineStyle: {
                        color: #FF0000,
                        width: 2
                    }
                },
                splitLine: {
                    show: true
                }
            },
            series: []//数据
        }

        $.ajax({
            url: "/api/Tension/GetRootData",
            type: GET,
            data: { "RootId": rootid },
            async: true,
            dataType: JSON,
            success: function (args) {
                if (args == "" || args == null) {
                    layer.msg(没有数据);
                }else{
                    var data = JSON.parse(args.RootData);
                    for (var item in data) {
                        xdrift.push(data[item].drift);
                        ypull.push(data[item].pull);
                    }


                    charts.setOption({
                        xAxis: {
                            data: xdrift.sort(),
                            axisTick: { length: 10 },
                            axisLabel: {
                                formatter: function (val)
                                {
                                    
                                    return val;
                                }
                            }
                        },
                        series: [{
                            name: 力值,
                            type: line,
                            data: ypull,
                            markPoint: {
                                data: [
                                    { type: max, name: 最大值 }
                                ]
                            },
                            markLine: {
                                data: [
                                    { type: average, name: 平均值 }
                                ]
                            }
                        }]
                    })
                }
            }
        })


        charts.setOption(Option);

    })

    </script>

</body>

 

折线图

标签:code   ado   average   数据   art   平均值   async   height   nbsp   

原文地址:https://www.cnblogs.com/yelvin/p/9115470.html

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