We are about to switch to a new forum software. Until then we have removed the registration on this forum.
This is my first processing question for my first processing project, so sorry everybody for my ignorance of the software and of the forum rules, I'll be deeply thankful if anyone will be so kind to answer!
My problem is the following one: I would like to do a bar chart representing my 100 favorite songs (according to iTunes reproductions!), where you can change the table.sort, the disposition of the song in genre, artist, n° of reproduction, etc... with some buttons to do it. I've tried to do something with cp5 button, but the main problem is that if i maintain noLoop() the graph don't change, but if I take it away the graph goes crazy. I report down here the code and the CSV table!
Help me please, free hugs and the give of my final project if you do!
CODE:
import controlP5.*;
ControlP5 cp5;
Table table;
int c;
PFont font;
boolean Bottone = false;
void setup() {
//size(800, 600);
fullScreen();
background(255);
smooth();
table = loadTable("My Music Numbers_first 100.csv", "header");
font = createFont("Chivo-Regular-13.vlw", 13);//aggiunta la font
cp5= new ControlP5(this);
cp5.addToggle("Bottone")
.setPosition(20,180)
.setSize(90,15)
;
}
void draw() {
//questa linea e la successiva per invertire l'asse delle y
/*scale(1, -1);
translate(0, -height);*/
font = createFont("CircularStd-Bold", 40);
textFont(font);
textSize(32);
fill(#B0F566);
textAlign(CENTER);
text("My Favourite Tracks",(width/2),100);
textSize(18);
fill(#83B45B);
text("A data—visualization of the 100 songs that I love most",(width/2),150);
for (int i = 0; i<table.getRowCount(); i++) {
// Access each row of the table one at a time, in a loop.
TableRow riga = table.getRow(i);
int posizione = riga.getInt("posizione");
String n = riga.getString("artista");
String titolo = riga.getString("titolo");
int score = riga.getInt("riproduzioni");
int durata = riga.getInt("durata");
String album = riga.getString("album");
int anno = riga.getInt("anno");
String genere = riga.getString("genere");
String nazione = riga.getString("nazione");
int x = 200+(i*10);
int y = height/2;
table.sort("riproduzioni");
if (genere.equals("Alternativa/Indie") == true) {
c = #B0F566;
}
if (genere.equals("Reggae") == true) {
c = #4AF2A1;
}
if (genere.equals("Pop") == true) {
c = #5CC9F5;
}
if (genere.equals("Rock") == true) {
c = #6638F0;
}
if (genere.equals("Hip Hop") == true) {
c = #E8235E;
}
if (genere.equals("Rap") == true) {
c = #FF1A1A;
}
if (genere.equals("Ska") == true) {
c = #1EF7D1;
}
if (genere.equals("Dance Elettronica") == true) {
c = #FFF41A;
}
if (genere.equals("Neofolk") == true) {
c = #10FF00;
}
if (genere.equals("Soul") == true) {
c = #2420C4;
}
if (genere.equals("Punk") == true) {
c = #CB7777;
}
if (Bottone == true) {
table.sort("genere");
} else {
table.sort("riproduzioni");
}
fill(c);
rectMode(CENTER);
noStroke();
rect(x, y, 10, score*4,7);
//noLoop();
println(titolo + " " + score);
}
}
CSV (named "My Music Numbers_first 100.csv"):
posizione,artista,titolo,riproduzioni,durata,album,anno,genere,nazione 001,The Vaccines,All in White,112,04:34,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 002,The Vaccines,Norgaard,079,01:38,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 003,Alt-J,Dissolve Me,065,04:00,An Awesome Wave,2012,Alternativa/Indie,Inghilterra 004,Bon Iver,Skinny Love,063,03:58,For Emma| Forever Ago,2007,Alternativa/Indie,USA 005,Alt-J,Breezeblocks,058,03:47,An Awesome Wave,2012,Alternativa/Indie,Inghilterra 006,The Vaccines,Wetsuit,053,03:50,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 007,Bob Marley & The Wailers,Stir It Up,048,03:41,Catch a Fire,1973,Reggae,Inghilterra 008,The Libertines,Don't Look Back Into The Sun,048,03:21,The Libertines,2004,Alternativa/Indie,Inghilterra 009,Tame Impala,Feels Like We Only Go Backwards,047,03:13,Lonerism,2012,Alternativa/Indie,Australia 010,The Vaccines,A Lack Of Understanding,044,02:59,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 011,Babyshambles,Maybeline,041,03:16,Sequel to the Prequel,2013,Alternativa/Indie,Inghilterra 012,Gazebo Penguins,Difetto,041,02:23,Raudo,2013,Alternativa/Indie,Italia 013,Alt-J,Matilda,041,03:48,An Awesome Wave,2012,Alternativa/Indie,Inghilterra 014,King Harvest,Dancing in the Moonlight,040,02:52,Dancing in the Moonlight,1973,Pop,USA 015,Gazebo Penguins,Finito il cafe,039,03:05,Raudo,2013,Alternativa/Indie,Italia 016,Alt-J,Something Good,038,03:42,An Awesome Wave,2012,Alternativa/Indie,Inghilterra 017,Egg,Shoe,038,03:45,Shoe EP,2009,Rock,Inghilterra 018,The Vaccines,Blow It Up,037,02:36,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 019,I Cani,Corso Trieste,034,03:28,Glamour,2013,Pop,Italia 020,I Cani,Post Punk,034,04:46,Il sorprendente album d'esordio de i cani,2011,Pop,Italia 021,The Vaccines,Under Your Thumb,034,02:20,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 022,Chiddy Bang,By Your Side,034,03:48,inedito,2012,Hip Hop,USA 023,Gazebo Penguins,Casa dei Miei,033,02:28,Raudo,2013,Alternativa/Indie,Italia 024,I Cani,Hipsteria,033,03:39,Il sorprendente album d'esordio de i cani,2011,Pop,Italia 025,U2,California (There Is No End to Love),033,04:00,Songs of Innocence,2014,Rock,Irlanda 026,Gazebo Penguins,Domani e' gennaio,032,02:57,Raudo,2013,Alternativa/Indie,Italia 027,Babyshambles,Fireman,031,01:42,Sequel to the Prequel,2013,Alternativa/Indie,Inghilterra 028,Babyshambles,Nothing Comes to Nothing,030,03:15,Sequel to the Prequel,2013,Alternativa/Indie,Inghilterra 029,Gazebo Penguins,Correggio,030,02:00,Raudo,2013,Alternativa/Indie,Italia 030,I Cani,Le coppie,030,03:09,Il sorprendente album d'esordio de i cani,2011,Pop,Italia 031,I Cani,Il pranzo di santo stefano,030,02:09,Il sorprendente album d'esordio de i cani,2011,Pop,Italia 032,The Vaccines,Post Break-Up Sex,030,02:54,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 033,Babyshambles,Farmer's Daughter,028,05:05,Sequel to the Prequel,2013,Alternativa/Indie,Inghilterra 034,Gazebo Penguins,Ogni scelta e' in perdita,028,03:23,Raudo,2013,Alternativa/Indie,Italia 035,I Cani,Velleita',028,04:47,Il sorprendente album d'esordio de i cani,2011,Pop,Italia 036,Mecna,Cerotti,028,02:52,inedito,2012,Rap,Italia 037,Mighty Oaks,Brother,028,03:16,Brother,2012,Alternativa/Indie,Germania 038,The Vaccines,Tiger Blood,028,02:08,Come Of Age,2012,Alternativa/Indie,Inghilterra 039,Mecna,31/07,027,03:16,Bagagli a mano,2011,Rap,Italia 040,Paolo Nutini,10/10,027,02:57,Sunny Side Up,2009,Ska,Inghilterra 041,The Vaccines,If You Wanna,027,02:54,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 042,U2,The Miracle (Of Joey Ramone),027,04:15,Songs of Innocence,2014,Rock,Irlanda 043,Big Sean,Too Fake,027,04:12,Finally Famous Vol. 3: Big,2010,Hip Hop,USA 044,Flume,Holdin On,027,02:35,Flume,2012,Dance Elettronica,Australia 045,Deluxe,Pony,027,03:29,Polishing Peanuts,2011,Dance Elettronica,Francia 046,Bob Marley & The Wailers,One Love,026,02:53,Exodus,1977,Reggae,Giamaica 047,Drowners,Ways to Phrase a Rejection,026,01:46,Drowners,2014,Alternativa/Indie,USA 048,The Vaccines,Wreckin' Bar (Ra Ra Ra),026,01:22,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 049,The Hives,Hate To Say I Told You So,026,03:20,Veni Vidi Vicious,2000,Alternativa/Indie,Svezia 050,Bon Iver,Holocene,025,05:36,Bon Iver| Bon Iver,2011,Alternativa/Indie,USA 051,I Cani,FBYC (Sfortuna),025,03:35,Glamour,2013,Pop,Italia 052,The Libertines,Music When The Lights Go Out,025,03:02,The Libertines,2004,Alternativa/Indie,Inghilterra 053,The Vaccines,Teenage Icon,025,03:05,Come Of Age,2012,Alternativa/Indie,Inghilterra 054,Cee Lo Green,Fuck You,025,03:54,The Lady Killer,2010,Pop,USA 055,Oscar Isaac,Hang Me| Oh Hang Me,025,03:23,Inside Llewyn Davis,2013,Neofolk,USA 056,The Tallest Man on Earth,Love is all,025,04:17,The Wild Hunt,2010,Neofolk,Svezia 057,The Vaccines,If You Wanna,025,02:54,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 058,Bob Marley & The Wailers,No Woman No Cry,024,07:12,Natty Dread,1975,Reggae,Giamaica 059,Bob Marley & The Wailers,Three Little Birds,024,03:02,Exodus,1980,Reggae,Giamaica 060,Drowners,Luv| Hold Me Down,024,02:51,Drowners,2014,Alternativa/Indie,USA 061,Gazebo Penguins,Non moriro',024,02:53,Raudo,2013,Alternativa/Indie,Italia 062,The Tallest Man on Earth ,Thousand Ways,024,02:53,The Wild Hunt,2010,Neofolk,Svezia 063,The Vaccines,No Hope,024,04:10,Come Of Age,2012,Alternativa/Indie,Inghilterra 064,The Vaccines,Wolf Pack,024,02:24,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra 065,Justice,D.A.N.C.E. ,024,04:03,Cross,2007,Dance Elettronica,Francia 066,Arctic Monkeys,Mardy Bum,023,02:55,Whatever People Say I Am| That's What I'm Not,2006,Alternativa/Indie,Inghilterra 067,Babyshambles,New Pair,023,03:06,Sequel to the Prequel,2013,Alternativa/Indie,Australia 068,Mumford & Sons,Below My Feet,023,05:00,Babel,2012,Neofolk,Inghilterra 069,Otis Redding ,Respect,023,02:10,Otis Blue: Otis Redding Sings Soul,1965,Soul,USA 070,Grouplove,Itchin' On A Photograph,023,04:23,Never Trust a Happy Song,2011,Rock,USA 071,Ingrid Michaelson,You And I,023,02:36,Girls and Boys,2006,Alternativa/Indie,USA 072,Bob Marley & The Wailers,Get Up Stand Up,022,03:20,Burnin',1973,Reggae,Giamaica 073,Drowners,Long Hair,022,01:49,Drowners,2014,Alternativa/Indie,USA 074,I Cani,Non c'e' niente di twee,022,04:04,Glamour,2013,Pop,Italia 075,I Cani,Storia di un impiegato,022,03:53,Glamour,2013,Pop,Italia 076,I Cani,I pariolini di diciott'anni,022,03:46,Il sorprendente album d'esordio de i cani,2011,Pop,Italia 077,Mumford & Sons,The Cave,022,03:38,Sigh No More,2009,Neofolk,Inghilterra 078,The Tallest Man on Earth,Thrown Right at Me,022,02:59,Sometimes the Blues Is Just a Passing Bird,2010,Neofolk,Svezia 079,U2,Every Breaking Wave,022,04:12,Songs of Innocence,2014,Rock,Irlanda 080,Rancid,Ruby Soho,022,02:52,...And Out Come the Wolves,1995,Punk,USA 081,Sam Smith,Stay With Me,022,02:55,In the Lonely Hour,2014,Soul,Inghilterra 082,The Killers,Mr. Brightside,022,03:47,Hot Fuss,2004,Alternativa/Indie,USA 083,Bob Marley & The Wailers,I Shot The Sheriff,021,03:54,Burnin',1973,Reggae,Giamaica 084,Chance The Rapper,Cocoa Butter Kisses ,021,05:07,Acid Rap,2013,Rap,USA 085,Coez,Lontana da me,021,03:43,Non erano fiori,2013,Pop,Italia 086,I Cani,Door Selection,021,02:40,Il sorprendente album d'esordio de i cani,2011,Pop,Italia 087,I Cani,Perdona e dimentica,021,03:37,Il sorprendente album d'esordio de i cani,2011,Pop,Italia 088,Mumford & Sons,Sigh No More,021,03:28,Sigh No More,2009,Neofolk,Inghilterra 089,The Black Keys,Lonely Boy,021,03:13,El Camino,2011,Alternativa/Indie,USA 090,The Libertines,What Katie Did,021,03:50,The Libertines,2004,Alternativa/Indie,Inghilterra 091,The Vaccines,I Wish I Was A Girl,021,02:52,Come Of Age,2012,Alternativa/Indie,Inghilterra 092,The Vaccines,Bad Mood,021,03:14,Come Of Age,2012,Alternativa/Indie,Inghilterra 093,Bob Marley & The Wailers,Jamming,020,03:35,Exodus,1977,Reggae,Giamaica 094,Bon Iver ,Beth/Rest,020,06:26,Bon Iver|Bon Iver,2011,Alternativa/Indie,USA 095,Bon Iver,Minnesota|WI,020,03:32,Bon Iver|Bon Iver,2011,Alternativa/Indie,USA 096,Gazebo Penguins,Mio Nonno,020,01:47,Raudo,2013,Alternativa/Indie,Italia 097,I Cani,Come vera nabokov,020,04:03,Glamour,2013,Pop,Italia 098,Mumford & Sons,Roll Away Your Stone,020,04:24,Sigh No More,2009,Neofolk,Inghilterra 099,The Black Keys,Little Black Submarines,020,04:11,El Camino,2011,Alternativa/Indie,USA 100,The Cure,Just Like Heaven,020,3:30,Kiss Me Kiss Me Kiss Me,1987,Alternativa/Inside,Inghilterra