gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 05:48:16 24 4
gpt4 key购买 nike

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

最佳答案

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

关于javascript - 如何使用 javascript 创建一个简单的条形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16473521/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com