天天看点

网页,html5,canvas,js 动态绘制柱形图

网页,html5,canvas,js 动态绘制柱形图

<!doctype html>

    <head><title>chart demo</title>

        <style>

            #chartcontainer{

                border:solid 1px #999;

            }

        </style>

        <script src="h5draw.js"></script>

        <script src="h5charts.js"></script>

        <script>

            function   zxt(){

            var chart = new h5charts.serialchart();

            chart.dataprovider = [{age:"18",amount:0.1},{age:"38",amount:0.3},

{age:"8",amount:0.4},{age:"29",amount:0.2}];

            chart.categoryfield = "age";

            chart.valuefield = "amount";

            chart.type = "column";

            chart.columnwidth = 55;

            chart.colors = ["#f00","#0f0","#0ff","#00f"];

            chart.addto("chartcontainer");

            };

        </script>

    </head>

    <body>

        <canvas id="chartcontainer" width="1000" height="400">

             browser doesn't support html5

        </canvas>

        <script>zxt()</script>

    </body>

</html>

本例需要两个js文件,可以去http://download.csdn.net/detail/u013378306/8756825下载

继续阅读