X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=graph.h;h=078e50ceac83ee881abe61a56073cf56f27bb969;hp=9eb33d7fe121b7e0062cb8e16e5794e728f931f1;hb=fb296043a09fa828e4121d655643f9332b3590e0;hpb=ba35aa8dbd78cc59e2f29d3d746ad3be912a0541 diff --git a/graph.h b/graph.h index 9eb33d7f..078e50ce 100644 --- a/graph.h +++ b/graph.h @@ -2,12 +2,18 @@ #define GRAPH_H struct graph; +struct graph_label; +typedef struct graph_label * graph_label_t; + +#define GRAPH_DEFAULT_FONT "Sans 12" struct graph *graph_new(unsigned int xdim, unsigned int ydim, const char *font); /* graph_new() Returns a new graph structure of the given dimensions and font */ void graph_set_size(struct graph *g, unsigned int xdim, unsigned int ydim); /* graph_set_size() Changes the size of a graph to the given dimensions. */ +void graph_set_position(struct graph *g, double xoffset, double yoffset); +/* graph_set_position() sets the x- and y-offset to translate the graph */ void bar_graph_draw(struct graph *g, cairo_t *cr); /* bar_graph_draw() draws the given graph as a bar graph */ void line_graph_draw(struct graph *g, cairo_t *cr); @@ -17,13 +23,14 @@ void line_graph_set_data_count_limit(struct graph *g, int per_label_limit); * be added to a line graph. Once the limit is reached, the oldest data * is discarded as new data is added */ +void graph_set_font(struct graph *g, const char *font); void graph_title(struct graph *g, const char *title); /* graph_title() sets the main title of the graph to the given string */ void graph_x_title(struct graph *g, const char *title); /* graph_x_title() sets the title of the x axis to the given string */ void graph_y_title(struct graph *g, const char *title); /* graph_y_title() sets the title of the y axis to the given string */ -void graph_add_label(struct graph *g, const char *label); +graph_label_t graph_add_label(struct graph *g, const char *label); /* graph_add_label() adds a new "stream" of data to be graphed. * For line charts, each label is a separate line on the graph. * For bar charts, each label is a grouping of columns on the x-axis @@ -45,13 +52,13 @@ void graph_add_label(struct graph *g, const char *label); * label. */ -int graph_add_data(struct graph *g, const char *label, const double value); +int graph_add_data(struct graph *g, graph_label_t label, const double value); /* graph_add_data() is used to add data to the labels of a bar graph */ -int graph_add_xy_data(struct graph *g, const char *label, - const double x, const double y); +int graph_add_xy_data(struct graph *g, graph_label_t label, + const double x, const double y, const char *tooltip); /* graph_add_xy_data is used to add data to the labels of a line graph */ -void graph_set_color(struct graph *g, const char *label, +void graph_set_color(struct graph *g, graph_label_t label, double red, double green, double blue); #define INVISIBLE_COLOR (-1.0) /* graph_set_color is used to set the color used to plot the data in @@ -73,5 +80,20 @@ void graph_y_axis_unit_change_notify(struct graph *g, graph_axis_unit_change_cal * millions, thousands and ones. */ +void graph_add_extra_space(struct graph *g, double left_percent, double right_percent, + double top_percent, double bottom_percent); +/* graph_add_extra_space() adds extra space to edges of the the graph + * so that the data doesn't go to the very edges. + */ + +extern int graph_has_tooltips(struct graph *g); +extern const char *graph_find_tooltip(struct graph *g, int x, int y); +extern int graph_contains_xy(struct graph *p, int x, int y); + +extern void graph_set_base_offset(struct graph *g, unsigned int base_offset); +extern void graph_set_graph_all_zeroes(struct graph *g, unsigned int set); + +extern void graph_clear_values(struct graph *g); + #endif