There's no real change here yet, since the only style offered so far
is the default ACRE_STYLE_LINE, (which is the same as how acre has
always drawn things). But things will get more interesting as new
styles are added in the future.
/* The name of this data set. */
char *name;
/* The name of this data set. */
char *name;
+ /* The style for rendering (line, bar, etc.) */
+ acre_style_t style;
+
/* Minimum and mximum extents of data. */
acre_data_point_2d_t min;
acre_data_point_2d_t max;
/* Minimum and mximum extents of data. */
acre_data_point_2d_t min;
acre_data_point_2d_t max;
cmsCloseProfile (srgb_profile);
}
cmsCloseProfile (srgb_profile);
}
+/* Draw the given dataset as a line. */
+static void
+_draw_data_line (acre_t *acre, acre_data_t *data)
+{
+ unsigned i;
+ cairo_t *cr = acre->cr;
+
+ cairo_save (cr);
+
+ cairo_new_path (cr);
+
+ for (i = 0; i < data->num_points; i++) {
+ cairo_line_to (cr,
+ data->points[i].x,
+ data->points[i].y);
+ }
+
+ cairo_identity_matrix (cr);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
+
+ cairo_restore (cr);
+}
+
+/* Draw all the datasets of the chart. */
static void
_draw_data (acre_t *acre)
{
cairo_t *cr = acre->cr;
static void
_draw_data (acre_t *acre)
{
cairo_t *cr = acre->cr;
acre_data_t *data;
cairo_save (cr);
acre_data_t *data;
cairo_save (cr);
_set_transform_to_data_space (acre);
_set_transform_to_data_space (acre);
- for (d = 0; d < acre->num_data; d++) {
- int color = d % acre->num_colors;
+ for (i = 0; i < acre->num_data; i++) {
+ int color = i % acre->num_colors;
cairo_set_source_rgb (cr,
acre->colors[color].red,
acre->colors[color].green,
acre->colors[color].blue);
cairo_set_source_rgb (cr,
acre->colors[color].red,
acre->colors[color].green,
acre->colors[color].blue);
- data = acre->data[d];
-
- cairo_new_path (cr);
- for (i = 0; i < data->num_points; i++) {
- cairo_line_to (cr,
- data->points[i].x,
- data->points[i].y);
- }
- cairo_save (cr);
- {
- cairo_identity_matrix (cr);
- cairo_set_line_width (cr, 1.0);
- cairo_stroke (cr);
+ switch (data->style) {
+ case ACRE_STYLE_LINE:
+ _draw_data_line (acre, data);
+ break;
+ data->style = ACRE_STYLE_LINE;
+
data->points = NULL;
data->points_size = 0;
data->num_points = 0;
data->points = NULL;
data->points_size = 0;
data->num_points = 0;
acre_set_y_axis_range_auto (acre_t *acre);
/* Add a dataset to the plot. The plot assumes ownership of the
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);
void
acre_add_data (acre_t *acre, acre_data_t *data);
void
acre_data_destroy (acre_data_t *data);
void
acre_data_destroy (acre_data_t *data);
+/* The style to be used for rendering data sets. */
+typedef enum
+{
+ ACRE_STYLE_LINE
+} 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);
/* 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);