RGraph : svg : 玫瑰图

www.rgraph.net下载RGraph.minified-2018-08-14.zip

解压后,将目录libraries简化为:lib

rose图例子:RGraph/svg_rose1.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>RGraph : SVG rose 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.rose.js"></script>
</head>
<body>
  <div style="width: 500px; height: 500px" id="chart-container"></div>
    <div id="tab"></div>
<script>
    var keys = ['周一','周二','周三','周四','周五','周六','周日'];
    var data = [8,6,4,3,8,6,3];
    var tips = ['Alf','Bertie','Charlie','Doug','Edgar','Frankie','Gary'];
    var colors = ['blue','green','red','#aaa','black','brown','pink'];

    var rose = new RGraph.SVG.Rose({
        id: 'chart-container',
        data: data,
        options: {
            tooltips: tips,
            colors: colors,
            colorsSequential: true,
            //backgroundGridRadialsCount: 0,
            linewidth: 2,
            margin: '3deg',
            key: keys,
            keyOffsety: 455
        }
    }).draw().on('tooltip', function (obj)
    {
        var tooltip = RGraph.SVG.REG.get('tooltip');
        var colors  = rose.properties.colors;

        tooltip.style.border = '4px solid ' + colors[tooltip.__index__]
    });
    
    RGraph.SVG.tooltips.style.backgroundColor = 'white';
    RGraph.SVG.tooltips.style.color           = 'black';
    RGraph.SVG.tooltips.style.fontWeight      = 'bold';
    RGraph.SVG.tooltips.style.boxShadow       = 'none';
// 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); // 创建第一行
    for(var j=0; j<keys.length; j++){
        td = tr.insertCell(tr.cells.length);
        td.innerHTML = keys[j];
        td.align = "center";
    }
    tr = tb.insertRow(tb.rows.length); // 创建一行
    for(var j=0; j<tips.length; j++){
        td = tr.insertCell(tr.cells.length);
        td.innerHTML = tips[j];
        td.align = "center";
    }
    tr = tb.insertRow(tb.rows.length); // 创建一行
    for(var j=0; j<data.length; j++){
        td = tr.insertCell(tr.cells.length);
        td.innerHTML = data[j];
        td.align = "center";
    }
    document.querySelector("#tab").appendChild(table);
</script>
</body>
</html>

相关推荐