gfio: do not mix K M and G when shortening axis labels
[fio.git] / graph.c
diff --git a/graph.c b/graph.c
index 4a3a9938b008770594536f4dd9af191ba50a2e46..d7bdbe5fb8136dcae5908f57990db3d1c74499b6 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -60,13 +60,18 @@ struct graph {
        const char *font;
 };
 
+void graph_set_size(struct graph *g, unsigned int xdim, unsigned int ydim)
+{
+       g->xdim = xdim;
+       g->ydim = ydim;
+}
+
 struct graph *graph_new(unsigned int xdim, unsigned int ydim, const char *font)
 {
        struct graph *g;
 
        g = calloc(1, sizeof(*g));
-       g->xdim = xdim;
-       g->ydim = ydim;
+       graph_set_size(g, xdim, ydim);
        g->per_label_limit = -1;
        g->font = font;
        if (!g->font)
@@ -273,11 +278,10 @@ static void graph_draw_common(struct graph *g, cairo_t *cr,
         cairo_set_source_rgb(cr, 0, 0, 0);
         cairo_set_line_width (cr, 0.8);
 
-       /* for now just set margins at 10% of width.  This is not very good. */
-       *x1 = g->xdim / 10.0;   
-       *x2 = 9.0 * *x1;
-       *y1 = g->ydim / 10.0;   
-       *y2 = 9.0 * *y1;
+       *x1 = 0.15 * g->xdim;   
+       *x2 = 0.95 * g->xdim;
+       *y1 = 0.10 * g->ydim;   
+       *y2 = 0.90 * g->ydim;
 
        cairo_move_to(cr, *x1, *y1);
        cairo_line_to(cr, *x1, *y2);