在HTML5的Canvas元素上绘制图形数据(二)
时间:2011-01-08 来源:永恒的记忆
第一部分的图形数据展示
这一部分的图形数据展示
实现代码如下

您可以复制这段代码,浏览效果。
添加背景
代码
添加X/Y轴数值
代码function addlabels(){
ctx.font = "10pt Arial";
/* y axis labels */
ctx.fillText("Temps", 2, 15);
ctx.fillText("100", 5, 40);
ctx.fillText(" 80", 5, 60);
ctx.fillText(" 60", 5, 80);
ctx.fillText(" 40", 5, 100);
ctx.fillText(" 20", 5, 120);
/* x axis labels */
ctx.fillText("Days", 100, 160);
ctx.fillText("1", 26, 150);
ctx.fillText("2", 56, 150);
ctx.fillText("3", 86, 150);
ctx.fillText("4", 116, 150);
ctx.fillText("5", 146, 150);
ctx.fillText("6", 176, 150);
ctx.fillText("7", 206, 150);
}
相关阅读 更多 +
排行榜 更多 +