imcsk8 has asked for the wisdom of the Perl Monks concerning the following question:

i have to write a data cube for a school project, i mostly understand the concept but i have to draw a graph of the cube (something like this cube). i don't really know which approach to take, sould i use GD or should i use opengl??
is there a module that does this kind of graph??

any help will be appreciated, thanks


ignorance, the plague is everywhere
--guttermouth

Replies are listed 'Best First'.
Re: data cube (OLAP) graphic
by flyingmoose (Priest) on Mar 26, 2004 at 17:12 UTC
    OpenGL is doable, but it would be a lot of work, and for a static image I doubt it is worth the time investment to figure out how to make the fonts work, to deal with the infamous black screen of death, and so on.

    If you feel up to it, PDL has a Graphing package that does a very good job of rendering plots in OpenGL. I am not sure exactly how well it can put labels in certain points in space, however, but it makes some killer rotating plots. See the Screenshots section of the PDL page. You could do something with PDL and take screen captures -- however you are going to have to think of your graph in terms of line equations and points, so this may be less than ideal.

    Failing that, your graph is isomorphic, and all the lines are at right or 45 degree angles, so using GD and the aforementioned modules isn't really that rough. The line calculations are essentially trivial if you must do your own isomorphic (cabinet view) rendering.

Re: data cube (OLAP) graphic
by jZed (Prior) on Mar 26, 2004 at 16:43 UTC
Re: data cube (OLAP) graphic
by toma (Vicar) on Mar 26, 2004 at 18:10 UTC
    A cool way to do it would be to use POV-Ray: "The Persistence of Vision Raytracer is a high-quality, totally free tool for creating stunning three-dimensional graphics."

    Math::VectorReal would be helpful for the 3D math part.

    Your problem difficulty is just right for your first POV-Ray project.

    It should work perfectly the first time! - toma
      POV-Ray is an unbelievable tool, but a charting package or a CAD package it is not. It's mostly used for static art and animation. IMHO, charts shouldn't have to worry about camera position and light sources. However (OT), I have long toyed with the idea of making a Perl module to build POV-Ray files in a clever way, as well as to automate POV-Ray, but this is more of a module idea than anything else.

      If this is to be done manually (and only a few times), some really basic drawing program will be easier than POV (POV has a learning curve), and I suppose the reason this was posted in a Perl forum is because he would like to generate these tables automatically as some sort of schema or definition changes, or maybe there are a lot of schemas to generate.

      Of course, the POV version could use the new radiosity features and would definitely be really shiny. Be sure to include lots of textured camels.

Re: data cube (OLAP) graphic
by Anonymous Monk on Mar 27, 2004 at 01:55 UTC

    if your assignment is not about the graphics, but about the cube itself, impress them with simple.

    z2 -- # z1 -- + z0 -- * ## ## ## ++ ++ ++ ## y2 -- ** ** ** ++ ## y1 -- ** ** ** ++ y0 -- ** ** ** | | | x0 x1 x2

    if your values are all the same number of characters and you don't have too many rows, columns or layers you should be able to do this in plain text. it's much easier to tell the layers apart if each is done in a different color, make the #'s dark grey, the +'s medium grey, and the *'s and labels white on a black background.

    if it's the graphics you want, use GD. the method is about the same, take your data points and find a 2d box that will fit around them all. write a subroutine that draws a whole layer at an x,y offset with a given fill color. draw the back layer in a darker color, move the offset down and to the left a bit, make the fill color lighter, draw the next layer. repeat until done.

    i think most graph/chart modules would make it hard to put things on top of each other, or if they did have a 3d cube, using it would be cheating on your homework =)

    on the extreem end, i've seen way cool 3d cube visualizations that use color for one dimension, light and dark for the second, and size (perspective) for the third where it was possible to see all the numbers at once and still be able to grok out their 3d position.

Re: data cube (OLAP) graphic
by zentara (Cardinal) on Mar 27, 2004 at 16:20 UTC
    I would look at postscript and gnuplot. Check out the screenshots at gnuplot-3d and gnuplot

    If you can get a "generic postscript output for a 3d box", you could probably just modify it directly to suit your needs. There may be a postscript "3d box recipe" somewhere on the net.


    I'm not really a human, but I play one on earth. flash japh