summaryrefslogtreecommitdiff
path: root/graph.c
diff options
context:
space:
mode:
authorStephen M. Cameron <stephenmcameron@gmail.com>2012-03-11 11:36:51 +0100
committerJens Axboe <axboe@kernel.dk>2012-03-11 11:36:51 +0100
commit57f9d28e010b52fea5f41245e8fcb998367d3bcd (patch)
treeff31d26e42c6b7e79e75b71e6814e5fe5cb34eac /graph.c
parentba35aa8dbd78cc59e2f29d3d746ad3be912a0541 (diff)
downloadfio-57f9d28e010b52fea5f41245e8fcb998367d3bcd.tar.gz
fio-57f9d28e010b52fea5f41245e8fcb998367d3bcd.tar.bz2
gfio: encapsulate x- and y-offsets into graph library
Don't need to carry around drawing area dimensions alongside the graphs, the size and xy-offsets of the graphs can be set directly in the drawing area configure callback. Signed-off-by: Stephen M. Cameron <stephenmcameron@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'graph.c')
-rw-r--r--graph.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/graph.c b/graph.c
index de65055b..111a7203 100644
--- a/graph.c
+++ b/graph.c
@@ -55,6 +55,7 @@ struct graph {
char *xtitle;
char *ytitle;
unsigned int xdim, ydim;
+ double xoffset, yoffset;
struct graph_label *labels;
struct graph_label *tail;
int per_label_limit;
@@ -69,6 +70,12 @@ void graph_set_size(struct graph *g, unsigned int xdim, unsigned int ydim)
g->ydim = ydim;
}
+void graph_set_position(struct graph *g, double xoffset, double yoffset)
+{
+ g->xoffset = xoffset;
+ g->yoffset = yoffset;
+}
+
struct graph *graph_new(unsigned int xdim, unsigned int ydim, const char *font)
{
struct graph *g;
@@ -397,6 +404,7 @@ void bar_graph_draw(struct graph *bg, cairo_t *cr)
struct graph_label *lb;
cairo_save(cr);
+ cairo_translate(cr, bg->xoffset, bg->yoffset);
graph_draw_common(bg, cr, &x1, &y1, &x2, &y2);
nlabels = count_labels(bg->labels);
@@ -473,6 +481,7 @@ void line_graph_draw(struct graph *g, cairo_t *cr)
int good_data = 1, first = 1;
cairo_save(cr);
+ cairo_translate(cr, g->xoffset, g->yoffset);
graph_draw_common(g, cr, &x1, &y1, &x2, &y2);
minx = find_xy_value(g, getx, mindouble);