I'm familiarizing with PHP-GTK2 and I must admints it's not so hard, also thanks to samples and tutorials around, such as one I found in this site about displaying a graph.
Using that useful code as a start I enanched it to display a graph, bounding a scrollbar to modify the scale of x axis and y axis.
What I've done is creating a timeout_add to call every 100 ms to render the graph in the following function ($graph is a GtkImage() globally declared):
| Code: |
function onRenderGraph()
{
global $graph, $hscroll;
$im = imagecreate(GRAPH_W, GRAPH_H);
// painting stuff ... on $im
$pixbuf = GdkPixbuf::new_from_gd( $im );
$graph->set_from_pixbuf($pixbuf);
return true;
} |
When I drag the scrollbar, the changes are not instant, but they happen at least every 100 ms, the timeout delay. I would need a function to connect with a sort of "onScrollChange" event, but I didnt find any :(
Moreover, I was thinking if the onRenderGraph() function could be optimized, without creating every time the $im buffer, maybe create it once when the program starts, and in the function above writing directly to the gd buffer?
I realize I've wrote too much maybe, thanks for reading if you've come up so far.