X-Git-Url: https://git.cworth.org/git?p=acre;a=blobdiff_plain;f=acre.h;h=7924cba2d26d38603b0318ac1d319a3f72ed6198;hp=89079ff3908bce3219a43cfba33719ff9777f60c;hb=HEAD;hpb=fb885ce6b3cdd5cde8b3c21821b49e2a82f6f11f diff --git a/acre.h b/acre.h index 89079ff..7924cba 100644 --- a/acre.h +++ b/acre.h @@ -42,8 +42,55 @@ acre_set_x_axis_label (acre_t *acre, const char *label); void acre_set_y_axis_label (acre_t *acre, const char *label); +/* Get the range of data values in the X dimension. */ +void +acre_get_x_axis_data_range (acre_t *acre, double *x_min, double *x_max); + +/* Get the range of the currently viewable X axis. */ +void +acre_get_x_axis_range (acre_t *acre, double *x_min, double *x_max); + +/* Set the range of the currently viewable X axis. */ +void +acre_set_x_axis_range (acre_t *acre, double x_min, double x_max); + +/* Set the X axis viewable range to be sized automatically. + * + * If both X and Y axes are sized automatically, then the X range will + * be set to the full range of data in the X dimension. + * + * But if the Y axis has been set to a limited viewable range, (with + * acre_set_y_axis_range), then the X axis will be set to the + * corresponding X range of data that lies within that set Y range. */ +void +acre_set_x_axis_range_auto (acre_t *acre); + +/* Get the range of data values in the Y dimnension. */ +void +acre_get_y_axis_data_range (acre_t *acre, double *y_min, double *y_max); + +/* Get the range of the currently viewable Y axis. */ +void +acre_get_y_axis_range (acre_t *acre, double *y_min, double *y_max); + +/* Set the range of the currently viewable Y axis. */ +void +acre_set_y_axis_range (acre_t *acre, double y_min, double y_max); + +/* Set the Y axis viewable range to be sized automatically. + * + * If both X and Y axes are sized automatically, then the Y range will + * be set to the full range of data in the Y dimension. + * + * But if the X axis has been set to a limited viewable range, (with + * acre_set_x_axis_range), then the Y axis will be set to the + * corresponding Y range of data that lies within that set X range. */ +void +acre_set_y_axis_range_auto (acre_t *acre); + /* Add a dataset to the plot. The plot assumes ownership of the - * dataset so it is not necessary to call acre_data_destroy on it. */ + * dataset so it is not necessary to call acre_data_destroy on it. + */ void acre_add_data (acre_t *acre, acre_data_t *data); @@ -53,7 +100,7 @@ acre_add_data (acre_t *acre, acre_data_t *data); * etc.) */ void -acre_draw (acre_t *acre, cairo_t *cr, double width, double height); +acre_draw (acre_t *acre, cairo_t *cr, int width, int height); /* Create a new dataset---a collection of (x, y) datapoints. A single * plot can contain multiple datasets, (see acre_add_data). */ @@ -65,6 +112,33 @@ acre_data_create (void); void acre_data_destroy (acre_data_t *data); +/* The style to be used for rendering data sets. */ +typedef enum +{ + /* A simple line graph connection each (X,Y) pair in order. */ + ACRE_STYLE_LINE, + + /* A bar chart. */ + ACRE_STYLE_BARS, + + /* Bars if there is room for them, a line otherwise. */ + ACRE_STYLE_BARS_OR_LINE, + + /* A timeline. + * + * Each (X,Y) pair specifies the (start,stop) time of a + * timeline bar. + * + * The acre_data_add_point_2d_named function is particularly + * useful to provide a name for each timeline bar. + */ + ACRE_STYLE_TIMELINE +} acre_style_t; + +/* Set the rendering style for this dataset. */ +void +acre_data_set_style (acre_data_t *data, acre_style_t style); + /* Set the label for this dataset (to appear in the plot's key). */ void acre_data_set_name (acre_data_t *data, const char *name); @@ -73,4 +147,9 @@ acre_data_set_name (acre_data_t *data, const char *name); void acre_data_add_point_2d (acre_data_t *data, double x, double y); +/* Add a datapoint with a name to the given dataset. */ +void +acre_data_add_point_2d_named (acre_data_t *data, double x, double y, + const char *name); + #endif /* ACRE_H */