We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › help w/event triggered loading of data
Page Index Toggle Pages: 1
help w/event triggered loading of data (Read 228 times)
help w/event triggered loading of data
Sep 28th, 2008, 11:59pm
 
hi

i am wondering which route to take to achieve a program whereby upon clicking on a button, a graph or some other visualization is loaded with a different dataset. I can see it happening a couple of different ways, and I'm wondering which is the right one. some of the options I considered:
i. have all the datasets loaded at runtime and then switch visibility states....
ii. have different load data functions for each dataset, each one being triggered by its own respective button
iii. (most ideal) a single array, a single set of functions, and a button which says to fill an existing array with a new set of data...

which one should I go with? any advice? I have been working with Ben Fry's Visualizing Data book and I don't see anything that does what I'm after...If you need an example to imagine what I'm talking about you could take the chapter 4 time series one and imagine that instead of a single file feeding separate tabs (coffee, milk, tea) just by advancing the current column, this is done by switching between TSV files...

thanks!
gabe
Re: help w/event triggered loading of data
Reply #1 - Sep 29th, 2008, 1:11am
 
It depends on the data and how you're using it. From what you've described, the best option would be to create an array of Table objects, and to load the separate files as entries in the array. For instance, something like this:

Code:
Table[] tables;
String[] filenames = { "one.tsv", "something.tsv", "blah.tsv" };

void setup() {
size(400, 400);

tables = new Table[filenames.length];
for (int i = 0; i < tables.length; i++) {
tables[i] = new Table(this, filenames[i]);
}
}


Then have another Table object that simply points to the current Table whose data is being displayed. Or store an index to the current Table that's in use, which will make it easier to switch between data sets using tabs (since the tab index can the same as the array index, and so on).
Page Index Toggle Pages: 1