summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 95df04d)
raw | patch | inline | side by side (parent: 95df04d)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Tue, 1 Sep 2009 08:49:11 +0000 (08:49 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Tue, 1 Sep 2009 08:49:11 +0000 (08:49 +0000) |
NEWS | patch | blob | history | |
src/rrd_graph.c | patch | blob | history |
index d5a4ad2e60c5c5a49b091ddec9e10a33ec49f268..d13a76ad04204ac3606a5e42e9bcc76c3328d3c4 100644 (file)
--- a/NEWS
+++ b/NEWS
* new graph option --border to set the 3d border width
by Bernhard Reutner-Fischer
+* draw different color swats depending on the type of line drawn in the
+ graph by Loïc Tortay
for more detail see the CHANGES file.
diff --git a/src/rrd_graph.c b/src/rrd_graph.c
index ff1859d6622cedfb85b3fc0d13c2dc9811604134..2df1835d1b4764e25b4d2bbd0f7d25a0c6bfa184 100644 (file)
--- a/src/rrd_graph.c
+++ b/src/rrd_graph.c
boxV = boxH;
/* shift the box up a bit */
Y0 -= boxV * 0.4;
- /* make sure transparent colors show up the same way as in the graph */
- gfx_new_area(im,
- X0, Y0 - boxV,
- X0, Y0, X0 + boxH, Y0, im->graph_col[GRC_BACK]);
- gfx_add_point(im, X0 + boxH, Y0 - boxV);
- gfx_close_path(im);
- gfx_new_area(im, X0, Y0 - boxV, X0,
- Y0, X0 + boxH, Y0, im->gdes[i].col);
- gfx_add_point(im, X0 + boxH, Y0 - boxV);
- gfx_close_path(im);
- cairo_save(im->cr);
- cairo_new_path(im->cr);
- cairo_set_line_width(im->cr, 1.0);
- X1 = X0 + boxH;
- Y1 = Y0 - boxV;
- gfx_line_fit(im, &X0, &Y0);
- gfx_line_fit(im, &X1, &Y1);
- cairo_move_to(im->cr, X0, Y0);
- cairo_line_to(im->cr, X1, Y0);
- cairo_line_to(im->cr, X1, Y1);
- cairo_line_to(im->cr, X0, Y1);
- cairo_close_path(im->cr);
- cairo_set_source_rgba(im->cr,
- im->
- graph_col
- [GRC_FRAME].
- red,
- im->
- graph_col
- [GRC_FRAME].
- green,
- im->
- graph_col
- [GRC_FRAME].
- blue, im->graph_col[GRC_FRAME].alpha);
+ if (im->gdes[i].gf == GF_HRULE) { /* [-] */
+ cairo_save(im->cr);
+ cairo_new_path(im->cr);
+ cairo_set_line_width(im->cr, 1.0);
+ gfx_line(im,
+ X0, Y0 - boxV / 2,
+ X0 + boxH, Y0 - boxV / 2,
+ 1.0, im->gdes[i].col);
+ gfx_close_path(im);
+ } else if (im->gdes[i].gf == GF_VRULE) { /* [|] */
+ cairo_save(im->cr);
+ cairo_new_path(im->cr);
+ cairo_set_line_width(im->cr, 1.0);
+ gfx_line(im,
+ X0 + boxH / 2, Y0,
+ X0 + boxH / 2, Y0 - boxV,
+ 1.0, im->gdes[i].col);
+ gfx_close_path(im);
+ } else if (im->gdes[i].gf == GF_LINE) { /* [/] */
+ cairo_save(im->cr);
+ cairo_new_path(im->cr);
+ cairo_set_line_width(im->cr, im->gdes[i].linewidth);
+ gfx_line(im,
+ X0, Y0,
+ X0 + boxH, Y0 - boxV,
+ im->gdes[i].linewidth, im->gdes[i].col);
+ gfx_close_path(im);
+ } else {
+ /* make sure transparent colors show up the same way as in the graph */
+ gfx_new_area(im,
+ X0, Y0 - boxV,
+ X0, Y0, X0 + boxH, Y0, im->graph_col[GRC_BACK]);
+ gfx_add_point(im, X0 + boxH, Y0 - boxV);
+ gfx_close_path(im);
+ gfx_new_area(im, X0, Y0 - boxV, X0,
+ Y0, X0 + boxH, Y0, im->gdes[i].col);
+ gfx_add_point(im, X0 + boxH, Y0 - boxV);
+ gfx_close_path(im);
+ cairo_save(im->cr);
+ cairo_new_path(im->cr);
+ cairo_set_line_width(im->cr, 1.0);
+ X1 = X0 + boxH;
+ Y1 = Y0 - boxV;
+ gfx_line_fit(im, &X0, &Y0);
+ gfx_line_fit(im, &X1, &Y1);
+ cairo_move_to(im->cr, X0, Y0);
+ cairo_line_to(im->cr, X1, Y0);
+ cairo_line_to(im->cr, X1, Y1);
+ cairo_line_to(im->cr, X0, Y1);
+ cairo_close_path(im->cr);
+ cairo_set_source_rgba(im->cr,
+ im->graph_col[GRC_FRAME].red,
+ im->graph_col[GRC_FRAME].green,
+ im->graph_col[GRC_FRAME].blue,
+ im->graph_col[GRC_FRAME].alpha);
+ }
if (im->gdes[i].dash) {
/* make box borders in legend dashed if the graph is dashed */
double dashes[] = {