Javafx Shapes 2 ("DataViz")

Well another post about javafx,although this isn't what i had in mind as a project i think it came out pretty. It doesn't show much but you can tell at glance whats happening.I guess the visualization is as good as the data,still new to this idea of data as art but loving it a lot.

Actual Arrivals
As per usual data from kenyaOpendata,the challenge with this particular project was the data ,the visualization was a combination from previous projects.

The Data

By challenge i mean it made me see the advantages of Streams (java 8),i will just show an example of the query i used to calculate the sum of the year quarters,

                        .filter(word->word.contains("1991") && word.contains("Departures") &&          word.contains("Actual"))
                        .map(word->word.split(",")[3]) //column 3 Visitors on Holiday

calculate the width of the CubicCurve


 double d=Math.sqrt(Math.pow(MAX_WIDTH,2) * sum.orElse(0.0) / MAX_VAL);

  NB: sum.orElse(0.0) its important to use this and not sum.get(),some years return "No value  present" cause no actual data present. 2004,1999,2009.

The Visuals

Drawing the circle i just used a method in a previous post,every label is given an year ID "label.setId("1991").
The CubicCurve ControlX1,ControlX2,ControlY1,ControlY2 are at the center of the circle ,the startX,startY on MouseClicked gets Node(Circle) LayoutX and LayoutY and the endX,endY i use the lookup method.

Node n=root.lookup("#"+year);//looking for a label with id year


The angle i decided to add Circles instead of labels were 12 and 348,and skipping angle 0 and 336 for spacing,the two circles have ids visitor_on_holiday and visitor_on_business ,using the lookup method you can easily find any Node in the AnchorPane.

Not too much coding  cause i feel nothing new here apart from the neat Stream query above,the rest are somewhere in my previous posts.

The Results
Actual Departure On Transit
and Others
Actual Departure

Preliminary Departure Holiday
Preliminary Departure Business


Popular Posts