3

I want to create a legends for a bar chart, which looks like:

 |  |  |  |
/  /  /  /

where | : data column, / : is a legend for each column

I couldn't get the text legend right, try multiple maxtrix transformation, but none works correctly.

for (int col = 0; col < 4; col++) {
                       // Draw emotions legends
                applet.fill(100);
                applet.textFont(font, 20);

                // perform matrix transform
                applet.rotate(-0.75f);
                applet.translate(col * columnW, h);

                // draw text
                applet.text(legends[col], 0, 0);

                // undo matrix
                applet.translate(-col * columnW, -h);
                applet.rotate(0.75f);
}

Please help :(

vulh
  • 41
  • 3

1 Answers1

1

For those who want to know the answer:

for (int col = 0; col < 4; col++) {
                applet.pushMatrix();
                applet.translate(col * blockW, h);
                // Rotate the text
                applet.rotate(-0.75f);

                // Display the text
                applet.text(Emotion.values()[col].toString(), 0, 0);
                applet.popMatrix();
}
vulh
  • 41
  • 3