|
From: Shigeharu T. <sh...@ie...> - 2008-09-17 10:02:24
|
shige 09/17 2008 ---------------- I wrote: | While we can not do it for 30 days interval simply, we can do the | other days (ex. 10, 15, 20, 25 days) without such trick. I think | the simple way is to enable to modify the automatic timelevel | setting. For example, the following patch enable us to control timelevel by set xdata: set xdata time tmlevel day # timelevel[x-axis] = TIMELEVEL_DAYS set ydata time tmlevel week # timelevel[y-axis] = TIMELEVEL_WEEKS set xdata time tmlevel none # not use timelevel[x-axis] set xdata time tmlevel auto # timelevel[x-axis] = automatic setting set xdata time # the same as above But, I do not know whether this is appropriate or not. ----- From here ----- diff -u src/axis.h.ORG src/axis.h --- src/axis.h.ORG Wed Sep 10 12:20:05 2008 +++ src/axis.h Wed Sep 17 18:21:07 2008 @@ -688,4 +688,17 @@ || 1 == (plot)->lp_properties.use_palette) int set_cbminmax __PROTO((void)); +/* shige: moved from axis.c */ +#ifdef USE_CTRL_TIMELEVEL +typedef enum e_timelevel { + TIMELEVEL_SECONDS = 1, TIMELEVEL_MINUTES, TIMELEVEL_HOURS, + TIMELEVEL_DAYS, TIMELEVEL_WEEKS, TIMELEVEL_MONTHS, + TIMELEVEL_YEARS + , + /* shige: add two */ + TIMELEVEL_NONE = -1, /* unuse timelevel */ + TIMELEVEL_AUTO = 0 /* use auto setting */ +} t_timelevel; +#endif + #endif /* GNUPLOT_AXIS_H */ diff -u src/axis.c.ORG src/axis.c --- src/axis.c.ORG Wed Sep 10 12:20:05 2008 +++ src/axis.c Wed Sep 17 18:45:39 2008 @@ -83,12 +83,17 @@ * self-explanatory */ /* The unit the tics of a given time/date axis are to interpreted in */ /* HBB 20040318: start at one, to avoid undershoot */ +/* shige: move to axis.h */ +#ifndef USE_CTRL_TIMELEVEL typedef enum e_timelevel { TIMELEVEL_SECONDS = 1, TIMELEVEL_MINUTES, TIMELEVEL_HOURS, TIMELEVEL_DAYS, TIMELEVEL_WEEKS, TIMELEVEL_MONTHS, TIMELEVEL_YEARS } t_timelevel; static t_timelevel timelevel[AXIS_ARRAY_SIZE]; +#else +t_timelevel timelevel[AXIS_ARRAY_SIZE]; +#endif /* The <increment> given in a 'set {x|y|...}tics', or an automatically * generated one, if automatic tic placement is active */ @@ -670,6 +675,10 @@ { int guide12 = guide * 3 / 5; /* --> 12 for default of 20 */ +/* shige */ +#ifdef USE_CTRL_TIMELEVEL + if(timelevel[axis] != TIMELEVEL_AUTO) return tic; +#endif timelevel[axis] = TIMELEVEL_SECONDS; if (tic > 5) { /* turn tic into units of minutes */ @@ -794,7 +803,13 @@ * leading to strange misbehaviours of minor tics on time axes. * We used to call quantize_time_tics, but that also caused strangeness. */ +/* shige */ +#ifdef USE_CTRL_TIMELEVEL + if (this->is_timedata && ticdef->type == TIC_SERIES + && timelevel[axis] == TIMELEVEL_AUTO) { +#else if (this->is_timedata && ticdef->type == TIC_SERIES) { +#endif if (tic >= 365*24*60*60.) timelevel[axis] = TIMELEVEL_YEARS; else if (tic >= 28*24*60*60.) timelevel[axis] = TIMELEVEL_MONTHS; else if (tic >= 7*24*60*60.) timelevel[axis] = TIMELEVEL_WEEKS; @@ -1165,7 +1180,12 @@ { struct tm tm; +/* shige */ +#ifdef USE_CTRL_TIMELEVEL + if (level == TIMELEVEL_NONE || level <= TIMELEVEL_SECONDS) { +#else if (level <= TIMELEVEL_SECONDS) { +#endif return (ticplace); } ggmtime(&tm, ticplace); diff -u src/set.c.ORG src/set.c --- src/set.c.ORG Wed Sep 10 12:20:08 2008 +++ src/set.c Wed Sep 17 18:45:51 2008 @@ -4372,6 +4372,41 @@ static void set_timedata(AXIS_INDEX axis) { +/* shige */ +#ifdef USE_CTRL_TIMELEVEL + extern t_timelevel timelevel[]; + axis_array[axis].is_timedata = FALSE; + + c_token++; + while (!END_OF_COMMAND) { + if (almost_equals(c_token,"t$ime")) { + axis_array[axis].is_timedata = TRUE; + } else if (equals(c_token,"tmlevel")) { + c_token++; + if (almost_equals(c_token,"a$uto")) + timelevel[axis] = TIMELEVEL_AUTO; + else if (almost_equals(c_token,"s$econd")) + timelevel[axis] = TIMELEVEL_SECONDS; + else if (almost_equals(c_token,"mi$nute")) + timelevel[axis] = TIMELEVEL_MINUTES; + else if (almost_equals(c_token,"h$our")) + timelevel[axis] = TIMELEVEL_HOURS; + else if (almost_equals(c_token,"d$ay")) + timelevel[axis] = TIMELEVEL_DAYS; + else if (almost_equals(c_token,"w$eek")) + timelevel[axis] = TIMELEVEL_WEEKS; + else if (almost_equals(c_token,"mo$nth")) + timelevel[axis] = TIMELEVEL_MONTHS; + else if (almost_equals(c_token,"year")) + timelevel[axis] = TIMELEVEL_YEARS; + else if (almost_equals(c_token,"no$ne")) + timelevel[axis] = TIMELEVEL_NONE; + else + timelevel[axis] = TIMELEVEL_AUTO; + } + c_token++; + } +#else c_token++; if(END_OF_COMMAND) { axis_array[axis].is_timedata = FALSE; @@ -4379,6 +4414,7 @@ if ((axis_array[axis].is_timedata = almost_equals(c_token,"t$ime"))) c_token++; } +#endif } ----- To here ----- +========================================================+ Shigeharu TAKENO NIigata Institute of Technology kashiwazaki,Niigata 945-1195 JAPAN sh...@ie... TEL(&FAX): +81-257-22-8161 +========================================================+ |