phpjpgraph

JPGraph : how to hide plot line when going above x-axis?


I set custom scale for my plot line in JPGraph, using :

$graph->SetScale('linlin', 60,200);

You can see the result here : http://screencast.com/t/jMKHg1XUis

The display is correct but i would want to hide the plots that come out of the range (below x-axis). Can't find anything about a such feature in the documentation.


Solution

  • The class reference for Graph has a SetClipping function. From the documentation:

    Enable or disable clipping outside the plot area. If clipping is enabled then only the part of the graph exactly inside the plot area will be visible.

    Clipping may come in handy when you for example set a manual scale and have data points outside the specified range.

    By default clipping is disabled.

    Note 1: Clipping is only supported for graphs at 0 or 90 degrees rotation and will generate an error message if enabled together with any other angle.

    Note 2: The clipping is implemented with a O(1) algorithm in terns of data size.

    You need to enable clipping by calling the function:

    $graph->SetClipping();