C++
Tutorial
Part 3a
Total SUU Webserver Pagehits by Day

Download this file:

DailyPageHit.zip shows the total number of page requests on several different days.

This visualization is actually reather elementary to create. The data is stored in a text file. Each line of the file is a different day, and each line merely contains the number of hits for that day. Then to create the bars we loop through all the lines in the file reading in the values and then create the bars with the following code:

--

//Create the new Objects

cube = vtkCubeSource::New();
cubeMapper = vtkPolyDataMapper::New();
cubeActor = vtkActor::New();

//Rotate the Actor and Set the size of the bars

cubeMapper->SetInput(cube->GetOutput());
cubeActor->SetMapper(cubeMapper);
cubeActor->RotateWXYZ(90, 0, 1, 0);
cube->SetXLength(.1);
cube->SetYLength(.1);
cube->SetZLength(barWidth / scaleMode);

//Position the Actors

cube->SetCenter(0, (i + 1) * 2, (barWidth / scaleMode) / 2);

ren1->AddActor(cubeActor);

--

 

Note that in the above code to position the cube we do so by setting it's center. Because of this we need to set the center z value equal to the zLength / 2. This is so that the left edges of the cubes will line up properly.

Home
C++ Tutorial
Python Tutorial
TCL/TK Tutorial

Downloads
Homework
About Us
Contact
Links

C++ Tutorial
Part 1: VS 6
Part 2: VS .NET
Part 3: SUU Logs