Trying to get number values to show

Hello Again! i have pushed my basic design to this point. My next question is trying to make the data values show up when the mouse has hovered over the rectangles.
I attached a screenshot of the code working.

Table table;

void setup() {
  size(1200, 900);
  table = loadTable("Hopwood_Visualizing data_ Copy of ign_contesters.tsv", "header");
  println(table.getString(1, 0));
  println(table.getFloat(1, 1));
  textAlign(LEFT, CENTER);
  // println(table.getColumnCount());
  //println(table.getRowCount());
}

void draw() {
  background(255);
  fill(0);
  for (int d=0; d< table.getRowCount(); d++) {

    
    rectMode(CORNER);
    fill(0);
    text(table.getString(d, 0), 100, 25+ d*25);
    fill(0, 320, 612);
    text("Critic Score", 340, 20);
    fill(0, 320, 612);
    text("User Score", 425, 20);
    fill(2, 320, 612);
    text("Total Sold in Millions", 630, 20);


    fill(226, 120, 50, 50);
    rect(425, 25+ d*25, sqrt(table.getFloat(d, 1))*12, sqrt(table.getFloat(d, 1))*6);
    fill(220, 100, 50, 50);
    rect(340, 25+ d*25, sqrt(table.getFloat(d, 2))*18, sqrt(table.getFloat(d, 2))*6);
    fill(120, 200, 50, 50);
    rect(630, 25+ d*25, sqrt(table.getFloat(d, 3))*18, sqrt(table.getFloat(d, 3))*6);
  }
}

First you are changing the y height; bad.

I think that you only should change the width of the bars

Then check for all bars whether mouse is inside

Do this where you draw them

If inside display text()

1 Like