4. nmake test (You must have Visual C++ on the machine!)
-After these steps it generates the test files (gifs and rrds),
+After these steps it generates the test files (svgs and rrds),
and they seem to be good.
The real problem in the shared perl modul is the following:
# Perl will figure out which one is valid
'depend' => {'RRDs.c' => "../../src/.libs/librrd_private.a"},
'dynamic_lib' => {'OTHERLDFLAGS' => "$librrd -lm"},
- 'realclean' => {FILES => 't/demo?.rrd t/demo?.gif' }
+ 'realclean' => {FILES => 't/demo?.rrd t/demo?.png' }
);
$lastupdate = RRDs::last ...
B<RRDs::graph> returns an pointer to an ARRAY containing the x-size and y-size of the
-created gif and results of the PRINT arguments.
+created image and results of the PRINT arguments.
($averages,$xsize,$ysize) = RRDs::graph ...
- print "Gifsize: ${xsize}x${ysize}\n";
+ print "Imagesize: ${xsize}x${ysize}\n";
print "Averages: ", (join ", ", @$averages);
B<RRDs::info> returns a pointer to a hash. The keys of the hash
'INC' => '-I../../src/ -I../../libraries/freetype-2.0.5/include -I ../../libraries/libart_lgpl-2.3.7 -I ../../libraries/zlib-1.1.4 -I ../../libraries/libpng-1.2.0',
# change this path to refer to your libc.lib
'MYEXTLIB' => 'c:/vc98/lib/libc.lib ../../src/release/rrd.lib ../../libraries/libart_lgpl-2.3.7/release/libart.lib ../../libraries/zlib-1.1.4/release/zlib.lib ../../libraries/libpng-1.2.0\release\png.lib ../../libraries/freetype-2.0.5/release/freetype.lib',
- 'realclean' => {FILES => 't/demo?.rrd t/demo?.gif' },
+ 'realclean' => {FILES => 't/demo?.rrd t/demo?.png' },
($] ge '5.005') ? (
'AUTHOR' => 'Tobias Oetiker (oetiker@ee.ethz.ch)',
'ABSTRACT' => 'Round Robin Database Tool',
my $GRUNS = 4;
my $RRD1 = "demo1.rrd";
my $RRD2 = "demo2.rrd";
-my $GIF1 = "demo1.gif";
-my $GIF2 = "demo2.gif";
+my $PNG1 = "demo1.png";
+my $PNG2 = "demo2.png";
my $time = 30*int(time/30);
my $START = $time-$RUNS*$STEP;
die "$0: unable to update `$RRD2': $ERROR\n";
}
-print "* Creating $GRUNS graphs: $GIF1 & $GIF2\n\n";
+print "* Creating $GRUNS graphs: $PNG1 & $PNG2\n\n";
my $now = $time;
for (my $i=0;$i<$GRUNS;$i++) {
- my @rrd_gifs = ($RRD1, $GIF1, $RRD2, $GIF2);
- while (@rrd_gifs) {
- my $RRD = shift(@rrd_gifs);
- my $GIF = shift(@rrd_gifs);
- my ($graphret,$xs,$ys) = RRDs::graph $GIF, "--title", 'Test GRAPH',
+ my @rrd_pngs = ($RRD1, $PNG1, $RRD2, $PNG2);
+ while (@rrd_pngs) {
+ my $RRD = shift(@rrd_pngs);
+ my $PNG = shift(@rrd_pngs);
+ my ($graphret,$xs,$ys) = RRDs::graph $PNG, "--title", 'Test GRAPH',
"--vertical-label", 'Dummy Units', "--start", (-$RUNS*$STEP),
"DEF:alpha=$RRD:a:AVERAGE",
"DEF:beta=$RRD:b:AVERAGE",
if ($ERROR = RRDs::error) {
print "ERROR: $ERROR\n";
} else {
- print "GIF Size: ${xs}x${ys}\n";
+ print "Image Size: ${xs}x${ys}\n";
print "Graph Return:\n",(join "\n", @$graphret),"\n\n";
}
}
ln -s ../bindings/perl-piped/RRDp.pm .
index.html:
- rm index.html; ln -s rrdtool.html index.html
+ rm -f index.html; ln -s rrdtool.html index.html
link: RRDp.pm RRDs.pm index.html
=head2 Degrees Celcius vs. Degrees Fahrenheit
- rrdtool graph demo.gif --title="Demo Graph" \
+ rrdtool graph demo.png --title="Demo Graph" \
DEF:cel=demo.rrd:exhaust:AVERAGE \
CDEF:far=cel,32,-,0.55555,* \
LINE2:cel#00a000:"D. Celsius" \
=head2 Changing unknown into zero
- rrdtool graph demo.gif --title="Demo Graph" \
+ rrdtool graph demo.png --title="Demo Graph" \
DEF:idat1=interface1.rrd:ds0:AVERAGE \
DEF:idat2=interface2.rrd:ds0:AVERAGE \
DEF:odat1=interface1.rrd:ds1:AVERAGE \
S<[B<-h>|B<--height> I<pixels>]>
S<[B<-i>|B<--interlaced>]>
S<[B<-f>|B<--imginfo> I<formatstring>]>
-S<[B<-a>|B<--imgformat> B<GIF>|B<PNG>]>
+S<[B<-a>|B<--imgformat> B<SVG>|B<PNG>]>
S<[B<-z>|B<--lazy>]>
S<[B<-o>|B<--logarithmic>]>
S<[B<-u>|B<--upper-limit> I<value>]>
=item I<filename>
The name of the graph to generate. Since B<rrdtool> outputs
-GIFs and PNGs, it's recommended that the filename end in either
-F<.gif> or F<.png>. B<rrdtool> does not enforce this, however.
+SVGs and PNGs, it's recommended that the filename end in either
+F<.svg> or F<.png>. B<rrdtool> does not enforce this, however.
If the I<filename> is set to '-' the image file will be written
to standard out. All other output will get suppressed.
-PNG output is recommended, since it takes up to 40% less disk space
-and 20-30% less time to generate than a GIF file.
-
If no graph functions are called, the graph will not be created.
=item B<-s>|B<--start> I<seconds> (default end-1day)
=item B<-w>|B<--width> I<pixels> (default 400 pixel)
Width of the drawing area within the graph. This affects the size of the
-gif.
+image.
=item B<-h>|B<--height> I<pixels> (default 100 pixel)
Width of the drawing area within the graph. This affects the size of the
-gif.
+image.
=item B<-i>|B<--interlaced> (default: false)
-If you set this option, then the resulting GIF will be interlaced.
+If you set this option, then the resulting image will be interlaced.
Most web browsers display these incrementally as they load. If
-you do not use this option, the GIFs default to being progressive
+you do not use this option, the image defaults to being progressive
scanned. The only effect of this option is to control the format
-of the GIF on disk. It makes no changes to the layout or contents
+of the image on disk. It makes no changes to the layout or contents
of the graph.
=item B<-f>|B<--imginfo> I<formatstring>
--imginfo '<IMG SRC="/img/%s" WIDTH="%lu" HEIGHT="%lu" ALT="Demo">'
-=item B<-a>|B<--imgformat> B<GIF>|B<PNG> (default: GIF)
+=item B<-a>|B<--imgformat> B<SVG>|B<PNG> (default: PNG)
Allows you to produce PNG output from rrdtool.
=item B<-z>|B<--lazy> (default: false)
-Only generate the graph, if the current gif is out of date or not
+Only generate the graph, if the current image is out of date or not
existent.
=item B<-u>|B<--upper-limit> I<value> (default autoconfigure)
=head1 NOTE on Return Values
Whenever rrd_graph gets called, it prints a line telling the size of
-the gif it has just created to STDOUT. This line looks like this: XSIZExYSIZE.
+the image it has just created to STDOUT. This line looks like this: XSIZExYSIZE.
=head1 EXAMPLE 1
- rrdtool graph demo.gif --title="Demo Graph" \
+ rrdtool graph demo.png --title="Demo Graph" \
DEF:cel=demo.rrd:exhaust:AVERAGE \
"CDEF:far=cel,1.8,*,32,+"" \
LINE2:cel#00a000:"D. Celsius" \
aggregating interface data where the start dates of the data sets
doesn't match.
- rrdtool graph demo.gif --title="Demo Graph" \
+ rrdtool graph demo.png --title="Demo Graph" \
DEF:idat1=interface1.rrd:ds0:AVERAGE \
DEF:idat2=interface2.rrd:ds0:AVERAGE \
DEF:odat1=interface1.rrd:ds1:AVERAGE \
can be used to generate the graph of a time series with confidence bands and
failures.
- rrdtool graph example.gif \
+ rrdtool graph example.png \
DEF:obs=monitor.rrd:ifOutOctets:AVERAGE \
DEF:pred=monitor.rrd:ifOutOctets:HWPREDICT \
DEF:dev=monitor.rrd:ifOutOctets:DEVPREDICT \
I<Depriciated. Use the new form of this command in new scripts.>
This is the same as B<PRINT> but now it is printed inside the graph.
-See L<PRINT> for more information.
+See L<PRINT|rrdgraph/PRINT> for more information.
B<GPRINT:>I<vname>B<:>I<format>
This is the same as B<PRINT> but now it is printed inside the graph.
-See L<PRINT> for more information.
+See L<PRINT|rrdgraph/PRINT> for more information.
B<COMMENT:>I<text>
conseguidos a través de SNMP, y que los datos
sean el número de bytes (o bits) transferidos desde y hacia una red u
ordenador. RRDtool te permite crear una base de datos, guardar los
-datos en ellas, recuperarlos y crear gráficos en formato GIF o PNG,
+datos en ellas, recuperarlos y crear gráficos en formato SVG o PNG,
para mostrarlos en un navegador web. Esas imágenes dependen de los
datos que hayas guardado y pueden, por ejemplo, ser un sumario del
promedio de uso de la red, o los picos de tráfico que ocurrieron.
Prueba este comando:
- rrdtool graph speed.gif \
+ rrdtool graph speed.png \
--start 920804400 --end 920808000 \
DEF:myspeed=test.rrd:speed:AVERAGE \
LINE2:myspeed#FF0000
-Este comando crea speed.gif, un gráfico de los datos desde las
+Este comando crea speed.png, un gráfico de los datos desde las
12:00 hasta las 13:00. Contiene una definición de la variable myspeed
y define el color como rojo. Notarás que el gráfico no comienza
exactamente a las 12:00 sino a las 12:05, y es porque no tenemos datos
violeta #FF00FF (mezcla de rojo y azul)
gris #555555 (un tercio de cada uno de los colores)
-El archivo GIF que acabas de crear puede
+El archivo PNG que acabas de crear puede
verse con tu visor de archivos de imagen favorito. Los navegadores lo
mostrarán usando la URL
-``file://el/camino/de/directorios/hasta/speed.gif''
+``file://el/camino/de/directorios/hasta/speed.png''
=head2 Gráficos con un poco de matemática
Vamos a corregirlo. Podríamos recrear la base de datos con los
valores correctos, pero hay una forma mejor: ¡haciendo los cálculos
-mientras creamos el archivo gif!
+mientras creamos el archivo png!
- rrdtool graph speed2.gif \
+ rrdtool graph speed2.png \
--start 920804400 --end 920808000 \
--vertical-label m/s \
DEF:myspeed=test.rrd:speed:AVERAGE \
Cuando veas esta imagen, notarás que la ``m'' ha desaparecido, y
ahora tienes los resultados correctos. Además hemos añadido una
-etiqueta a la imagen. Apartando esto, el archivo GIF es el mismo.
+etiqueta a la imagen. Apartando esto, el archivo PNG es el mismo.
Las operaciones están en la sección del CDEF
y están escritas en Notación Polaca Inversa (Reverse Polish Notation o
valores en kilómetros, debemos compensar por ello, multiplicando por
100, por lo que al aplicar esta corrección nos queda valor * 3600.
-Ahora vamos a crear este gif, agreándole un poco más de magia...
+Ahora vamos a crear este png, agreándole un poco más de magia...
- rrdtool graph speed3.gif \
+ rrdtool graph speed3.png \
--start 920804400 --end 920808000 \
--vertical-label km/h \
DEF:myspeed=test.rrd:speed:AVERAGE \
=head2 Magia gráfica
Me gusta creer que virtualmente no hay limites para lo que RRDtool puede
-hacer con los datos. No voy a explicarlo en detalle, pero mira este GIF:
+hacer con los datos. No voy a explicarlo en detalle, pero mira este PNG:
- rrdtool graph speed4.gif \
+ rrdtool graph speed4.png \
--start 920804400 --end 920808000 \
--vertical-label km/h \
DEF:myspeed=test.rrd:speed:AVERAGE \
AREA:fast#550000:"Too fast" \
STACK:over#FF0000:"Over speed"
-Vamos a crear una página HTML simple para ver los tres archivos GIF:
+Vamos a crear una página HTML simple para ver los tres archivos PNG:
<HTML><HEAD><TITLE>Velocidad</TITLE></HEAD><BODY>
- <IMG src="speed2.gif" alt="Speed in meters per second">
+ <IMG src="speed2.png" alt="Speed in meters per second">
<BR>
- <IMG src="speed3.gif" alt="Speed in kilometers per hour">
+ <IMG src="speed3.png" alt="Speed in kilometers per hour">
<BR>
- <IMG src="speed4.gif" alt="Traveled too fast?">
+ <IMG src="speed4.png" alt="Traveled too fast?">
</BODY></HTML>
Guárdalo como ``speed.html'' o algo parecido, y examínalo con un navegador.
Ahora, todo lo que tienes que hacer es medir los datos regularmente
y actualizar la base de datos. Cuando quieras verlos, vuelve a crear
-los archivos GIF y asegúrate que se carguen de nuevo en tu navegador
+los archivos PNG y asegúrate que se carguen de nuevo en tu navegador
(Nota: presionar el botón de "refrescar" puede no ser suficiente; en
particular, Netscape tiene un problema al respecto, por lo que
necesitaras darle al botón mientras presionas la tecla de mayúsculas.
Luego, tras recoger datos por un día, crea una imagen, usando:
- rrdtool graph myrouter-day.gif --start -86400 \
+ rrdtool graph myrouter-day.png --start -86400 \
DEF:inoctets=myrouter.rrd:input:AVERAGE \
DEF:outoctets=myrouter.rrd:output:AVERAGE \
AREA:inoctets#00FF00:"In traffic" \
978303300:2400:6:600:2400 \
978303600:2700:4:600:2700 \
978303900:3000:2:1200:3000
- rrdtool graph all1.gif -s 978300600 -e 978304200 -h 400 \
+ rrdtool graph all1.png -s 978300600 -e 978304200 -h 400 \
DEF:linea=all.rrd:a:AVERAGE LINE3:linea#FF0000:"Line A" \
DEF:lineb=all.rrd:b:AVERAGE LINE3:lineb#00FF00:"Line B" \
DEF:linec=all.rrd:c:AVERAGE LINE3:linec#0000FF:"Line C" \
- Línea C: u u 2 2 2 0 -2 -6 2 0 2 u
- Línea D: u 1 2 3 4 5 6 7 8 9 10 u
-Si tu archivo GIF muestra todo esto, has
+Si tu archivo PNG muestra todo esto, has
entrado los datos correctamente, tu programa RRDtool está funcionando
bien, el visor de gráficos no te engaña y hemos entrado en el 2000 sin
problemas :) Puedes probar el mismo ejemplo cuatro veces, una por cada línea.
rrdtool update seconds2.rrd \
920805000:000 920805300:300 920805603:603 920805900:900
- rrdtool graph seconds1.gif \
+ rrdtool graph seconds1.png \
--start 920804700 --end 920806200 \
--height 200 \
--upper-limit 1.05 --lower-limit 0.95 --rigid \
CDEF:unknown=seconds,UN \
LINE2:seconds#0000FF \
AREA:unknown#FF0000
- rrdtool graph seconds2.gif \
+ rrdtool graph seconds2.png \
--start 920804700 --end 920806200 \
--height 200 \
--upper-limit 1.05 --lower-limit 0.95 --rigid \
<H1>This is NOT traffic</H1>
-<P><RRD::GRAPH cgi-demo1.gif
+<P><RRD::GRAPH cgi-demo1.png
--lower-limit 0
--start 'end-10h'
--title "Graph in Localtime <RRD::TIME::NOW %c>"
</P>
<P><RRD::SETENV TZ UTC>
- <RRD::GRAPH cgi-demo2.gif
+ <RRD::GRAPH cgi-demo2.png
--lower-limit 0
--start 'end-10h'
--title "Graph in UTC"
<H1>This is NOT traffic</H1>
-<P><RRD::GRAPH cgi-demo1.gif
+<P><RRD::GRAPH cgi-demo1.png
--lower-limit 0
--start 'end-10h'
--title "Graph in Localtime <RRD::TIME::NOW %c>"
</P>
<P><RRD::SETENV TZ UTC>
- <RRD::GRAPH cgi-demo2.gif
+ <RRD::GRAPH cgi-demo2.png
--lower-limit 0
--start 'end-10h'
--title "Graph in UTC"
-#! /bin/perl
+#! /usr/bin/perl
#makes things work when run without install
use lib qw( ../bindings/perl-piped/blib/lib ../lib/perl );
$RUNS = 12*24*30*6;
$GRUNS = 20;
$RRD = "piped-demo.rrd";
-$GIF = "piped-demo.gif";
+$SVG = "piped-demo.svg";
$PNG = "piped-demo.png";
# some magic to find the correct rrdtol executable
print "\n";
# creating some graphs
-print "* Creating $GRUNS GIF graphs: $GIF\n\n";
+print "* Creating $GRUNS SVG graphs: $SVG\n\n";
$now = time;
for ($i=0;$i<$GRUNS;$i++) {
-RRDp::cmd "graph $GIF ", "--title 'Test GRAPH' ",
- "--height 150 --vertical-label 'Dummy Units' ".
+RRDp::cmd "graph $SVG ", "--title 'Test GRAPH' ",
+ "--imgformat SVG --height 150 --vertical-label 'Dummy Units' ".
"--start now".(-$RUNS*$STEP),
"--color ARROW#bfbfbf",
"DEF:alpha=$RRD:in:AVERAGE",
$RUNS = 12*24*30*6;
$GRUNS = 20;
$RRD = "piped-demo.rrd";
-$GIF = "piped-demo.gif";
+$SVG = "piped-demo.svg";
$PNG = "piped-demo.png";
# some magic to find the correct rrdtol executable
print "\n";
# creating some graphs
-print "* Creating $GRUNS GIF graphs: $GIF\n\n";
+print "* Creating $GRUNS SVG graphs: $SVG\n\n";
$now = time;
for ($i=0;$i<$GRUNS;$i++) {
-RRDp::cmd "graph $GIF ", "--title 'Test GRAPH' ",
- "--height 150 --vertical-label 'Dummy Units' ".
+RRDp::cmd "graph $SVG ", "--title 'Test GRAPH' ",
+ "--imgformat SVG --height 150 --vertical-label 'Dummy Units' ".
"--start now".(-$RUNS*$STEP),
"--color ARROW#bfbfbf",
"DEF:alpha=$RRD:in:AVERAGE",
-#! /bin/perl
+#! /usr/bin/perl
END {
my $GRUNS = 4;
my $RRD1 = "shared-demo.rrd";
my $RRD2 = "shared-demob.rrd";
-my $GIF1 = "shared-demo1.gif";
-my $GIF2 = "shared-demo2.gif";
+my $PNG1 = "shared-demo1.png";
+my $PNG2 = "shared-demo2.png";
my $time = 30*int(time/30);
my $START = $time-$RUNS*$STEP;
die "$0: unable to update `$RRD2': $ERROR\n";
}
-print "* Creating $GRUNS graphs: $GIF1 & $GIF2\n\n";
+print "* Creating $GRUNS graphs: $PNG1 & $PNG2\n\n";
my $now = $time;
for (my $i=0;$i<$GRUNS;$i++) {
- my @rrd_gifs = ($RRD1, $GIF1, $RRD2, $GIF2);
- while (@rrd_gifs) {
- my $RRD = shift(@rrd_gifs);
- my $GIF = shift(@rrd_gifs);
- my ($graphret,$xs,$ys) = RRDs::graph $GIF, "--title", 'Test GRAPH',
+ my @rrd_pngs = ($RRD1, $PNG1, $RRD2, $PNG2);
+ while (@rrd_pngs) {
+ my $RRD = shift(@rrd_pngs);
+ my $PNG = shift(@rrd_pngs);
+ my ($graphret,$xs,$ys) = RRDs::graph $PNG, "--title", 'Test GRAPH',
'--base', '1024',
"--vertical-label", 'Dummy Units', "--start", (-$RUNS*$STEP),
"--end", $time,
- "--interlace", "--imgformat","GIF",
+ "--interlace", "--imgformat","PNG",
"DEF:alpha=$RRD:a:AVERAGE",
"DEF:beta=$RRD:b:AVERAGE",
"DEF:gamma=$RRD:c:AVERAGE",
if ($ERROR = RRDs::error) {
print "ERROR: $ERROR\n";
} else {
- print "GIF Size: ${xs}x${ys}\n";
+ print "Image Size: ${xs}x${ys}\n";
print "Graph Return:\n",(join "\n", @$graphret),"\n\n";
}
}
my $GRUNS = 4;
my $RRD1 = "shared-demo.rrd";
my $RRD2 = "shared-demob.rrd";
-my $GIF1 = "shared-demo1.gif";
-my $GIF2 = "shared-demo2.gif";
+my $PNG1 = "shared-demo1.png";
+my $PNG2 = "shared-demo2.png";
my $time = 30*int(time/30);
my $START = $time-$RUNS*$STEP;
die "$0: unable to update `$RRD2': $ERROR\n";
}
-print "* Creating $GRUNS graphs: $GIF1 & $GIF2\n\n";
+print "* Creating $GRUNS graphs: $PNG1 & $PNG2\n\n";
my $now = $time;
for (my $i=0;$i<$GRUNS;$i++) {
- my @rrd_gifs = ($RRD1, $GIF1, $RRD2, $GIF2);
- while (@rrd_gifs) {
- my $RRD = shift(@rrd_gifs);
- my $GIF = shift(@rrd_gifs);
- my ($graphret,$xs,$ys) = RRDs::graph $GIF, "--title", 'Test GRAPH',
+ my @rrd_pngs = ($RRD1, $PNG1, $RRD2, $PNG2);
+ while (@rrd_pngs) {
+ my $RRD = shift(@rrd_pngs);
+ my $PNG = shift(@rrd_pngs);
+ my ($graphret,$xs,$ys) = RRDs::graph $PNG, "--title", 'Test GRAPH',
'--base', '1024',
"--vertical-label", 'Dummy Units', "--start", (-$RUNS*$STEP),
"--end", $time,
- "--interlace", "--imgformat","GIF",
+ "--interlace", "--imgformat","PNG",
"DEF:alpha=$RRD:a:AVERAGE",
"DEF:beta=$RRD:b:AVERAGE",
"DEF:gamma=$RRD:c:AVERAGE",
if ($ERROR = RRDs::error) {
print "ERROR: $ERROR\n";
} else {
- print "GIF Size: ${xs}x${ys}\n";
+ print "Image Size: ${xs}x${ys}\n";
print "Graph Return:\n",(join "\n", @$graphret),"\n\n";
}
}
}
}
+static
char* rrdstrip(char *buf){
char *start;
if (buf == NULL) return NULL;
}
/* scan aLine until an unescaped '>' arives */
+static
char* scanargs(char *aLine, long *argc, char ***args)
{
char *getP, *putP;
/* create a new line */
gfx_node_t *gfx_new_line(gfx_canvas_t *canvas,
- double x0, double y0,
- double x1, double y1,
+ double X0, double Y0,
+ double X1, double Y1,
double width, gfx_color_t color){
- return gfx_new_dashed_line(canvas, x0, y0, x1, y1, width, color, 0, 0);
+ return gfx_new_dashed_line(canvas, X0, Y0, X1, Y1, width, color, 0, 0);
}
gfx_node_t *gfx_new_dashed_line(gfx_canvas_t *canvas,
- double x0, double y0,
- double x1, double y1,
+ double X0, double Y0,
+ double X1, double Y1,
double width, gfx_color_t color,
double dash_on, double dash_off){
if (node == NULL) return NULL;
vec = art_new(ArtVpath, 3);
if (vec == NULL) return NULL;
- vec[0].code = ART_MOVETO_OPEN; vec[0].x=x0+LINEOFFSET; vec[0].y=y0+LINEOFFSET;
- vec[1].code = ART_LINETO; vec[1].x=x1+LINEOFFSET; vec[1].y=y1+LINEOFFSET;
+ vec[0].code = ART_MOVETO_OPEN; vec[0].x=X0+LINEOFFSET; vec[0].y=Y0+LINEOFFSET;
+ vec[1].code = ART_LINETO; vec[1].x=X1+LINEOFFSET; vec[1].y=Y1+LINEOFFSET;
vec[2].code = ART_END;
node->points = 3;
/* create a new area */
gfx_node_t *gfx_new_area (gfx_canvas_t *canvas,
- double x0, double y0,
- double x1, double y1,
- double x2, double y2,
+ double X0, double Y0,
+ double X1, double Y1,
+ double X2, double Y2,
gfx_color_t color) {
gfx_node_t *node;
if (node == NULL) return NULL;
vec = art_new(ArtVpath, 5);
if (vec == NULL) return NULL;
- vec[0].code = ART_MOVETO; vec[0].x=x0; vec[0].y=y0;
- vec[1].code = ART_LINETO; vec[1].x=x1; vec[1].y=y1;
- vec[2].code = ART_LINETO; vec[2].x=x2; vec[2].y=y2;
- vec[3].code = ART_LINETO; vec[3].x=x0; vec[3].y=y0;
+ vec[0].code = ART_MOVETO; vec[0].x=X0; vec[0].y=Y0;
+ vec[1].code = ART_LINETO; vec[1].x=X1; vec[1].y=Y1;
+ vec[2].code = ART_LINETO; vec[2].x=X2; vec[2].y=Y2;
+ vec[3].code = ART_LINETO; vec[3].x=X0; vec[3].y=Y0;
vec[4].code = ART_END;
node->points = 5;
double x, double y){
if (node == NULL) return 1;
if (node->type == GFX_AREA) {
- double x0 = node->path[0].x;
- double y0 = node->path[0].y;
+ double X0 = node->path[0].x;
+ double Y0 = node->path[0].y;
node->points -= 2;
art_vpath_add_point (&(node->path),
&(node->points),
&(node->points),
&(node->points_max),
ART_LINETO,
- x0,y0);
+ X0,Y0);
art_vpath_add_point (&(node->path),
&(node->points),
&(node->points_max),
case GFX_H_RIGHT: pen_x -= text_width; break;
case GFX_H_CENTER: pen_x -= text_width / 2.0; break;
case GFX_H_LEFT: break;
+ case GFX_H_NULL: break;
}
switch(node->valign){
case GFX_V_TOP: pen_y += text_height; break;
case GFX_V_CENTER: pen_y += text_height / 2.0; break;
case GFX_V_BOTTOM: break;
+ case GFX_V_NULL: break;
}
glyph_index=0;
/* create a new line */
gfx_node_t *gfx_new_line (gfx_canvas_t *canvas,
- double x0, double y0,
- double x1, double y1,
+ double X0, double Y0,
+ double X1, double Y1,
double width, gfx_color_t color);
gfx_node_t *gfx_new_dashed_line (gfx_canvas_t *canvas,
- double x0, double y0,
- double x1, double y1,
+ double X0, double Y0,
+ double X1, double Y1,
double width, gfx_color_t color,
double dash_on, double dash_off);
/* create a new area */
gfx_node_t *gfx_new_area (gfx_canvas_t *canvas,
- double x0, double y0,
- double x1, double y1,
- double x2, double y2,
+ double X0, double Y0,
+ double X1, double Y1,
+ double X2, double Y2,
gfx_color_t color);
/* add a point to a line or to an area */
#ifdef WIN32
#include <io.h>
#include <fcntl.h>
-#define RRD_DEFAULT_FONT "c:/winnt/fonts/COUR.TTF"
#endif
#include "rrd_graph.h"
}
}
break;
- case GF_COMMENT:
case GF_LINE:
case GF_AREA:
case GF_TICK:
case GF_VRULE:
graphelement = 1;
break;
+ case GF_COMMENT:
case GF_DEF:
case GF_CDEF:
case GF_VDEF:
int border = im->text_prop[TEXT_PROP_LEGEND].size*2.0;
int fill=0, fill_last;
int leg_c = 0;
- int leg_x = border, leg_y = im->ygif;
+ int leg_x = border, leg_y = im->yimg;
int leg_cc;
int glue = 0;
int i,ii, mark = 0;
if (i == im->gdes_c -1 ) prt_fctn ='l';
/* is it time to place the legends ? */
- if (fill > im->xgif - 2*border){
+ if (fill > im->ximg - 2*border){
if (leg_c > 1) {
/* go back one */
i--;
if (prt_fctn != '\0'){
leg_x = border;
if (leg_c >= 2 && prt_fctn == 'j') {
- glue = (im->xgif - fill - 2* border) / (leg_c-1);
+ glue = (im->ximg - fill - 2* border) / (leg_c-1);
} else {
glue = 0;
}
- if (prt_fctn =='c') leg_x = (im->xgif - fill) / 2.0;
- if (prt_fctn =='r') leg_x = im->xgif - fill - border;
+ if (prt_fctn =='c') leg_x = (im->ximg - fill) / 2.0;
+ if (prt_fctn =='r') leg_x = im->ximg - fill - border;
for(ii=mark;ii<=i;ii++){
if(im->gdes[ii].legend[0]=='\0')
mark = ii;
}
}
- im->ygif = leg_y;
+ im->yimg = leg_y;
free(legspace);
}
return 0;
double gridstep;
double scaledstep;
char graph_label[100];
- double x0,x1,y0;
+ double X0,X1,Y0;
int labfact,gridind;
int decimals, fractionals;
char labfmt[64];
labfact = im->ylabfact;
}
- x0=im->xorigin;
- x1=im->xorigin+im->xsize;
+ X0=im->xorigin;
+ X1=im->xorigin+im->xsize;
sgrid = (int)( im->minval / gridstep - 1);
egrid = (int)( im->maxval / gridstep + 1);
scaledstep = gridstep/im->magfact;
for (i = sgrid; i <= egrid; i++){
- y0=ytr(im,gridstep*i);
- if ( y0 >= im->yorigin-im->ysize
- && y0 <= im->yorigin){
+ Y0=ytr(im,gridstep*i);
+ if ( Y0 >= im->yorigin-im->ysize
+ && Y0 <= im->yorigin){
if(i % labfact == 0){
if (i==0 || im->symbol == ' ') {
if(scaledstep < 1){
}
gfx_new_text ( im->canvas,
- x0-im->text_prop[TEXT_PROP_AXIS].size/1.5, y0,
+ X0-im->text_prop[TEXT_PROP_AXIS].size/1.5, Y0,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
im->tabwidth, 0.0, GFX_H_RIGHT, GFX_V_CENTER,
graph_label );
gfx_new_line ( im->canvas,
- x0-2,y0,
- x1+2,y0,
+ X0-2,Y0,
+ X1+2,Y0,
MGRIDWIDTH, im->graph_col[GRC_MGRID] );
} else {
gfx_new_line ( im->canvas,
- x0-1,y0,
- x1+1,y0,
+ X0-1,Y0,
+ X1+1,Y0,
GRIDWIDTH, im->graph_col[GRC_GRID] );
}
int ii,i;
int minoridx=0, majoridx=0;
char graph_label[100];
- double x0,x1,y0;
+ double X0,X1,Y0;
double value, pixperstep, minstep;
/* find grid spaceing */
if(pixperstep > 2 * im->text_prop[TEXT_PROP_LEGEND].size){majoridx = i;}
}
- x0=im->xorigin;
- x1=im->xorigin+im->xsize;
+ X0=im->xorigin;
+ X1=im->xorigin+im->xsize;
/* paint minor grid */
for (value = pow((double)10, log10(im->minval)
- fmod(log10(im->minval),log10(yloglab[minoridx][0])));
if (value < im->minval) continue;
i=0;
while(yloglab[minoridx][++i] > 0){
- y0 = ytr(im,value * yloglab[minoridx][i]);
- if (y0 <= im->yorigin - im->ysize) break;
+ Y0 = ytr(im,value * yloglab[minoridx][i]);
+ if (Y0 <= im->yorigin - im->ysize) break;
gfx_new_line ( im->canvas,
- x0-1,y0,
- x1+1,y0,
+ X0-1,Y0,
+ X1+1,Y0,
GRIDWIDTH, im->graph_col[GRC_GRID] );
}
}
if (value < im->minval) continue;
i=0;
while(yloglab[majoridx][++i] > 0){
- y0 = ytr(im,value * yloglab[majoridx][i]);
- if (y0 <= im->yorigin - im->ysize) break;
+ Y0 = ytr(im,value * yloglab[majoridx][i]);
+ if (Y0 <= im->yorigin - im->ysize) break;
gfx_new_line ( im->canvas,
- x0-2,y0,
- x1+2,y0,
+ X0-2,Y0,
+ X1+2,Y0,
MGRIDWIDTH, im->graph_col[GRC_MGRID] );
sprintf(graph_label,"%3.0e",value * yloglab[majoridx][i]);
gfx_new_text ( im->canvas,
- x0-im->text_prop[TEXT_PROP_AXIS].size/1.5, y0,
+ X0-im->text_prop[TEXT_PROP_AXIS].size/1.5, Y0,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
time_t ti, tilab;
long factor;
char graph_label[100];
- double x0,y0,y1; /* points for filled graph and more*/
+ double X0,Y0,Y1; /* points for filled graph and more*/
/* the type of time grid is determined by finding
}
/* y coords are the same for every line ... */
- y0 = im->yorigin;
- y1 = im->yorigin-im->ysize;
+ Y0 = im->yorigin;
+ Y1 = im->yorigin-im->ysize;
/* paint the minor grid */
){
/* are we inside the graph ? */
if (ti < im->start || ti > im->end) continue;
- x0 = xtr(im,ti);
- gfx_new_line(im->canvas,x0,y0+1, x0,y1-1,GRIDWIDTH, im->graph_col[GRC_GRID]);
+ X0 = xtr(im,ti);
+ gfx_new_line(im->canvas,X0,Y0+1, X0,Y1-1,GRIDWIDTH, im->graph_col[GRC_GRID]);
}
){
/* are we inside the graph ? */
if (ti < im->start || ti > im->end) continue;
- x0 = xtr(im,ti);
- gfx_new_line(im->canvas,x0,y0+2, x0,y1-2,MGRIDWIDTH, im->graph_col[GRC_MGRID]);
+ X0 = xtr(im,ti);
+ gfx_new_line(im->canvas,X0,Y0+2, X0,Y1-2,MGRIDWIDTH, im->graph_col[GRC_MGRID]);
}
/* paint the labels below the graph */
# error "your libc has no strftime I guess we'll abort the exercise here."
#endif
gfx_new_text ( im->canvas,
- xtr(im,tilab), y0+im->text_prop[TEXT_PROP_AXIS].size/1.5,
+ xtr(im,tilab), Y0+im->text_prop[TEXT_PROP_AXIS].size/1.5,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
gfx_new_area ( im->canvas,
im->xorigin+im->xsize+3, im->yorigin-3,
im->xorigin+im->xsize+3, im->yorigin+4,
- im->xorigin+im->xsize+8, im->yorigin+0.5, // LINEOFFSET
+ im->xorigin+im->xsize+8, im->yorigin+0.5, /* LINEOFFSET */
im->graph_col[GRC_ARROW]);
{
long i;
int res=0;
- double x0,y0; /* points for filled graph and more*/
+ double X0,Y0; /* points for filled graph and more*/
gfx_node_t *node;
/* draw 3d border */
- node = gfx_new_area (im->canvas, 0,im->ygif,
- 2,im->ygif-2,
+ node = gfx_new_area (im->canvas, 0,im->yimg,
+ 2,im->yimg-2,
2,2,im->graph_col[GRC_SHADEA]);
- gfx_add_point( node , im->xgif - 2, 2 );
- gfx_add_point( node , im->xgif, 0 );
+ gfx_add_point( node , im->ximg - 2, 2 );
+ gfx_add_point( node , im->ximg, 0 );
gfx_add_point( node , 0,0 );
-/* gfx_add_point( node , 0,im->ygif ); */
+/* gfx_add_point( node , 0,im->yimg ); */
- node = gfx_new_area (im->canvas, 2,im->ygif-2,
- im->xgif-2,im->ygif-2,
- im->xgif - 2, 2,
+ node = gfx_new_area (im->canvas, 2,im->yimg-2,
+ im->ximg-2,im->yimg-2,
+ im->ximg - 2, 2,
im->graph_col[GRC_SHADEB]);
- gfx_add_point( node , im->xgif,0);
- gfx_add_point( node , im->xgif,im->ygif);
- gfx_add_point( node , 0,im->ygif);
-/* gfx_add_point( node , 0,im->ygif ); */
+ gfx_add_point( node , im->ximg,0);
+ gfx_add_point( node , im->ximg,im->yimg);
+ gfx_add_point( node , 0,im->yimg);
+/* gfx_add_point( node , 0,im->yimg ); */
if (im->draw_x_grid == 1 )
/* dont draw horizontal grid if there is no min and max val */
if (! res ) {
char *nodata = "No Data found";
- gfx_new_text(im->canvas,im->xgif/2, (2*im->yorigin-im->ysize) / 2,
+ gfx_new_text(im->canvas,im->ximg/2, (2*im->yorigin-im->ysize) / 2,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
/* graph title */
gfx_new_text( im->canvas,
- im->xgif/2, im->text_prop[TEXT_PROP_TITLE].size,
+ im->ximg/2, im->text_prop[TEXT_PROP_TITLE].size,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_TITLE].font,
im->text_prop[TEXT_PROP_TITLE].size, im->tabwidth, 0.0,
continue;
/* im->gdes[i].leg_y is the bottom of the legend */
- x0 = im->gdes[i].leg_x;
- y0 = im->gdes[i].leg_y;
+ X0 = im->gdes[i].leg_x;
+ Y0 = im->gdes[i].leg_y;
/* Box needed? */
if ( im->gdes[i].gf != GF_GPRINT
&& im->gdes[i].gf != GF_COMMENT) {
boxV = boxH;
node = gfx_new_area(im->canvas,
- x0,y0-boxV,
- x0,y0,
- x0+boxH,y0,
+ X0,Y0-boxV,
+ X0,Y0,
+ X0+boxH,Y0,
im->gdes[i].col);
- gfx_add_point ( node, x0+boxH, y0-boxV );
+ gfx_add_point ( node, X0+boxH, Y0-boxV );
node = gfx_new_line(im->canvas,
- x0,y0-boxV, x0,y0,
+ X0,Y0-boxV, X0,Y0,
1,0x000000FF);
- gfx_add_point(node,x0+boxH,y0);
- gfx_add_point(node,x0+boxH,y0-boxV);
+ gfx_add_point(node,X0+boxH,Y0);
+ gfx_add_point(node,X0+boxH,Y0-boxV);
gfx_close_path(node);
- x0 += boxH / 1.25 * 2;
+ X0 += boxH / 1.25 * 2;
}
- gfx_new_text ( im->canvas, x0, y0,
+ gfx_new_text ( im->canvas, X0, Y0,
im->graph_col[GRC_FONT],
im->text_prop[TEXT_PROP_AXIS].font,
im->text_prop[TEXT_PROP_AXIS].size,
int lazy_check(image_desc_t *im){
FILE *fd = NULL;
int size = 1;
- struct stat gifstat;
+ struct stat imgstat;
if (im->lazy == 0) return 0; /* no lazy option */
- if (stat(im->graphfile,&gifstat) != 0)
+ if (stat(im->graphfile,&imgstat) != 0)
return 0; /* can't stat */
/* one pixel in the existing graph is more then what we would
change here ... */
- if (time(NULL) - gifstat.st_mtime >
+ if (time(NULL) - imgstat.st_mtime >
(im->end - im->start) / im->xsize)
return 0;
if ((fd = fopen(im->graphfile,"rb")) == NULL)
return 0; /* the file does not exist */
switch (im->canvas->imgformat) {
case IF_PNG:
- size = PngSize(fd,&(im->xgif),&(im->ygif));
+ size = PngSize(fd,&(im->ximg),&(im->yimg));
break;
default:
size = 1;
Xmain =0, Ymain =0,
Xpie =0, Ypie =0,
Xxlabel =0, Yxlabel =0,
+#if 0
Xlegend =0, Ylegend =0,
+#endif
Xspacing =10, Yspacing =10;
if (im->ylegend[0] != '\0') {
** forget about it at all; the legend will have to fit in the
** size already allocated.
*/
- im->xgif = Xylabel + Xmain + Xpie + Xspacing;
- if (Xmain) im->xgif += Xspacing;
- if (Xpie) im->xgif += Xspacing;
+ im->ximg = Xylabel + Xmain + Xpie + Xspacing;
+ if (Xmain) im->ximg += Xspacing;
+ if (Xpie) im->ximg += Xspacing;
im->xorigin = Xspacing + Xylabel;
- if (Xtitle > im->xgif) im->xgif = Xtitle;
+ if (Xtitle > im->ximg) im->ximg = Xtitle;
if (Xvertical) {
- im->xgif += Xvertical;
+ im->ximg += Xvertical;
im->xorigin += Xvertical;
}
xtr(im,0);
*/
/* reserve space for main and/or pie */
- im->ygif = Ymain + Yxlabel;
- if (im->ygif < Ypie) im->ygif = Ypie;
- im->yorigin = im->ygif - Yxlabel;
+ im->yimg = Ymain + Yxlabel;
+ if (im->yimg < Ypie) im->yimg = Ypie;
+ im->yorigin = im->yimg - Yxlabel;
/* reserve space for the title *or* some padding above the graph */
if (Ytitle) {
- im->ygif += Ytitle;
+ im->yimg += Ytitle;
im->yorigin += Ytitle;
} else {
- im->ygif += Yspacing;
+ im->yimg += Yspacing;
im->yorigin += Yspacing;
}
/* reserve space for padding below the graph */
- im->ygif += Yspacing;
+ im->yimg += Yspacing;
ytr(im,DNAN);
/* Determine where to place the legends onto the image.
- ** Adjust im->ygif to match the space requirements.
+ ** Adjust im->yimg to match the space requirements.
*/
if(leg_place(im)==-1)
return -1;
/* last of three steps: check total height of image */
- if (im->ygif < Yvertical) im->ygif = Yvertical;
+ if (im->yimg < Yvertical) im->yimg = Yvertical;
#if 0
- if (Xlegend > im->xgif) {
- im->xgif = Xlegend;
+ if (Xlegend > im->ximg) {
+ im->ximg = Xlegend;
/* reposition Pie */
#endif
** padding.
*/
if (elements) {
- im->pie_x = im->xgif - Xspacing - Xpie/2;
+ im->pie_x = im->ximg - Xspacing - Xpie/2;
im->pie_y = im->yorigin-Ymain+Ypie/2;
} else {
- im->pie_x = im->xgif/2;
+ im->pie_x = im->ximg/2;
im->pie_y = im->yorigin-Ypie/2;
}
node=gfx_new_area ( im->canvas,
0, 0,
- im->xgif, 0,
- im->xgif, im->ygif,
+ im->ximg, 0,
+ im->ximg, im->yimg,
im->graph_col[GRC_BACK]);
- gfx_add_point(node,0, im->ygif);
+ gfx_add_point(node,0, im->yimg);
if (piechart != 2) {
node=gfx_new_area ( im->canvas,
return (-1);
}
}
- gfx_render (im->canvas,im->xgif,im->ygif,0x0,fo);
+ gfx_render (im->canvas,im->ximg,im->yimg,0x0,fo);
if (strcmp(im->graphfile,"-") != 0)
fclose(fo);
return 0;
** Also, if needed, print a line with information about the image.
*/
- *xsize=im.xgif;
- *ysize=im.ygif;
+ *xsize=im.ximg;
+ *ysize=im.yimg;
if (im.imginfo) {
char *filename;
if (!(*prdata)) {
filename--;
}
- sprintf((*prdata)[0],im.imginfo,filename,(long)(im.canvas->zoom*im.xgif),(long)(im.canvas->zoom*im.ygif));
+ sprintf((*prdata)[0],im.imginfo,filename,(long)(im.canvas->zoom*im.ximg),(long)(im.canvas->zoom*im.yimg));
}
im_free(&im);
return 0;
int i;
im->xlab_user.minsec = -1;
- im->xgif=0;
- im->ygif=0;
+ im->ximg=0;
+ im->yimg=0;
im->xsize = 400;
im->ysize = 100;
im->step = 0;
values outside */
char* imginfo; /* construct an <IMG ... tag and return
as first retval */
- int lazy; /* only update the gif if there is reasonable
- probablility that the existing one is out of date */
+ int lazy; /* only update the image if there is
+ reasonable probablility that the
+ existing one is out of date */
int logarithmic; /* scale the yaxis logarithmic */
/* status information */
long xorigin,yorigin;/* where is (0,0) of the graph */
long pie_x,pie_y; /* where is the centerpoint */
- long xgif,ygif; /* total size of the gif */
+ long ximg,yimg; /* total size of the image */
double magfact; /* numerical magnitude*/
long base; /* 1000 or 1024 depending on what we graph */
char symbol; /* magnitude symbol for y-axis */
/* HELPER FUNCTIONS */
-int GifSize(FILE *, long *, long *);
-int PngSize(FILE *, long *, long *);
int PngSize(FILE *, long *, long *);
int rrd_create_fn(char *file_name, rrd_t *rrd);