** at http://gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28
** Started on Thu Jul 17 10:51:32 2008 Johnny Q. Hacker
-** Last update Sun May 12 01:17:25 2002 Speed Blue
+** Last update Thu Oct 8 17:13:50 2009 Johnny Q. Hacker
*/
#include <graphwidget.h>
double xoffset = (gw->graph->points->len == 1)? (-minx/2) : (-minx);
double yoffset = (gw->graph->points->len == 1)? (-miny/2) : (-miny);
/*Finish up our context information.*/
- cxt.xscaling = (gw->graph->points->len == 1)? cxt.xmax : (cxt.xmax/(maxx - minx));
- cxt.yscaling = (gw->graph->points->len == 1)? cxt.ymax : (cxt.ymax/(maxy - miny));
+ cxt.xscaling = (gw->graph->points->len == 1)? cxt.xmax : (cxt.xmax/(((maxx - minx)==0)?1:(maxx-minx)));
+ cxt.yscaling = (gw->graph->points->len == 1)? cxt.ymax : (cxt.ymax/(((maxy - miny)==0)?1:(maxy-miny)));
cxt.xoffset = (gw->graph->points->len == 1)? (-minx/2) : (-minx);
cxt.yoffset = (gw->graph->points->len == 1)? (-miny/2) : (-miny);
cairo_matrix_translate(&(cxt.data_xlat), xoffset, yoffset);
fprintf(stderr, "minx=%g, maxx=%g, miny=%g, maxy=%g, xscaling=%g, yscaling=%g, xoffset=%g, yoffset=%g\n", minx, maxx, miny, maxy, cxt.xscaling, cxt.yscaling, cxt.xoffset, cxt.yoffset);
fprintf(stderr, "x0=%g, y0=%g, width=%g, height=%g\n", x0, y0, height, width);
fprintf(stderr, "translate=(%g, %g)\n", x0 + ((width>height)?(width-height)/2.0:0), y0+((width > height)?height:width) + ((height>width)?(height-width)/2.0:0));
-#endif
+ #endif
double offset_height = ((width>=height)?height*INSET_PERCENT:0);;
double offset_width = ((height>=width)?width*INSET_PERCENT:0);
double inset_height = height - offset_height;