36 int ret, n, ri, si, ei;
37 char x_title[64], y_title[64], tac_id[32], tac_title[64];
38 double minx, maxx, miny, maxy, tx1, tx2, ty1, ty2, f;
40 int max_color_nr, color_nr;
41 int max_symbol_nr, symbol_nr;
46 printf(
"%s(dft1, dft2, mt, x1, x2, y1, y2, fn, %d)\n", __func__, verbose);
50 if(dft1==NULL || dft1->
voiNr<1)
return(1);
51 if(dft2==NULL)
return(1);
57 int is_label=0;
if(dft1->
voiNr>1) is_label=1;
60 ret=
dftMinMax(dft1, &tx1, &tx2, NULL, NULL);
if(ret)
return(3);
62 ret=
dftMinMax(dft2, &tx1, &tx2, NULL, NULL);
if(ret)
return(3);
63 if(minx>tx1) minx=tx1;
64 if(maxx<tx2) maxx=tx2;
66 f=maxx-minx; minx-=0.05*f;
67 if(minx<0.0) minx=0.0;
69 if(!isnan(x1)) minx=x1;
70 if(!isnan(x2)) maxx=x2;
73 ret=
dftMaxY(dft1, minx, maxx, &ty1, &ty2);
if(ret)
return(3);
75 ret=
dftMaxY(dft2, minx, maxx, &ty1, &ty2);
if(ret)
return(3);
76 if(miny>ty1) miny=ty1;
77 if(maxy<ty2) maxy=ty2;
79 f=maxy-miny; miny-=0.05*f;
80 if(miny<0.0) miny=0.0;
82 if(!isnan(y1)) miny=y1;
83 if(!isnan(y2)) maxy=y2;
85 if(verbose>1) printf(
"minx:=%g\nmaxx:=%g\nminy:=%g\nmaxy:=%g\n", minx, maxx, miny, maxy);
89 viewports.
x.
min=minx; viewports.
x.
max=maxx;
90 viewports.
y.
min=miny; viewports.
y.
max=maxy;
91 if(isnan(x1) || isnan(x2)) viewports.
x.
fixed_min=0;
92 if(isnan(y1) || isnan(y2)) viewports.
y.
fixed_min=0;
99 sprintf(x_title,
"Time (%s)", dftTimeunit(dft1->
timeunit));
100 else if(dft1->
timeunit!=DFTTIME_UNKNOWN)
101 strcpy(x_title, dftTimeunit(dft1->
timeunit));
103 if(dftUnitId(dft1->
unit)!=DFTUNIT_UNKNOWN)
104 strcpy(y_title, dftUnit(dftUnitId(dft1->
unit)));
108 strlen(x_title), is_label, &viewports, verbose-3);
112 fp_svg=
svg_initiate(fname, 0, 0, &viewports, NULL, verbose-3);
113 if(fp_svg==NULL)
return(6);
138 max_color_nr=0;
while(
svgColorName(max_color_nr)!=NULL) max_color_nr++;
139 if(max_color_nr==0) max_color_nr=1;
140 if(verbose>3) printf(
"max_color_nr := %d\n", max_color_nr);
141 max_symbol_nr=0;
while(
svgSymbolName(max_symbol_nr)!=NULL) max_symbol_nr++;
142 if(max_symbol_nr==0) max_symbol_nr=1;
143 if(verbose>3) printf(
"max_symbol_nr := %d\n", max_symbol_nr);
144 if(dft1->
voiNr==1) color_nr=0;
else color_nr=1;
146 for(ri=0, n=0; ri<dft1->
voiNr; ri++) {
147 sprintf(tac_id,
"plot_%d", n);
155 for(si=0; si<dft2->
frameNr; si++)
if(!isnan(dft2->
voi[ri].
y[si]))
break;
156 for(ei=dft2->
frameNr-1; ei>=si; ei--)
if(!isnan(dft2->
voi[ri].
y[ei]))
break;
159 dft2->
x+si, dft2->
voi[ri].
y+si, 1+ei-si,
160 svgColorName(color_nr%max_color_nr), symbol_nr%max_symbol_nr, SYMBOLFILLED,
167 svgColorName(color_nr%max_color_nr), symbol_nr%max_symbol_nr, SYMBOLFILLED,
172 svg_legend_add(&legends, 0, symbol_nr%max_symbol_nr, SYMBOLFILLED,
173 color_nr%max_color_nr, tac_title);
177 if(color_nr==max_color_nr) {symbol_nr++; color_nr=0;}
178 if(symbol_nr==max_symbol_nr) symbol_nr=0;
197 if(verbose>2) printf(
"creating plot legends\n");
204 ret=
svg_close(fp_svg, NULL, verbose-3);
if(ret)
return(101);
228 int ret, n, ri, si, ei;
229 char x_title[64], y_title[64], tac_id[32], tac_title[64];
230 double minx, maxx, miny, maxy, tx1, tx2, ty1, ty2, f;
232 int max_color_nr, color_nr;
233 int max_symbol_nr, symbol_nr;
239 printf(
"%s(dft1, dft2, mt, fn, %d)\n", __func__, verbose);
243 if(dft1==NULL || dft1->
voiNr<1)
return(1);
244 if(dft2==NULL)
return(1);
247 int is_label=0;
if(dft1->
voiNr>1) is_label=1;
253 minx=maxx=miny=maxy=0;
254 ret=
dftMinMax(dft1, &tx1, &tx2, &ty1, &ty2);
if(ret)
return(3);
255 minx=tx1; maxx=tx2; miny=ty1; maxy=ty2;
256 ret=
dftMinMax(dft2, &tx1, &tx2, &ty1, &ty2);
if(ret)
return(3);
257 if(minx>tx1) minx=tx1;
258 if(maxx<tx2) maxx=tx2;
259 if(miny>ty1) miny=ty1;
260 if(maxy<ty2) maxy=ty2;
261 if(verbose>1) printf(
"minx:=%g\nmaxx:=%g\nminy:=%g\nmaxy:=%g\n", minx, maxx, miny, maxy);
262 if(miny>0.0) {f=maxy-miny; miny-=0.01*f;}
267 viewports.
x.
min=minx; viewports.
x.
max=maxx;
268 viewports.
y.
min=miny; viewports.
y.
max=maxy;
272 if(verbose>2) printf(
"set x title\n");
275 sprintf(x_title,
"Time (%s)", dftTimeunit(dft1->
timeunit));
276 else if(dft1->
timeunit!=DFTTIME_UNKNOWN)
277 strcpy(x_title, dftTimeunit(dft1->
timeunit));
278 if(verbose>2) printf(
"set y title\n");
280 if(dftUnitId(dft1->
unit)!=DFTUNIT_UNKNOWN)
281 strcpy(y_title, dftUnit(dftUnitId(dft1->
unit)));
284 if(verbose>2) printf(
"set window sizes\n");
286 strlen(x_title), is_label, &viewports, verbose-3);
290 fp_svg=
svg_initiate(fname, 0, 0, &viewports, NULL, verbose-3);
291 if(fp_svg==NULL)
return(6);
312 if(verbose>0) printf(
"svg_write_axes() := %d\n", ret);
319 max_color_nr=0;
while(
svgColorName(max_color_nr)!=NULL) max_color_nr++;
320 if(max_color_nr<1) max_color_nr=1;
321 if(verbose>3) printf(
"max_color_nr := %d\n", max_color_nr);
322 max_symbol_nr=0;
while(
svgSymbolName(max_symbol_nr)!=NULL) max_symbol_nr++;
323 if(max_symbol_nr<1) max_symbol_nr=1;
324 if(verbose>3) printf(
"max_symbol_nr := %d\n", max_symbol_nr);
325 if(dft1->
voiNr==1) color_nr=0;
else color_nr=1;
327 for(ri=0, n=0; ri<dft1->
voiNr; ri++) {
328 sprintf(tac_id,
"plot_%d", n);
336 for(si=0; si<dft2->
frameNr; si++)
if(!isnan(dft2->
voi[ri].
y[si]))
break;
337 for(ei=dft2->
frameNr-1; ei>=si; ei--)
if(!isnan(dft2->
voi[ri].
y[ei]))
break;
340 dft2->
x+si, dft2->
voi[ri].
y+si, 1+ei-si,
341 svgColorName(color_nr%max_color_nr), symbol_nr%max_symbol_nr, SYMBOLFILLED,
348 svgColorName(color_nr%max_color_nr), symbol_nr%max_symbol_nr, SYMBOLFILLED,
353 svg_legend_add(&legends, 0, symbol_nr%max_symbol_nr, SYMBOLFILLED,
354 color_nr%max_color_nr, tac_title);
358 if(color_nr==max_color_nr) {symbol_nr++; color_nr=0;}
359 if(symbol_nr==max_symbol_nr) symbol_nr=0;
378 if(verbose>2) printf(
"creating plot legends\n");
385 ret=
svg_close(fp_svg, NULL, verbose-3);
if(ret)
return(101);
int svg_write_tac(FILE *fp, struct svg_viewports *vp, const int plot_type, const char *tac_id, const char *tac_title, double *x, double *y, const int data_nr, const char *color, const svgSymbolType symbol_type, const svgSymbolFill symbol_fill, char *errmsg, int verbose)