如何使用javascript创建简单的条形图

时间:2013-05-10 00:52:23

标签: javascript

用户将输入图表的数据。我使用过画线,但我不能把位置弄好。到目前为止,这是我的代码。由于java环境被嵌入到网页中,我无法使用条形图库。

// Ex5-1: Weather Data Graph
enter code herevar canvas;
canvas = openGraphics();
var sun;
var n;
var xposition;
xposition = 40;
sun = prompt("enter the sun");
sun = parseInt(sun, 10);
 ///xposition= xposition +10;
canvas.drawLine(40, 10, 40, 245);
canvas.drawLine(40, 245, 390, 245);
canvas.drawString("225 ", 10, 30);
canvas.drawString("180 ", 10, 70);
canvas.drawString("135 ", 10, 110);
canvas.drawString("90 ", 10, 150);
canvas.drawString("45 ", 10, 190);
canvas.drawString("0 ", 10, 230);
canvas.drawString("J ", 50, 250);
canvas.drawString("F ", 80, 250);
canvas.drawString("M ", 110, 250);
canvas.drawString("A ", 140, 250);
canvas.drawString("M ", 170, 250);
canvas.drawString("J ", 200, 250);
canvas.drawString("J ", 230, 250);
canvas.drawString("A ", 260, 250);
canvas.drawString("S ", 290, 250);
canvas.drawString("O ", 320, 250);
canvas.drawString("N ", 350, 250);
canvas.drawString("D ", 380, 250);
canvas.setStroke(30);
canvas.drawLine(xposition, 230, xposition, sun);
canvas.paint();

1 个答案:

答案 0 :(得分:1)

除非您将此javascript条形图绘图仪编写为练习,否则我会使用jqplot