We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I was trying to create a small diagram based on the data from a csv file. I created a two columns of data where the first column displays name of few drinks and objects, and the second column displays their color. I wanted to create a diagram as i drew in the concept sketch shown below.
Concept image
image showing the content inside the csv file
I was able to count and list down the repeating members in both the columns. But I am not able to create the connecting lines.
the code so far is as follows
String tag = "dataset.csv";
String []rawData;
IntDict drinks;
IntDict colors;
void setup() {
size(600, 600);
drinks = new IntDict();
colors = new IntDict();
rawData = loadStrings(tag);
for (int i =0; i<rawData.length; i++) {
String [] thisRow = split(rawData[i], ",");
// drinks.increment(thisRow[1]);
drinks.increment(thisRow[0]);
colors.increment(thisRow[1]);
}
println(drinks);
println(colors);
String [] drinkName = drinks.keyArray();
int [] drinkNo = drinks.valueArray();
String [] colorName = colors.keyArray();
int [] colorNo = colors.valueArray();
for (int i = 0; i<drinkName.length; i++) {
fill(0);
textSize(15);
text(drinkName[i]+":"+drinkNo[i], 100, 100+30*i);
line(100, 100+30*i, 300, 100+30*i);
}
for (int i = 0; i<colorName.length; i++) {
fill(0);
textSize(15);
text(colorName[i]+":"+colorNo[i], 300, 100+30*i);
}
}
It would be great if someone can help me with this.
Many thanks in advance:)
Yousuf
Answers
http://StackOverflow.com/questions/33160079/creating-a-rank-list-by-sorting-an-array
http://StackOverflow.com/questions/33200984/drawing-a-cross-chart-visualization-using-processing
@GoToLoop thank you for suggesting me to read hashmap and stringlist. i shall start with that. i must say ur previous suggestion to read about indDict was really helpful. :)
l posted the same questions in stackoverflow also to learn more and find answers :)
@GoToLoop thank you for the reply :)
I now have to study this as usual :)