用户将输入图表的数据。我使用了拉线,但我无法找到正确的位置。到目前为止,这是我的代码。由于 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();