Re: issue with drawing graph in GTK



My guess is that your data points are extending outside your drawing area.
I would suggest including something in your code to verify that all points
passed to cairo move to or cairo line to are within the valid range.

Anthony Ruth
NASA Space Technology Research Fellow
Condensed Matter Theory
University of Notre Dame

On Sat, Feb 11, 2017 at 1:40 AM, Lokesh Chakka <
lvenkatakumarchakka gmail com> wrote:

Hello,

please refer to the graph images one.jpg
<https://drive.google.com/open?id=0By6TAMxEKC6yUjYtU3VKOE5TQ1k> and
two.jpg
<https://drive.google.com/open?id=0By6TAMxEKC6yYXNXN2lCMmVOTTA>.

I am using below code for drawing two graphs from same data.
=====================================================
void on_draw_event( GtkWidget *widget, cairo_t *cr, parameter_type
parameter )
{
    cairo_line_to(.......);
    cairo_stroke( cr )
    cairo_set_source_surface( cr, parameter->surface, 0, 0 );
    cairo_paint( cr );
}

gboolean draw_graphs( gpointer param )
{
    gtk_widget_queue_draw( parameter->statistics );
}

main()
{
    parameter->surface = create_image_surface();
    parameter->cr = cairo_create( temp->surface );
    parameter->statistics = gtk_drawing_area_new();
    if( g_signal_connect( G_OBJECT(parameter->statistics), "draw",
G_CALLBACK( on_draw_event ), parameter ) == 0 )
         fprintf( stderr, "unable to connect.");

     const guint draw_event_source = g_timeout_add_seconds( 2, draw_graphs,
NULL );
     .
     .
     .
     g_source_remove( draw_event_source );

}
=====================================================

even though it is same code and same data, I am seeing one graph is proper
and other graph is with some missing lines. graph one.jpg is not as per
expectations and graph two.jpg is proper.
can some one help me what wrong I am doing ?

both the graphs are attached to a box which in turn was attached to a
scrolling window.
My requirement is that, both the graphs to be exactly look a like.

please let me know if more information is required.



Thanks & Regards
--
Lokesh Chakka.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]