Skip to content

Instantly share code, notes, and snippets.

@ASRagab
Created July 6, 2013 04:54
Show Gist options
  • Save ASRagab/5938686 to your computer and use it in GitHub Desktop.
Save ASRagab/5938686 to your computer and use it in GitHub Desktop.
Processing Gist which draws a Bubble Chart..manually or as manually as one gets in Processing
Company[] companies;
PFont font;
void setup()
{
String[] company = loadStrings("Testdata.csv");
size(800,800);
background(255);
noStroke();
smooth();
font = loadFont("BrowalliaNew-18.vlw");
textFont(font);
println(company.length);
for(int i=0; i<company.length; i++)
{
String[] temp = split(company[i], ',');
for(int j=0; j<temp.length; j++)
{
companies[j] = new Company(temp[j], Integer.parseInt(temp[j+1]), Integer.parseInt(temp[j+2]), Integer.parseInt(temp[j+3]), Integer.parseInt(temp[j+4]));
}
}
}
void draw(){
stroke(255);
fill(0,0,255);
textAlign(CENTER);
text("4 Category Visualization of Test Company Data", width/2, 10);
line(25,25,25,725);
text("Data Security", 5, height/2);
line(25,725, 725,725);
text("Project Complexity", width/2, 740);
for(int i=0; i<companies.length; i++){
companies[i].drawCompany();
}
}
class Company{
String name;
int resources;
int security;
int complexity;
int flexibility;
Company(String _name, int _resources, int _security, int _complexity, int _flexibility)
{
name = _name;
resources = _resources;
security = _security;
complexity = _complexity;
flexibility = _flexibility;
}
public void drawCompany()
{
ellipseMode(CENTER);
fill(0,flexibility*50,0);
ellipse(150+(125*complexity), 800-(150+125*security), 25*resources, 25*resources);
fill(0);
text(name, 150+(125*complexity), 800-(150+125*security));
}
}
@Betul06
Copy link

Betul06 commented May 16, 2019

Could you provide the csv file please?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment