summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 55177bd)
raw | patch | inline | side by side (parent: 55177bd)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 24 Oct 2008 09:25:49 +0000 (09:25 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 24 Oct 2008 09:25:49 +0000 (09:25 +0000) |
program/doc/rrdgraph.pod | patch | blob | history | |
program/src/rrd_graph.c | patch | blob | history | |
program/src/rrd_graph.h | patch | blob | history | |
program/src/rrd_tool.c | patch | blob | history |
index 02b9a82f44e107e13ee75fb86265b2ab3f361a19..807ef4fc641551ce65dbcb27ad83bc9b75d5ae99 100644 (file)
--- a/program/doc/rrdgraph.pod
+++ b/program/doc/rrdgraph.pod
[B<-S>|B<--step> I<seconds>]
The start and end of the time series you would like to display, and which
-B<RRA> the data should come from. Defaults are: 1 day ago until
-now, with the best possible resolution. B<Start> and B<end> can
-be specified in several formats, see
-L<rrdfetch> and L<rrdgraph_examples>.
-By default, B<rrdtool graph> calculates the width of one pixel in
-the time domain and tries to get data from an B<RRA> with that
-resolution. With the B<step> option you can alter this behaviour.
-If you want B<rrdtool graph> to get data at a one-hour resolution
-from the B<RRD>, set B<step> to 3'600. Note: a step smaller than
-one pixel will silently be ignored.
+B<RRA> the data should come from. Defaults are: 1 day ago until now, with
+the best possible resolution. B<Start> and B<end> can be specified in
+several formats, see L<rrdfetch> and L<rrdgraph_examples>. By default,
+B<rrdtool graph> calculates the width of one pixel in the time domain and
+tries to get data from an B<RRA> with that resolution. With the B<step>
+option you can alter this behaviour. If you want B<rrdtool graph> to get
+data at a one-hour resolution from the B<RRD>, set B<step> to 3'600. Note: a
+step smaller than one pixel will silently be ignored.
=item Labels
[B<--right-axis-label> I<label>]
A second axis will be drawn to the right of the graph. It is tied to the
-left axis via the scale and shift parameters. You can also define a label for the right axis.
+left axis via the scale and shift parameters. You can also define a label
+for the right axis.
+
+[B<--right-axis-format> I<format-string>]
+
+By default the format of the axis lables gets determined automatically. If
+you want todo this your self, use this option with the same %lf arguments
+you know from the PRING and GPRINT commands.
=item Size
index 41024eccc3925932b92aaf0802ceb79f248f712c..139b44558211002a476ca85ef69210bf195932e8 100644 (file)
--- a/program/src/rrd_graph.c
+++ b/program/src/rrd_graph.c
nlabels++;
if (im->second_axis_scale != 0){
char graph_label_right[100];
- double sval = im->ygrid_scale.gridstep*(double)i/im->second_axis_scale+im->second_axis_shift;
- if (!second_axis_magfact){
- double dummy = im->ygrid_scale.gridstep*(double)(sgrid+egrid)/2.0/im->second_axis_scale+im->second_axis_shift;
+ double sval = im->ygrid_scale.gridstep*(double)i*im->second_axis_scale+im->second_axis_shift;
+ if (im->second_axis_format[0] == '\0'){
+ if (!second_axis_magfact){
+ double dummy = im->ygrid_scale.gridstep*(double)(sgrid+egrid)/2.0*im->second_axis_scale+im->second_axis_shift;
auto_scale(im,&dummy,&second_axis_symb,&second_axis_magfact);
- }
- sval /= second_axis_magfact;
+ }
+ sval /= second_axis_magfact;
- if(MaxY < 10) {
- sprintf(graph_label_right,"%5.1f %s",sval,second_axis_symb);
- } else {
- sprintf(graph_label_right,"%5.0f %s",sval,second_axis_symb);
+ if(MaxY < 10) {
+ sprintf(graph_label_right,"%5.1f %s",sval,second_axis_symb);
+ } else {
+ sprintf(graph_label_right,"%5.0f %s",sval,second_axis_symb);
+ }
}
+ else {
+ sprintf(graph_label_right,im->second_axis_format,sval);
+ }
gfx_new_text ( im->canvas,
X1+7, Y0,
im->graph_col[GRC_FONT],
}
if (im->second_axis_scale != 0){
char graph_label_right[100];
- if (im->extra_flags & FORCE_UNITS_SI) {
- double sval = value/im->second_axis_scale+im->second_axis_shift;
- double mfac = 1;
- char *symb = "";
- auto_scale(im,&sval,&symb,&mfac);
- sprintf(graph_label_right,"%4.0f %s", sval,symb);
- }
- else {
- sprintf(graph_label_right,"%3.0e", value/im->second_axis_scale+im->second_axis_shift);
+ double sval = value*im->second_axis_scale+im->second_axis_shift;
+ if (im->second_axis_format[0] == '\0'){
+ if (im->extra_flags & FORCE_UNITS_SI) {
+ double mfac = 1;
+ char *symb = "";
+ auto_scale(im,&sval,&symb,&mfac);
+ sprintf(graph_label_right,"%4.0f %s", sval,symb);
+ }
+ else {
+ sprintf(graph_label_right,"%3.0e", sval);
+ }
}
+ else {
+ sprintf(graph_label_right,im->second_axis_format,sval);
+ }
+
gfx_new_text ( im->canvas,
X1+7, Y0,
im->graph_col[GRC_FONT],
im->second_axis_scale = 0; /* 0 disables it */
im->second_axis_shift = 0; /* no shift by default */
im->second_axis_legend[0] = '\0';
+ im->second_axis_format[0] = '\0';
im->title[0] = '\0';
im->watermark[0] = '\0';
im->minval = DNAN;
{"disable-rrdtool-tag", no_argument, 0, 1001},
{"right-axis", required_argument, 0, 1002},
{"right-axis-label", required_argument, 0, 1003},
+ {"right-axis-format", required_argument, 0, 1004},
{0,0,0,0}};
int option_index = 0;
int opt;
strncpy(im->second_axis_legend,optarg,150);
im->second_axis_legend[150]='\0';
break;
+ case 1004:
+ if (bad_format(optarg)){
+ rrd_set_error("use either %le or %lf formats");
+ return;
+ }
+ strncpy(im->second_axis_format,optarg,150);
+ im->second_axis_format[150]='\0';
+ break;
case 'v':
strncpy(im->ylegend,optarg,150);
im->ylegend[150]='\0';
index b39552a7ab8b951b67b35d023103b0fcefa145a8..56308bb8c293685f3e69303d98a7f26489d5de57 100644 (file)
--- a/program/src/rrd_graph.h
+++ b/program/src/rrd_graph.h
double second_axis_scale; /* relative to the first axis (0 to disable) */
double second_axis_shift; /* how much is it shifted vs the first axis */
char second_axis_legend[210]; /* label to put on the seond axis */
+ char second_axis_format[210]; /* format for the numbers on the scond axis */
double ygridstep; /* user defined step for y grid */
int ylabfact; /* every how many y grid shall a label be written ? */
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index bcb1d07cb8751700d4db7b7a3ccb35cee60a3ca2..45f9f93baa9a3abb2402f337efc762ba9d9f4a47 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
"\t\t[-y|--y-grid y-axis grid and label]\n"
"\t\t[-v|--vertical-label string] [-w|--width pixels]\n"
"\t\t[--right-axis scale:shift] [--right-axis-label label]\n"
+ "\t\t[--right-axis-format format]\n"
"\t\t[-h|--height pixels] [-o|--logarithmic]\n"
"\t\t[-u|--upper-limit value] [-z|--lazy]\n"
"\t\t[-l|--lower-limit value] [-r|--rigid]\n"