]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Show legend coords in graphv, for making img map 715/head
authorAnders Björklund <anders@itension.se>
Sun, 26 Jun 2016 11:53:02 +0000 (13:53 +0200)
committerAnders Björklund <anders@itension.se>
Wed, 29 Jun 2016 05:55:53 +0000 (07:55 +0200)
src/rrd_graph.c
tests/functions
tests/rpn1
tests/rpn1.output

index ba34e18a08c122e5099683692fdd217a15b1694f..898b301f4f17ff3e4cc75f8057baa19bb0642e71 100644 (file)
@@ -3085,6 +3085,7 @@ int grid_paint(
     int       res = 0;
     double    X0, Y0;   /* points for filled graph and more */
     struct gfx_color_t water_color;
+    int       legend_cnt = 0;
 
     if (im->draw_3d_border > 0) {
            /* draw 3d border */
@@ -3251,6 +3252,32 @@ int grid_paint(
                      [TEXT_PROP_LEGEND].font_desc,
                      im->tabwidth, 0.0,
                      GFX_H_LEFT, GFX_V_BOTTOM, im->gdes[i].legend);
+            {
+                rrd_infoval_t val;
+                double w, h;
+
+                w = gfx_get_text_width(im, 0,
+                                       im->
+                                       text_prop
+                                       [TEXT_PROP_LEGEND].font_desc,
+                                       im->tabwidth, im->gdes[i].legend);
+                h = gfx_get_text_height(im, 0,
+                                        im->
+                                        text_prop
+                                        [TEXT_PROP_LEGEND].font_desc,
+                                        im->tabwidth, im->gdes[i].legend);
+
+                val.u_str = sprintf_alloc("%s", im->gdes[i].legend);
+                grinfo_push(im,
+                            sprintf_alloc("legend[%ld]", legend_cnt),
+                            RD_I_STR, val);
+                val.u_str = sprintf_alloc("%.0f,%.0f,%.0f,%.0f",
+                                          X0, Y0 - h, X0 + w, Y0);
+                grinfo_push(im,
+                            sprintf_alloc("coords[%ld]", legend_cnt),
+                            RD_I_STR, val);
+                legend_cnt++;
+            }
             /* The legend for GRAPH items starts with "M " to have
                enough space for the box */
             if (im->gdes[i].gf != GF_PRINT &&
index f12af726c3849dd457f12f572e64759af0149169..6b9f9069918c0baa6a001d82adb34000cc786e29 100644 (file)
@@ -15,6 +15,12 @@ function seddif {
    perl -p -e 's/([-+]?\d\.\d+e[-+]\d+)/sprintf("%0.7e",$1)/ge' | $DIFF $@
 }
 
+BLANK=blank
+
+function blank {
+   perl -p -e 'm/(left|top|right|bottom|width|height|coords)/ && s/\d+/\#/g' $@
+}
+
 #
 # because valgrind has trouble with glib memory handling
 # (see e.g. https://developer.gnome.org/glib/2.30/glib-running.html or 
index f000e6a78042663c98e5c46bb361d80af5bb5f63..2cbe05c897fbbc691fef988063ef0d39abb8a1da 100755 (executable)
@@ -12,7 +12,9 @@ $RRDTOOL update $RRD 920806500:12383 920806800:12393 920807100:12399
 $RRDTOOL update $RRD 920807400:12405 920807700:12411 920808000:12415
 $RRDTOOL update $RRD 920808300:12420 920808600:12422 920808900:12423
 report "update"
-$RRDTOOL graphv -                          \
+# blank out any absolute coordinates, as they might differ
+$BLANK < $BASEDIR/rpn1.output > $BASEDIR/rpn1.output.out
+$RRDTOOL graphv $BASEDIR/rpn1.out \
       --start 920804400 --end 920808000               \
       DEF:my-speed=$RRD:speed:AVERAGE              \
       CDEF:nonans01=my-speed,UN,0,my-speed,IF             \
@@ -23,7 +25,8 @@ $RRDTOOL graphv -                          \
       VDEF:f=fast123456789012345678901234567890,AVERAGE \
       VDEF:g=good,MAXIMUM \
       VDEF:o=over,MINIMUM \
+      VRULE:920806500:"foo" \
       PRINT:f:'%lf' \
       PRINT:g:'%lf' \
-      PRINT:o:'%lf' | $DIFF9 - $BASEDIR/rpn1.output
+      PRINT:o:'%lf' | $BLANK | $DIFF9 - $BASEDIR/rpn1.output.out
 report "graphv"
index 4a7696dbcf0b7860e486d3c4cfeff47db484c57b..211a76c9e7ddc58f776223fa648a701498591f5b 100644 (file)
@@ -1,3 +1,15 @@
 print[0] = "30.769231"
 print[1] = "72.000000"
 print[2] = "0.000000"
+graph_left = 51
+graph_top = 15
+graph_width = 400
+graph_height = 100
+image_width = 481
+image_height = 155
+graph_start = 920804400
+graph_end = 920808000
+value_min = 0.0000000e+00
+value_max = 1.0000000e+00
+legend[0] = "  foo"
+coords[0] = "16,135,51,148"