Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dataset conversion with Chart2D  RSS feed

Steve Angello
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!