Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes Dataset conversion with Chart2D Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Dataset conversion with Chart2D" Watch "Dataset conversion with Chart2D" New topic

Dataset conversion with Chart2D

Steve Angello

Joined: Mar 11, 2006
Posts: 1
I'm currently building a GUI that needs to load a datafile and display the data (one x, y value per line) into a chart2D object. Problem is Chart2D uses it's own Datasets, and I can't figure out how to make it use the array data read in from the file.

The Datasets used are in the form (sets, categories, items), which translates to 1 set (1 line), 2 cats (x, y and the items need to be read from the file.... :-s

The code which configures the Dataset is

//Configure dataset
Random random = new Random();
Dataset dataset = new Dataset (2, 2, 14);
for (int i = 0; i < dataset.getNumSets(); ++i)
for (int j = 0; j < dataset.getNumCats(); ++j)
for (int k = 0; k < dataset.getNumItems(); ++k)

{int increaseMetric = dataset.getNumSets() - i - 1;
dataset.set (i, j, k,
(increaseMetric + 1) * random.nextInt (5) + (increaseMetric + 30) * 5 + j * 1);

The file reader output looks like this:

public void readFile() {
// Disable read button

// Dimension data structure
data = new String[numLines];

// Read file

// Output to text area
textArea.setText(data[0] + "\n");
for(int index=1; index < data.length;index++)
textArea.append(data[index] + "\n");

// Rnable open button

I've tried going (i, j, data[k](
but it's not right and shows how poor my java skills are..... I have a feeling I'll have to modify but that might mess other Chart2D parts up but does anyone possibly have a way round it?

Any help with this will be very much appreciated...

Chart2Ds site is

I agree. Here's the link:
subject: Dataset conversion with Chart2D
jQuery in Action, 3rd edition