Drawing a cross chart visualization

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 Concept image

csv file 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

Sign In or Register to comment.