I'm not sure how you must do at the moment. I'll have to make some tests
and time is missing just now. But you surely need to take plot_area.x
and plot_area.y into account. Anyway this is related to the enhancement
feature #580545 even it is for an xy plot instead if a pie plot.
I intend to woekon that quite soon, and I'll let you know how things are
going.

Best regards,
Jean

Le mercredi 20 mai 2009 à 09:53 +0100, jcup...@gmail.com a écrit :
> Hi all,
> 
> I'm displaying a chart with libgoffice and I'd like to map motion
> notify event coordinates to axis positions.
> 
> I've got fairly close, but I can't see how to take account of the
> margins around the edges of the chart :-( Can anyone point me to some
> sample code that does this?
> 
> Here's what I have:
> 
>         axes = gog_chart_get_axes( plotpresent->gchart, GOG_AXIS_X );
>         x_axis = GOG_AXIS( axes->data );
>         g_slist_free( axes );
> 
>         axes = gog_chart_get_axes( plotpresent->gchart, GOG_AXIS_Y );
>         y_axis = GOG_AXIS( axes->data );
>         g_slist_free( axes );
> 
>         gog_chart_get_plot_area( plotpresent->gchart, &plot_area );
> 
>         map = gog_chart_map_new( plotpresent->gchart,
>                 &plot_area, x_axis, y_axis, NULL, FALSE );
> 
>         x_map = gog_chart_map_get_axis_map( map, 0 );
>         y_map = gog_chart_map_get_axis_map( map, 1 );
> 
>         x_canvas = event->x / (double) allocation->width;
>         y_canvas = event->y / (double) allocation->height;
> 
>         x = gog_axis_map_from_view( x_map, x_canvas );
>         y = gog_axis_map_from_view( y_map, y_canvas );
> 
>         gog_chart_map_free( map );
> 
>         printf( "event->x = %g, event->y = %g\n", event->x, event->y );
>         printf( "x_canvas = %g, y_canvas = %g\n", x_canvas, y_canvas );
>         printf( "x = %g, y = %g\n", x, y );
> 
> John
> _______________________________________________
> gnumeric-list mailing list
> gnumeric-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gnumeric-list

_______________________________________________
gnumeric-list mailing list
gnumeric-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gnumeric-list

Reply via email to