【发布时间】:2011-05-14 03:23:07
【问题描述】:
我正在使用 XML 中的值在处理过程中创建一个简单的条形图。数据是 28 年 9 座山脉的冰川质量平衡。我正在尝试用这个实现一个 jquery 滑块(我可以将它发布到 processing.js ......我只是不知道从那里去哪里)。为了能够查看我的所有数据,我现在只是一次显示所有 28 年。
使用 jquery 滑块,我希望能够在 1980 年到 2007 年之间滑动,并仅显示其中一年的条形图。我是否需要彻底更改我的处理代码才能完成这项工作?我发现的很多例子都没有广泛使用数组,处理草图更简单。 (我对此很陌生,所以请忍受我的业余问题)。任何提示/指针表示赞赏。
float[] yearA = new float[28];
String[] mountA = new String[9];
float[] massA = new float[9];
float[] recth = new float[9];
float rectw;
int rectx = 10;
int recty = 20;
float rectht;
void setup()
{
size(500,800);
}
void draw()
{
XMLElement years = new XMLElement(this, "glacier2.xml");
println(years.getChildCount());
int nResults = years.getChildCount();
int x=40;
int y=40;
background(255);
fill(0);
for(int j=0; j<28; j++) {
XMLElement yearN = years.getChild(j);
String yearn = yearN.getAttribute("id");
float yearnf = float(yearn);
yearA[j] = yearnf;
println(yearA[j]);
for(int i=0; i<9; i++) {
XMLElement mountains = yearN.getChild(i);
String mountain = mountains.getAttribute("id");
String massbalance = mountains.getAttribute("massbalance");
float massf = float(massbalance);
mountA[i] = mountain;
massA[i] = massf;
rectht = map(massf, -4260, 3700, 10, 750);
recth[i]=rectht;
rectw = floor(width/10);
rect(rectx, recty, rectw, recth[i]);
rectx+=(rectw+10);
text(massf, rectx, recty+rectht);
println(massf);
}
rectx=10;
}
}
【问题讨论】:
标签: jquery slider processing.js