tips for how the bloody hell to label my dynamically generated graphs pls

Discussion in 'OT Technology' started by piratepenguin, Dec 16, 2007.

  1. piratepenguin

    piratepenguin New Member

    Joined:
    Jun 18, 2006
    Messages:
    1,067
    Likes Received:
    0
    Location:
    Ireland
    Hello folks, long time no see.

    http://piratepenguin.is-a-geek.com:82/~declan/algebra/testing.xhtml
    ^ View in an SVG-enabled browser. There are a few fucked up things about that document, but my work is incomplete since I'm stumped as to in what way I should label and mark units on the axes. I've implemented different methods to do this about 2 or 3 times, and none have impressed me over a wide enough scope of zoom levels.

    I am only dealing with the positive X axis until I get this right 100%. I want to be able to deal with users viewing 5, 10, 100, 1000, and then 1 and under units there, and at intervals there needs to be marks - some labeled with a figure for the X value, elegantly, and that's the difficult part. Zoom in one in the testing.xhtml setup for the first issue with my current once-looking-promising implementation.

    Given is the length of one X unit (could be 1px, could be 50px, hopefully could be 5000px), what would YOU do with that unit.

    I'm hoping somebody has done something a lot like this before, and could give me some tips.
     
  2. piratepenguin

    piratepenguin New Member

    Joined:
    Jun 18, 2006
    Messages:
    1,067
    Likes Received:
    0
    Location:
    Ireland
    Here is my current implementation which I have fixed up:

    There is major markers, and minor markers (which are not labeled). minDistanceBetweenMajorMarkers is set to a fraction (one twelfth) of the viewable graphing space width. That's ok. unitsPerMajorMarker is set to minDistanceBetweenMajorMarkers / xUnitLength, rounded up.

    That's the major markers done, now the minor's is done in a similar way, with minimumDistance set to 4 pixels now. Then in a loop the markers are drawn.

    It works fine enough (subtract the JS rounding errors experienced in the odd case), but when I said elegant, I don't think people would appreciate labeled intervals of 7 as much as 8 or 10.

    I think I should exclude odd numbers for major counting, but 3 can be good. Baaah.

    If nobody has any tips, so be it. What I have is workable enough for a long time.
     
  3. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Just a thought... don't. http://code.google.com/p/flot/

    I've spent so much time doing custom charts and I'm just moving to this instead.

    Sorry, I'll re-read your post when I'm more sober/rested/smart.
     
  4. piratepenguin

    piratepenguin New Member

    Joined:
    Jun 18, 2006
    Messages:
    1,067
    Likes Received:
    0
    Location:
    Ireland
    Holy FUCK those are some beautiful graphs!

    But what I need more than anything is Cartesian graphs (that will accept equations of lines, parabolas, that sortof high-school stuff, and be able to find derivatives of them etc). I'm gonna mail that list, might be able to start working on that. Learning jQuery is a good idea too.

    I hope this works out. I never used canvas before, I guess that's a better idea too since it should turn out much faster than SVG - but I don't know.
     
  5. piratepenguin

    piratepenguin New Member

    Joined:
    Jun 18, 2006
    Messages:
    1,067
    Likes Received:
    0
    Location:
    Ireland
    cheers face (funny, this dude in school used to call me faceman for some reason I couldn't understand... wait why did he call me faceman?!)

    well, I don't think any code will be useful. I took a timeout, when I get to taking the computer outof my living room and up to my desk, I think I'll just trudge onwards with what I'm doing regardless of this imperfection, but I like using the web on a 40" screen from 1.5 meters away.
     

Share This Page