`
belldeep
  • 浏览: 40972 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

RGraph : svg : 双线图

阅读更多
www.rgraph.net 下载 RGraph.minified-2018-08-14.zip
解压后,将目录 libraries 简化为: lib
双线图例子: RGraph/svg/line2.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>RGraph : SVG Line charts API </title>
  <script src="./lib/RGraph.svg.common.core.js"></script>
  <script src="./lib/RGraph.svg.common.key.js"></script>
  <script src="./lib/RGraph.svg.common.tooltips.js"></script>
  <script src="./lib/RGraph.svg.line.js"></script>
</head>
<body>
    <div style="width: 750px; height: 300px" id="chart-line"></div>
    <div id="tab"></div>
<script>
    var keys = ['Richard','Charlie'];
    var data =[[0.05,0.06,0.01,0.06,0.09,0.02,0.07],
               [0.07,0.02,0.06,0.08,0.05,0.05,0.02]];
    var labels = ['周一','周二','周三','周四','周五','周六','周日'];
    
    var line2 = new RGraph.SVG.Line({
        id: 'chart-line',
        data: data,
        options: {
            backgroundGridVlines: true,
            backgroundGridBorder: false,
            key: keys,
            
            gutterTop: 55,

            linewidth: 5,
            hmargin: 0,
            
            title: 'A basic linechart',
            
            gutterLeft: 50,
            gutterBottom: 50,
            yaxisDecimals: 2,
            
            tickmarksStyle: 'endcircle',
            tickmarksFill: 'white',
            tickmarksLinewidth: 3,
            tickmarksSize: 10,
            
            spline: true,
            xaxis: false,
            yaxis: false,
            xaxisLabels: labels,
            shadow: true
        }
    }).trace();
// create table
    var table = document.createElement("table");
    table.border = "1"; // table.width = "100%";
    var tb = document.createElement("tbody");
    table.appendChild(tb);
    var tr,td;
    tr = tb.insertRow(0); // 创建第一行
    td = tr.insertCell(0); // 插入单元格
    td.innerHTML = "Name"; // 加字段名
    for(var j=0; j<labels.length; j++){
        td = tr.insertCell(tr.cells.length);
        td.innerHTML = labels[j];
        td.align = "center";
    }
    // 多行数组
    for(var i=0; i<keys.length; i++){
        tr = tb.insertRow(tb.rows.length); // 创建一行
        td = tr.insertCell(0); // 插入单元格
        td.innerHTML = keys[i]; // 加名字
        for(var j=0; j< data[i].length; j++){
            td = tr.insertCell(tr.cells.length);
            td.innerHTML = data[i][j];
            td.align = "center";
        }
    }
    document.querySelector("#tab").appendChild(table); 
</script>
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics