Javafx ("DataViz")

All the posts i show here in javafx  are my learning process in javafx. Since i started building data viz projects have learned a lot about javafx and yet to learn a lot more and loving it.
As i have observed as the data gets bigger the more am shifting to using Streams(Java 8) as compared to Collections.
2006 and 2010 counties grade frequency

That said another javafx dataviz project,the data here.

Streams really make it simple to query data as compared to Collections,with the data i wanted to find the summation of a grade frequency for each county in Kenya for years 2006 and 2010 and from schools that are in 2006 and 2010 for better comparison.

My query

for(county loop){
     String county_name=county;

     for(grade loop){
         for(year loop){

             Optional<Integer> sum= list.stream()
                 .filter(s->s.split(",")[0].equals(year) && s.split(",")  [3].equalsIgnoreCase(county_name)                       && s.split(",")[8].equals(grade))
                 .map(s->s.split(",")[10])
                 .map(s->Integer.valueOf(s))
                 .reduce(Integer::sum);
}
}
}
Drawing the circles is really simple, below is an example of how i did it.
example

   AnchorPane root = new AnchorPane();

     Rectangle rect=new Rectangle(10,10);
      rect.setLayoutX(150);
      rect.setLayoutY(30);
      rect.setId("Baringo");

      Text grade=new Text("A");
      grade.setLayoutX(30);
      grade.setLayoutY(100);
      grade.setId("A");
     
      root.getChildren().addAll(rect,grade);
     
      Node x_axis_node=root.lookup("#Baringo");
      Node y_axis_node=root.lookup("#A");
     
      Circle circle=new Circle(5);
      circle.setFill(Color.RED);
      circle.setLayoutX(x_axis_node.getLayoutX()+5);
      circle.setLayoutY(y_axis_node.getLayoutY()-5);

       root.getChildren().add(c);
example
I had to create another file that contains only year 2006 and 2010 ,cause the original data takes about 10 minutes to complete it has 273,867 records.
The radius of the circle is the sum total of a grade frequency the largest circle with a radius of 20 and a grade frequency of 3308.
Producing 2006 performance in a separate image with 2010 it was had to see the difference like ...


Okay,i thought of calculating the difference but most of the values were really small for visualization,the last attempt was to draw the circles in one image with different strokes and transparent fill,and this is it
2006 and 2010 counties grade frequency

Comments

Popular Posts