Thejesh GN avatar Thejesh GN committed 20ea093

bubble graph

Comments (0)

Files changed (2)

Add a comment to this file

processing/bubble_bar_graph/1.gif

Added
New image

processing/bubble_bar_graph/bubble_bar_graph.pde

+
+
+void setup(){
+  size(1200, 1500);
+  smooth();
+  
+    //how many years
+  int ROWS = 50;
+  int HEIGHT_OF_ROW = 25;
+  int NO_OF_DAYS = 31;
+  int BEFORE_AFTER = 31/2;
+  int CENTER_DATE =  BEFORE_AFTER+1;
+  color background_color = #FDE1CB;
+  color horizontal_line_color =  #81836D;
+  int top_margin =100;
+  int left_margin =100;
+  //int[year][date]
+  int[][] numbers = new int[ROWS][NO_OF_DAYS];
+  background(background_color);
+  stroke(129,131,109); 
+  line(500, top_margin+(ROWS*HEIGHT_OF_ROW), 500, 90);
+  
+  int second_verticle_line_x = 1050;
+  line(second_verticle_line_x, top_margin+(ROWS*HEIGHT_OF_ROW), second_verticle_line_x, 90);
+  fill(129,131,109);
+  //header text
+  text("Year", 50, top_margin-20); 
+  text("Deepavali Festival", 450, top_margin-20); 
+  text("Before/on", second_verticle_line_x-80, top_margin-20);
+  text("After", second_verticle_line_x+20, top_margin-20);
+  int year_start = 1960;
+  
+  for(int i =1; i <=  ROWS; i++){
+    //draw year line
+    stroke(129,131,109); 
+    line(10, top_margin+(HEIGHT_OF_ROW*i), 900, top_margin+(HEIGHT_OF_ROW*i));
+    fill(129,131,109);
+    text(year_start, 50, top_margin+(HEIGHT_OF_ROW*i)+12);
+    year_start = year_start + 1;
+      for(int j = 1; j < 31; j++){
+        noFill();
+        smooth();
+        noStroke();
+        //as of now its random, but we will have to consider the
+        //actual value. This is density of the circle  
+        int intensity_of_circle = int(random(2, 10)*25);
+        fill(171,195,182,intensity_of_circle);
+        //as of now its random. between 1 and 20. 
+        //But we have to consider the actual value
+        //this is size of the circle
+        int size_of_circle = int(random(5, 20));
+        ellipse(top_margin+(j*25), top_margin+(HEIGHT_OF_ROW*i), size_of_circle, size_of_circle);
+      }
+      
+      //TODO: Bar graph is total rainfall before and after
+      int before_on_total_rainfall = int(random(5, 10)*10);
+      int after_total_rainfall = int(random(5, 10)*10);
+      int bargraph_intensity_before = int(random(1, 5)*43);
+      int bargraph_intensity_after = int(random(1, 5)*43);
+      //center, point for the rect is on the vericle line and horizontal line intersect
+      int bargraph_center_x = second_verticle_line_x;
+      int bargraph_center_y = top_margin+(HEIGHT_OF_ROW*i);
+      //before rectagle 
+      //TODO: this calculation needs to happen
+      int length_of_rect_before = before_on_total_rainfall;            
+      fill(129,131,109,bargraph_intensity_before);     
+      rect(bargraph_center_x-length_of_rect_before, bargraph_center_y-10, length_of_rect_before, 20);
+      fill(129,131,109);
+      text("("+before_on_total_rainfall+")", bargraph_center_x-length_of_rect_before-40, bargraph_center_y);
+
+      //after rectagle      
+      //TODO: this calculation needs to happen
+      int length_of_rect_after = after_total_rainfall;      
+      fill(129,131,109,bargraph_intensity_after);
+      rect(bargraph_center_x, bargraph_center_y-10, length_of_rect_after, 20);
+      fill(129,131,109);
+      text("("+after_total_rainfall+")", bargraph_center_x+length_of_rect_after+10, bargraph_center_y);
+      
+      
+  }
+save("1.gif");
+}
+  
+  
+void draw()
+{  
+
+}  
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.