I dig into more about Dewey class 741.59 which is geographically classified code. The classification had not fixed, and simultaneulsy changed by librarians. Interestingly, Japan has the biggest number of volumes in cartoon section, even if the library located in the Seattle, there were some period that total checkout of Japanese mange were more than American's.
In some countries, famous artist take some categories, such as Hernandez_Jaime_Dean_Koontz_Graphic_Novel (741.59573),Palmiotti_Jimmy (741.5953) ,also, there is a section only for the "Seattle_publisher" (741.59797).
I used the MySQL result between 2006 to 2013 by every month, then arranged these numbers in the graph. The color stands for total checkout number, but the gap between two major cartoon countries Japan, US are far more than any other countries, the color variation lost its meaning. Instead, I put a number slide which shows number of actual check out by elevation.
Code: Select all
/**
* ControlP5 with PeasyCam support. tested with peasy 0.8.2
*
* by jeffg 2011
*/
//created by Mohit Hingorani for MAT259 Winter 2015
//edited by Intae Hwang for MAT259 W 2015 homework4
/*
A simple 3D demo to introduce the concepts of 3D graphics in processing
Introducing only peasycam
/**
* ControlP5 Controller on top of 3D
* demonstrates how to use controlP5 controllers on top of a
* OpenGL 3D scene.
* by Andreas Schlegel, 2011
* www.sojamo.de/libraries/controlP5
http://www.sojamo.de/libraries/controlP5/examples/extra/ControlP5withPeasyCam/ControlP5withPeasyCam.pde
press n , l , t for nubers, lines and text repectively
*/
import peasy.test.*;
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
import controlP5.*;
import igeo.*;
PeasyCam cam;
ControlP5 cp5;
int buttonValue = 1;
// setting up fonts for text
PFont myHelvetica12 = createFont("Helvetica",12, true);
PFont myHelvetica20 = createFont("Helvetica",20, true);
PFont myHelvetica48 = createFont("Helvetica",48, true);
//to store the data table
int [][] dataMatrix = null;
// to store the maximum possible value
int maxCount;
// intialzing number or rows & columns , can be modified later
int numRows;
int numColumns;
// text formatting variables
float constantMarginOnRows = 160;
float constantMarginOnColumns = 100;
Table table;
float blockWidth = 100;
float blockHeight = 100; // initial 80
boolean textFlag= false;
boolean numberFlag = false;
boolean lineFlag = false;
boolean y2006 = true;
boolean y2007 = true;
boolean y2008 = true;
boolean y2009 = true;
boolean y2010 = true;
boolean y2011 = true;
boolean y2012 = true;
boolean y2013 = true;
int ballelevation = 200;
int ballelevation1 = 0;
int checkout = 0;
boolean setMouseControlled = true;
String [] Month = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct", "Nov", "Dec"};
int textColor = #4D2315;
String [] countries = {"United States", "Japan", "France",
"Belgium","England","Canada","Italy","British","Korea","Mexico",
"Norway","Finland","Cote dIvoire","Australia","Iran","Swiss",
"Scotland","Seattle publisher","Sweden","Germany","Netherlands",
"South Africa","Palmiotti Jimmy","Malaysia","India","Spain",
"Brazil","Argentina","Chile","Eastern Europe","Egypt",
"Northern Europe", "New Zealand", "Israel"};
void text(float theValue) {
textFlag= !textFlag;
}
void grid(float thevalue){
lineFlag = !lineFlag;
}
void number(float thevalue){
numberFlag = !numberFlag;
}
void y2006(float thevalue){
y2006 = !y2006;
}
void y2007(float thevalue){
y2007 = !y2007;
}
void y2008(float thevalue){
y2008 = !y2008;
}
void y2009(float thevalue){
y2009 = !y2009;
}
void y2010(float thevalue){
y2010 = !y2010;
}
void y2011(float thevalue){
y2011 = !y2011;
}
void y2012(float thevalue){
y2012 = !y2012;
}
void y2013(float thevalue){
y2013 = !y2013;
}
void controlEvent(ControlEvent theEvent) {
//println(theEvent.getController().getId());
}
void draw() {
colorMode(RGB,100);
background(12);
translate( -width/2, -height/2, -1300); // Peasycam intially sets lookAt() at (0,0,0) hence we need to transalte the axis
pushMatrix();
if ( lineFlag)
{
stroke(textColor,128);
for ( int i =0 ; i <= blockWidth * (12) ; i+= blockWidth)
{
pushMatrix(); //setting up a matrix to keep the current graphi coordinates
translate(constantMarginOnRows, constantMarginOnColumns); //translate to the correct position
line( i,0,0,i, blockHeight * (numColumns-1) ,0); //creating a line (x,y,z)
popMatrix(); // going back to previos projection matrix
}
for ( int i = 0 ; i < blockHeight* numColumns ; i+= blockHeight)
{
pushMatrix();
translate(constantMarginOnRows, constantMarginOnColumns);
line ( 0,i,0,blockWidth* 12 ,i,0);
popMatrix();
}
}
for ( int i = 0 ; i< numRows ; i++)
{
for ( int j= 0 ; j< numColumns ; j++)
{
if( dataMatrix[i][j]!=0)
{
int zTranslation = (dataMatrix[i][j]*255/ maxCount);
//println(zTranslation);
noStroke();
colorMode(HSB,100);
fill (dataMatrix[i][j],dataMatrix[i][j],dataMatrix[i][j], 92 ); // setting up a color for the box
pushMatrix(); // doing the same for all the boxes, sadly that is the only way to do this
translate(constantMarginOnRows, constantMarginOnColumns);
if(i < 12 && y2006){
translate( i* blockWidth + blockWidth/2,
j* blockHeight + blockHeight/2, 0*ballelevation+zTranslation*checkout); // note the movement in z position, it is half of the box's z length, this is because the box is drawn at the center
sphere(10);
}
if(i > 11 && i < 24 && y2007){
translate( (i-12)* blockWidth + blockWidth/2,
j* blockHeight + blockHeight/2, 2*(ballelevation+ballelevation1)+zTranslation*checkout); // note the movement in z position, it is half of the box's z length, this is because the box is drawn at the center
sphere(10);
}
if(i > 23 && i < 36 && y2008){
translate( (i-24)* blockWidth + blockWidth/2,
j* blockHeight + blockHeight/2, 4*(ballelevation+ballelevation1)+zTranslation*checkout); // note the movement in z position, it is half of the box's z length, this is because the box is drawn at the center
sphere(10);
}
if(i > 35 && i < 48 && y2009){
translate( (i-36)* blockWidth + blockWidth/2,
j* blockHeight + blockHeight/2, 6*(ballelevation+ballelevation1)+zTranslation*checkout); // note the movement in z position, it is half of the box's z length, this is because the box is drawn at the center
sphere(10);
}
if(i > 47 && i < 60 && y2010){
translate( (i-48)* blockWidth + blockWidth/2,
j* blockHeight + blockHeight/2, 8*(ballelevation+ballelevation1)+zTranslation*checkout); // note the movement in z position, it is half of the box's z length, this is because the box is drawn at the center
sphere(10);
}
if(i > 59 && i < 72 && y2011){
translate( (i-60)* blockWidth + blockWidth/2,
j* blockHeight + blockHeight/2, 10*(ballelevation+ballelevation1)+zTranslation*checkout); // note the movement in z position, it is half of the box's z length, this is because the box is drawn at the center
sphere(10);
}
if(i > 71 && i < 84 && y2012){
translate( (i-72)* blockWidth + blockWidth/2,
j* blockHeight + blockHeight/2, 12*(ballelevation+ballelevation1)+zTranslation*checkout); // note the movement in z position, it is half of the box's z length, this is because the box is drawn at the center
sphere(10);
}
if(i > 83 && i < 96 && y2013){
translate( (i-84)* blockWidth + blockWidth/2,
j* blockHeight + blockHeight/2, 14*(ballelevation+ballelevation1)+zTranslation*checkout); // note the movement in z position, it is half of the box's z length, this is because the box is drawn at the center
sphere(10);
}
if (numberFlag)
{
// box values
translate( 0,0, zTranslation*10); // translating coordiantes to box position
textFont(myHelvetica12);
textAlign(CENTER,CENTER);
fill(0);
text( dataMatrix[i][j] , 0,0 );
}
popMatrix();
}
}
}
//supporting text
// nochanges required here. As this is being drawn at the base plane
if ( textFlag)
{
for ( int i = 0 ; i< numColumns-1 ; i++) // y varies
{
textFont(myHelvetica48);
textAlign(RIGHT,CENTER);
fill(textColor);
text( countries[i], constantMarginOnRows*0.75 ,constantMarginOnColumns + blockHeight * i + blockHeight/2 );
}
for ( int i = 0 ; i < 12 ; i++) // y varies
{
textFont(myHelvetica48);
textAlign(CENTER,CENTER);
fill(textColor);
text(Month[i], constantMarginOnRows + blockWidth*i+ 50 , constantMarginOnColumns/2);
}
/*
for ( int i = 2006 ; i< 2014 ; i++) // y varies
{
textFont(myHelvetica48);
textAlign(CENTER,CENTER);
fill(textColor);
text(i, constantMarginOnRows + blockWidth + 50 , constantMarginOnColumns/2, (i-2006)*2);
}
*/
textFont(myHelvetica48);
textAlign(LEFT ,CENTER);
fill(textColor);
text( "3D Graph: Comicbook checkouts by countries: 2006 - 2013 " , constantMarginOnRows , constantMarginOnColumns/2-50 );
}
popMatrix();
// makes the gui stay on top of elements
// drawn before.
gui();
if(mouseX > 0 && mouseX < 261 && mouseY > 749 && mouseY < 840){
cam.setMouseControlled(false);
} else {
cam.setMouseControlled(true);
}
/*
cp5.addSlider("ballelevation1")
.setPosition(30,750)
.setSize(200,20)
.setRange(0,200)
.setValue(0)
;
cp5.addSlider("checkout")
.setPosition(30,780)
.setSize(200,20)
.setRange(0,200)
.setValue(0)
;
*/
}
void gui() {
hint(DISABLE_DEPTH_TEST);
cam.beginHUD();
cp5.draw();
cam.endHUD();
hint(ENABLE_DEPTH_TEST);
}
void setup() {
size(1400, 840, OPENGL);
cam = new PeasyCam(this, 100);
cp5 = new ControlP5(this);
cp5.addButton("text", 4, 30, 30, 90, 40).setId(1);
cp5.addButton("grid", 4, 30, 80, 90, 40).setId(2);
cp5.addButton("number", 4, 30, 130, 90, 40).setId(3);
cp5.addButton("y2006", 4, 30, 200, 40, 30).setId(4);
cp5.addButton("y2007", 4, 30, 235, 40, 30).setId(5);
cp5.addButton("y2008", 4, 30, 270, 40, 30).setId(6);
cp5.addButton("y2009", 4, 30, 305, 40, 30).setId(7);
cp5.addButton("y2010", 4, 30, 340, 40, 30).setId(8);
cp5.addButton("y2011", 4, 30, 375, 40, 30).setId(9);
cp5.addButton("y2012", 4, 30, 410, 40, 30).setId(10);
cp5.addButton("y2013", 4, 30, 445, 40, 30).setId(11);
cp5.addSlider("ballelevation1")
.setPosition(30,750)
.setSize(200,20)
.setRange(-200,200)
.setValue(0)
;
cp5.addSlider("checkout")
.setPosition(30,780)
.setSize(200,20)
.setRange(0,70)
.setValue(0)
;
cp5.setAutoDraw(false);
//if (frame != null) {
// frame.setResizable(true); // resizable window
//}
//setting up the camera
//cam= new PeasyCam( this,0,0,0,1000);
cam.setMinimumDistance(50); // how near the camera can get 0,0,0
cam.setMaximumDistance(13000); // how far the camera can travel
table = new Table(); //allocating memory to new table
table = loadTable("data_all_06-13_all_month.csv", "header"); //loading table
numRows = table.getRowCount(); //getting number of rows in the table
numColumns = table.getColumnCount(); //getting the number of columns in table
dataMatrix = new int [numRows][numColumns]; //allocating memory to the internal 2D array
//copying the table data into 2D array
for ( int i = 0 ; i< numRows ; i++)
{
for ( int j= 0 ; j< numColumns ; j++)
{
dataMatrix[i][j] = table.getInt(i,j); // - 1 as the first column is the day number
println("data value: "+ dataMatrix[i][j]);
}
}
println("data transferred");
//finding the maximum count in the data
maxCount = dataMatrix[0][0];
for ( int i = 0 ; i< numRows ; i++)
{
for ( int j= 1 ; j< numColumns ; j++)
{
if(maxCount<dataMatrix[i][j])
{
maxCount=dataMatrix[i][j];
}
}
}
println ( "maximum value is:"+ maxCount);
println ( "rowCount: "+ numRows);
println ( "columnCount: "+ numColumns);
}