[英]html5 canvas tag - 2d context rendering not working
我在asp.net2010中实现了HTML5 canvas标记以绘制图形栏,但是在我的.aspx页面中实现的代码在下面显示的却是空的,因此它无法正常工作。 我正在使用类似的浏览器(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>
感谢Bhanu Prakash Inturi
您必须再添加两个脚本标记( RGraph.common.core.js
和excanvas.original.js
)才能使代码工作:
<script src="libraries/RGraph.common.core.js" ></script>
<!--[if lt IE 9]><script src="excanvas/excanvas.original.js"></script><![endif]-->
仅Internet Explorer才需要第二个脚本标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.