简体   繁体   中英

html5 canvas tag - 2d context rendering not working

I implemented the HTML5 canvas tag in asp.net2010 to draw graph bars but its not working below is the code that I implement in my .aspx page its showing empty page. I am using browsers like (updated version of Chrome, Firefox, IE9)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CanvasChart.aspx.cs"     Inherits="CanvasChart" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>

        <script src="Scripts/RGraph.bar.js"  type="text/javascript"></script>
        <script type="text/javascript">
            window.onload = function () {

                var data = [280, 45, 133];
                var bar = new RGraph.Bar('testroundchart', data);

                bar.Set('chart.labels', ['Richard', 'Alex', 'Nick']);
                bar.Set('chart.gutter.left', 45);
                bar.Set('chart.background.barcolor1', 'white');
                bar.Set('chart.background.barcolor2', 'white');
                bar.Set('chart.background.grid', true);
                bar.Set('chart.colors', ['red']);

                bar.Draw();
            }
        </script>

    </head>

    <body>
        <form id="form1" runat="server">
            <div>
                <canvas id="testroundchart" runat ="server" width="800" height="400"></canvas>

            </div>
        </form>
    </body>

Thanks Bhanu Prakash Inturi

You have to add two more script tags ( RGraph.common.core.js and excanvas.original.js ) to make your code work:

<script src="libraries/RGraph.common.core.js" ></script>
<!--[if lt IE 9]><script src="excanvas/excanvas.original.js"></script><![endif]-->

The second script tag is only needed for Internet Explorer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM