summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e5e436c)
raw | patch | inline | side by side (parent: e5e436c)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 3 Mar 2006 23:11:55 +0000 (23:11 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 3 Mar 2006 23:11:55 +0000 (23:11 +0000) |
* make TICK work for negative fractions
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@769 a5681a0c-68f1-0310-ab6d-d61299d08faa
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@769 a5681a0c-68f1-0310-ab6d-d61299d08faa
doc/rrdgraph_graph.pod | patch | blob | history | |
src/rrd_graph.c | patch | blob | history | |
src/rrd_graph_helper.c | patch | blob | history |
diff --git a/doc/rrdgraph_graph.pod b/doc/rrdgraph_graph.pod
index bf683ed5397f137ed843813d50f3a094430f48a2..754e703e3a19ddd58bf6e693411e9f925c546a4a 100644 (file)
--- a/doc/rrdgraph_graph.pod
+++ b/doc/rrdgraph_graph.pod
Plot a tick mark (a vertical line) for each value of I<vname> that is
non-zero and not *UNKNOWN*. The I<fraction> argument specifies the length of
the tick mark as a fraction of the y-axis; the default value is 0.1 (10% of
-the axis). Note that the color specification is not optional. The TICK marks
-start at y==0 if it is inside the graph. Else they start at the border that
-is closer to 0.
+the axis). Note that the color specification is not optional. The TICK marks normaly
+start at the lower edge of the graphing area. If the fraction is negative they start
+at the upper border of the graphing area.
=item B<SHIFT>B<:>I<vname>B<:>I<offset>
diff --git a/src/rrd_graph.c b/src/rrd_graph.c
index a762b25bfa4bac99b3c2404fa48fcaff70e94710..7adf04a8324ce1647f0497068cb4233a2f4939a4 100644 (file)
--- a/src/rrd_graph.c
+++ b/src/rrd_graph.c
conv_if(VRULE,GF_VRULE)
conv_if(LINE,GF_LINE)
conv_if(AREA,GF_AREA)
- conv_if(STACK,GF_STACK)
+ conv_if(STACK,GF_STACK)
conv_if(TICK,GF_TICK)
conv_if(DEF,GF_DEF)
conv_if(CDEF,GF_CDEF)
for(i=0;i<im->gdes_c;i++) {
if((im->gdes[i].gf==GF_LINE) ||
(im->gdes[i].gf==GF_AREA) ||
- (im->gdes[i].gf==GF_TICK) ||
- (im->gdes[i].gf==GF_STACK)) {
+ (im->gdes[i].gf==GF_TICK)) {
if((im->gdes[i].p_data = malloc((im->xsize +1)
* sizeof(rrd_value_t)))==NULL){
rrd_set_error("malloc data_proc");
case GF_TICK:
if (!im->gdes[ii].stack)
paintval = 0.0;
- case GF_STACK:
value = im->gdes[ii].yrule;
if (isnan(value) || (im->gdes[ii].gf == GF_TICK)) {
/* The time of the data doesn't necessarily match
im->gdes[ii].p_data[i] = DNAN;
}
break;
+ case GF_STACK:
+ rrd_set_error("STACK should already be turned into LINE or AREA here");
+ return -1;
+ break;
default:
break;
}
case GF_LINE:
case GF_AREA:
case GF_TICK:
- case GF_STACK:
case GF_HRULE:
case GF_VRULE:
graphelement = 1;
case GF_SHIFT:
case GF_XPORT:
break;
+ case GF_STACK:
+ rrd_set_error("STACK should already be turned into LINE or AREA here");
+ return -1;
+ break;
}
}
return graphelement;
gfx_node_t *node;
double areazero = 0.0;
- enum gf_en stack_gf = GF_PRINT;
graph_desc_t *lastgdes = NULL;
/* if we are lazy and there is nothing to PRINT ... quit now */
for (ii = 0; ii < im->xsize; ii++)
{
if (!isnan(im->gdes[i].p_data[ii]) &&
- im->gdes[i].p_data[ii] > 0.0)
- {
- /* generate a tick */
- gfx_new_line(im->canvas, im -> xorigin + ii,
- im -> yorigin - (im -> gdes[i].yrule * im -> ysize),
- im -> xorigin + ii,
- im -> yorigin,
- 1.0,
- im -> gdes[i].col );
- }
+ im->gdes[i].p_data[ii] != 0.0)
+ {
+ if (im -> gdes[i].yrule > 0 ) {
+ gfx_new_line(im->canvas,
+ im -> xorigin + ii, im->yorigin,
+ im -> xorigin + ii, im->yorigin - im -> gdes[i].yrule * im -> ysize,
+ 1.0,
+ im -> gdes[i].col );
+ } else if ( im -> gdes[i].yrule < 0 ) {
+ gfx_new_line(im->canvas,
+ im -> xorigin + ii, im->yorigin - im -> ysize,
+ im -> xorigin + ii, im->yorigin - ( 1 - im -> gdes[i].yrule ) * im -> ysize,
+ 1.0,
+ im -> gdes[i].col );
+
+ }
+ }
}
break;
case GF_LINE:
case GF_AREA:
- stack_gf = im->gdes[i].gf;
- case GF_STACK:
/* fix data points at oo and -oo */
for(ii=0;ii<im->xsize;ii++){
if (isinf(im->gdes[i].p_data[ii])){
********************************************************* */
if (im->gdes[i].col != 0x0){
/* GF_LINE and friend */
- if(stack_gf == GF_LINE ){
+ if(im->gdes[i].gf == GF_LINE ){
double last_y=0.0;
node = NULL;
for(ii=1;ii<im->xsize;ii++){
}
break;
#endif
+ case GF_STACK:
+ rrd_set_error("STACK should already be turned into LINE or AREA here");
+ return -1;
+ break;
} /* switch */
}
im->gdes[im->gdes_c-1].step=im->step;
im->gdes[im->gdes_c-1].step_orig=im->step;
im->gdes[im->gdes_c-1].stack=0;
+ im->gdes[im->gdes_c-1].linewidth=0;
im->gdes[im->gdes_c-1].debug=0;
im->gdes[im->gdes_c-1].start=im->start;
im->gdes[im->gdes_c-1].end=im->end;
diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c
index aca3eea82e8a84001db219eda3cbf6352c3aacd5..8855dcd1a5069de18f1c6dc7156699cd10ee0ca6 100644 (file)
--- a/src/rrd_graph_helper.c
+++ b/src/rrd_graph_helper.c
@@ -776,6 +776,9 @@ rrd_parse_cdef(const char *const line, unsigned int *const eaten, graph_desc_t *
void
rrd_graph_script(int argc, char *argv[], image_desc_t *const im, int optno) {
int i;
+ /* save state for STACK backward compat function */
+ enum gf_en last_gf=GF_PRINT;
+ float last_linewidth=0.0;
for (i=optind+optno;i<argc;i++) {
graph_desc_t *gdp;
#endif
if (rrd_parse_find_gf(argv[i],&eaten,gdp)) return;
-
+
switch (gdp->gf) {
case GF_SHIFT: /* vname:value */
if (rrd_parse_shift(argv[i],&eaten,gdp,im)) return;
case GF_COMMENT: /* text */
if (rrd_parse_legend(argv[i],&eaten,gdp)) return;
break;
- case GF_STACK: /* vname-or-value[#color[:legend]] */
#ifdef WITH_PIECHART
case GF_PART: /* value[#color[:legend]] */
#endif
case GF_LINE: /* vname-or-value[#color[:legend]][:STACK] */
case GF_AREA: /* vname-or-value[#color[:legend]][:STACK] */
case GF_TICK: /* vname#color[:num[:legend]] */
- if (rrd_parse_PVHLAST(argv[i],&eaten,gdp,im)) return;
+ if (rrd_parse_PVHLAST(argv[i],&eaten,gdp,im))return;
+ last_gf = gdp->gf;
+ last_linewidth = gdp->linewidth;
+ break;
+ case GF_STACK: /* vname-or-value[#color[:legend]] */
+ if (rrd_parse_PVHLAST(argv[i],&eaten,gdp,im))return;
+ if (last_gf == GF_LINE || last_gf == GF_AREA){
+ gdp->gf = last_gf;
+ gdp->linewidth = last_linewidth;
+ } else {
+ rrd_set_error("STACK must follow LINE or AREA! command:\n%s",
+ &argv[i][eaten],argv[i]);
+ return;
+ }
break;
/* data acquisition */
case GF_DEF: /* vname=x:DS:CF:[:step=#][:start=#][:end=#] */