zoukankan      html  css  js  c++  java
  • highcharts 实例

    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>

    <script src="../../Scripts/highcharts/highcharts.js" type="text/javascript"></script>
    <script type="text/javascript">
    var columnName = "";
    var Key = "";

    var date = new Array();
    var val = new Array();
    $(function () {
    $.ajax({
    type: "post",
    url: "/Charts/getList",
    async: false,
    success: function (str) {
    var str2 = $.parseJSON(str);
    if (str2.length > 0) {
    for (var i = 0; i < str2.length; i++) {
    // if (i == 0) {
    // columnName += str2[i].年月;
    // Key += str2[i].统计;
    // mycars[i] = str2[i].统计
    // }
    // else {
    // columnName += "," + str2[i].年月;
    // Key += "," + str2[i].统计;
    // mycars[i] = str2[i].统计
    // }

    //此处楼主需要显示的X轴为"X月份"这么个字符串,后台取得的数据而仅仅为数字,对此进行加工
    date.push(str2[i].年月 + "月份");
    //也可以在对数据的处理放在highchart 中进行处理。
    val.push(parseFloat(str2[i].统计));
    }

    }
    }
    });
    });


    onload = function () {
    // alert(date);
    // alert(val);

    $('#container').highcharts({
    chart: {
    type: 'column'
    },
    title: {
    text: '月出借款额度'
    },
    subtitle: {
    text: 'Source: 9fbank.com'
    },
    xAxis: {
    categories: date
    // [
    // date
    // ]
    },
    yAxis: {
    min: 0,
    title: {
    text: '借款 (元)'
    }
    },
    tooltip: {
    headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
    pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
    '<td style="padding:0"><b>{point.y:.1f} 元</b></td></tr>',
    footerFormat: '</table>',
    shared: true,
    useHTML: true
    },
    plotOptions: {
    column: {
    pointPadding: 0.2,
    borderWidth: 0
    }
    },
    series: [{
    name: '出借额度',
    data: val //[
    //"49.9"*"1"
    //, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4
    //val

    //]

    }]
    });
    }



    </script>

    <body>
    <div id="container" style="min- 700px; height: 400px">
    </div>
    </body>

    -----------------------------------

    上面 ajax  请求的   /Charts/getList  返回的是josn 字符串

    自己做的时候 比较坑的是 ,自己一直把数组 放到  categories: [ date  ]   中括号 内,所以一直调不出来,

  • 相关阅读:
    另一种逆元的求解方法
    SSHFS使用笔记
    HDU 2612 Find a way (BFS)
    POJ 3984 迷宫问题 (BFS + Stack)
    计蒜客 疑似病毒 (AC自动机 + 可达矩阵)
    HUD 1426 Sudoku Killer (DFS)
    计蒜客 成绩统计 (Hash表)
    计蒜客 劫富济贫 (Trie树)
    POJ 2251 Dungeon Master (BFS)
    [IB]Integration Broker 是如何处理传入的请求(Part 2)
  • 原文地址:https://www.cnblogs.com/yangjinwang/p/4959388.html
Copyright © 2011-2022 走看看