Data Help, Processing

edited January 2016 in Questions about Code

Pretty much what I have to do is get the data from the drones.csv file and plug it into processing and make something visual that accurately depicts the data in the different sections. So what I've done is create a green line that displays the years and have the rest of the information go along that line. Can you take a look at it maybe try adding something or just look it over see if it makes sense to you It would be greatly appreciated.

I pretty much just used the MAP tool in order to display the data. Although, Its not visually appealing I feel like more can be done I just don't know what or how to add to it, I've tried several different things that ended up in failure.

If you copy/paste this code into processing you wont be able to run it Unless you the CSV folder into the code because it contains all the data points.. I'm not sure how to attach the CSV file to this post though I kept getting all sorts of errors, so I decided to upload the code on dropbox, if u quickly get the code and plug it into the sketch you can see it all run,

and, Here's the Code

void setup() {
size(640, 400, P3D);   


void draw() {

   Table data = loadTable("drones.csv", "header,csv"); // Header Section, - Date, DEcimal_date - Min_killed - max-killed - civilin- children - iNJURED

  //translate(width/2, height/2);  // center the Image

  for (TableRow row : data.rows() ) {

    float injured = row.getFloat("injured");
    injured = int(injured);

     float civilian = row.getFloat("civilian");
    civilian = int(civilian);

    float children = row.getFloat("children");
    children = int(children);

  //  float date = row.getFloat("date"); 
    float decimal_date = row.getFloat("decimal_date"); // Decimal date is a Float because it has a decimal point
     decimal_date = (decimal_date);

   // float min_killed = row.getFloat("min_killed");
    float max_kiled = row.getFloat("max_kiled");
    //min_killed = radians(min_killed);
    max_kiled = (max_kiled);


 float x1 = map(decimal_date, 2004, 2012, 0, width);   //float x1 = map(decimal_date, 2004, 2012, 0, width);   float x1 = map(decimal_date, 0, 2004, 0, 2012)
   stroke(0,255,0); // Green will represent the Years
   point(x1, 100);

   float r = 140; //radius
   float x2  =  map(max_kiled, 2, 84, 0, width);   // gets first value, targets value, high low for both, and sets out displayment.. Maps the 4 functions in the order I applied earlier
   stroke(255,0,0); // red will Represent the deaths

   float children1  =  map(children, 0, 69, 0, width);
   stroke(255,255,255); // White

   float injured1  =  map(injured, 0, 50, 0, width);
   stroke(0,0,255); // blue

   float civilian1  =  map(civilian, 0, 81, 0, width);
   stroke(250,128,114); //Orange


  // Change height of the camera with mouseY
  camera(30.0, mouseY, 220.0, // eyeX, eyeY, eyeZ
         0.0, 0.0, 0.0, // centerX, centerY, centerZ
         0.0, 1.0, 0.0); // upX, upY, upZ




  • Some generic remarks:

    • Why use P3D mode when you draw only in 2D?
    • Move the loading of your CSV file to setup! No need to read it 60 times per second...
Sign In or Register to comment.