Menu

Single vertical Lines

Kümmel83
2011-07-20
2012-09-07
  • Kümmel83

    Kümmel83 - 2011-07-20

    I want to mark a specific x-position with a vertical line, f.e. to show the
    extension of an intersection of two linegraphs down to the x-axis. This
    position(s) (normally) has nothing to do with the grid or ticks.

    By telling the plot on with x-value to put the vertical line, I also want to
    have access to edit its look (color, width, dashed, ..) and up to which
    y-value it should be drawn (no value = to the highest value).

     
  • lbayuk

    lbayuk - 2011-07-20

    Use a drawing callback. There is a description in the manual, Using Callbacks
    to Annotate Plots
    , and Example - Annotating a Plot Using a
    Callback
    .

    Briefly, you set up a function (callback) to be called after the graph is
    drawn but before it is output to the browser. Your function can draw whatever
    you want on the image, using PHP GD functions. There is a PHPlot function that
    lets you map world X,Y coordinates to GD coordinates so you can annotate at
    specific locations on the data. You are going to have to calculate the
    intersection on your own, though.

    This should point you in the right direction, but if you need some more help I
    can try to make a small example.

     
  • Kümmel83

    Kümmel83 - 2011-07-21

    Ok, so it is now more a feature request.

    I hoped I only overlooked something in the manual. The part with the callback
    came also in my mind, but theoretical all needs can be solved with own
    callbacks.

    That I have to calculate the intersection is clear and no problem - I have it
    already in my dataarray (only a part is used for setDataValues()).

    The callback acts better as I thought. I use it for draw_image_background and
    solid lines are placed easy. Am I supposed to make my own functions for other
    line styles?

     
  • lbayuk

    lbayuk - 2011-07-21

    Good. Note that the draw_image_background callback happens pretty early in the
    drawing process. Anything drawn from a draw_image_background callback will be
    covered by any overlapping parts of the plot. Also, if you have a plot area
    background, it will completly cover anything drawn from the
    draw_image_background callback.

    To do line styles in PHP with GD, you use imagesetstyle() to set up your
    pattern of pixels (color and transparent), then draw the lines as usual but
    specify the constant IMG_COLOR_STYLED as the 'color' to use. There is an
    example in the PHP manual page for imagesetstyle. Also you can use
    imagesetthickness() for thicker lines.

    (Note thick, styled lines don't work the way you might think. More info
    here
    )

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.