i[add] time at the bottom axis - ploot - simple plotting tools Err bitreich.org 70
hgit clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ploot URL:git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ploot bitreich.org 70
1Log /scm/ploot/log.gph bitreich.org 70
1Files /scm/ploot/files.gph bitreich.org 70
1Refs /scm/ploot/refs.gph bitreich.org 70
1Tags /scm/ploot/tag bitreich.org 70
1README /scm/ploot/file/README.md.gph bitreich.org 70
1LICENSE /scm/ploot/file/LICENSE.gph bitreich.org 70
i--- Err bitreich.org 70
1commit 8f05e8625d7d5a684fba3ab97c911d3b98e1ecdd /scm/ploot/commit/8f05e8625d7d5a684fba3ab97c911d3b98e1ecdd.gph bitreich.org 70
1parent ae31e2f1bccbf48ba05d29941119f73b34e1a66b /scm/ploot/commit/ae31e2f1bccbf48ba05d29941119f73b34e1a66b.gph bitreich.org 70
hAuthor: Josuah Demangeon <mail@josuah.net> URL:mailto:mail@josuah.net bitreich.org 70
iDate: Wed, 14 Feb 2018 20:13:55 +0100 Err bitreich.org 70
i Err bitreich.org 70
i[add] time at the bottom axis Err bitreich.org 70
i Err bitreich.org 70
iDiffstat: Err bitreich.org 70
i M ploot.c | 109 ++++++++++++++++++------------- Err bitreich.org 70
i A ploot.core | 0 Err bitreich.org 70
i A txt | 0 Err bitreich.org 70
i Err bitreich.org 70
i3 files changed, 62 insertions(+), 47 deletions(-) Err bitreich.org 70
i--- Err bitreich.org 70
1diff --git a/ploot.c b/ploot.c /scm/ploot/file/ploot.c.gph bitreich.org 70
i@@ -7,18 +7,15 @@ Err bitreich.org 70
i Err bitreich.org 70
i #include "config.h" Err bitreich.org 70
i Err bitreich.org 70
i-#define MAX_VAL 80 Err bitreich.org 70
i-#define MARGIN 7 Err bitreich.org 70
i- Err bitreich.org 70
i #define ABS(x) ((x) < 0 ? -(x) : (x)) Err bitreich.org 70
i #define MIN(x, y) ((x) < (y) ? (x) : (y)) Err bitreich.org 70
i #define MAX(x, y) ((x) > (y) ? (x) : (y)) Err bitreich.org 70
i #define LEN(buf) (sizeof(buf) / sizeof(*(buf))) Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Add `val' at the current position `pos' of the `ring' buffer and set pos to Err bitreich.org 70
i- * the next postion. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Add `val' at the current position `pos' of the `ring' buffer and set pos to Err bitreich.org 70
i+** the next postion. Err bitreich.org 70
i+*/ Err bitreich.org 70
i #define RING_ADD(rbuf, len, pos, val) \ Err bitreich.org 70
i do { \ Err bitreich.org 70
i rbuf[pos] = val; \ Err bitreich.org 70
i@@ -26,24 +23,27 @@ do { \ Err bitreich.org 70
i } while (0) Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Copy the ring buffer `rbuf' content with current position `pos' into the Err bitreich.org 70
i- * buffer `buf'. Both buffer of length `len'. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Copy the ring buffer `rbuf' content with current position `pos' into the Err bitreich.org 70
i+** buffer `buf'. Both buffer of length `len'. Err bitreich.org 70
i+*/ Err bitreich.org 70
i #define RING_COPY(buf, rbuf, len, pos) \ Err bitreich.org 70
i do { \ Err bitreich.org 70
i memcpy(buf, rbuf + pos, (len - pos) * sizeof(*rbuf)); \ Err bitreich.org 70
i memcpy(buf + (len - pos), rbuf, pos * sizeof(*rbuf)); \ Err bitreich.org 70
i } while (0) Err bitreich.org 70
i Err bitreich.org 70
i+#define MAX_VAL 80 Err bitreich.org 70
i+#define MARGIN 7 Err bitreich.org 70
i+ Err bitreich.org 70
i int flag_h = 20; Err bitreich.org 70
i char *flag_t = NULL; Err bitreich.org 70
i time_t flag_o = 0; Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Set `str' to a human-readable form of `num' with always a width of 7 (+ 1 Err bitreich.org 70
i- * the '\0' terminator). Buffer overflow is ensured not to happen due to the Err bitreich.org 70
i- * max size of a double. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Set `str' to a human-readable form of `num' with always a width of 7 (+ 1 Err bitreich.org 70
i+** the '\0' terminator). Buffer overflow is ensured not to happen due to the Err bitreich.org 70
i+** max size of a double. Err bitreich.org 70
i+*/ Err bitreich.org 70
i void Err bitreich.org 70
i humanize(char *str, double val) Err bitreich.org 70
i { Err bitreich.org 70
i@@ -63,8 +63,8 @@ humanize(char *str, double val) Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Returns the maximal double of values between `beg' and `end'. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Returns the maximal double of values between `beg' and `end'. Err bitreich.org 70
i+*/ Err bitreich.org 70
i double Err bitreich.org 70
i maxdv(double *beg, double *end) Err bitreich.org 70
i { Err bitreich.org 70
i@@ -79,8 +79,8 @@ maxdv(double *beg, double *end) Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * If not null, print the title `str' centered on width. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** If not null, print the title `str' centered on width. Err bitreich.org 70
i+*/ Err bitreich.org 70
i void Err bitreich.org 70
i title(char *str, int width) Err bitreich.org 70
i { Err bitreich.org 70
i@@ -90,9 +90,9 @@ title(char *str, int width) Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Print vertical axis with humanized number from time to time, with occurences Err bitreich.org 70
i- * determined after the position on the vertical axis from the bottom `pos'. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Print vertical axis with humanized number from time to time, with occurences Err bitreich.org 70
i+** determined after the position on the vertical axis from the bottom `pos'. Err bitreich.org 70
i+*/ Err bitreich.org 70
i void Err bitreich.org 70
i vaxis(double val, int pos) Err bitreich.org 70
i { Err bitreich.org 70
i@@ -107,22 +107,35 @@ vaxis(double val, int pos) Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Print horizontal axis for up to `col' values. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Print horizontal axis for up to `col' values along with dates if reading time Err bitreich.org 70
i+** series. Err bitreich.org 70
i+*/ Err bitreich.org 70
i void Err bitreich.org 70
i-haxis(double *beg, double *end) Err bitreich.org 70
i+haxis(double *beg, double *end, time_t time) Err bitreich.org 70
i { Err bitreich.org 70
i- double *tp; Err bitreich.org 70
i+ double *tp; Err bitreich.org 70
i+ char buf[9], dbeg[11], dend[11]; Err bitreich.org 70
i Err bitreich.org 70
i printf("%*d -+", MARGIN, 0); Err bitreich.org 70
i for (tp = beg; tp < end; tp++) Err bitreich.org 70
i putchar((*tp < 0) ? ('x') : ('-')); Err bitreich.org 70
i putchar('\n'); Err bitreich.org 70
i+ if (flag_o > 0) { Err bitreich.org 70
i+ printf("%*c", MARGIN - 1, ' '); Err bitreich.org 70
i+ strftime(dbeg, sizeof(dbeg), "%Y/%m/%d", localtime(&time)); Err bitreich.org 70
i+ for (tp = beg; tp < end; tp += 7) { Err bitreich.org 70
i+ strftime(buf, sizeof(buf), " %H:%M", localtime(&time)); Err bitreich.org 70
i+ fputs(buf, stdout); Err bitreich.org 70
i+ time += flag_o * 7; Err bitreich.org 70
i+ } Err bitreich.org 70
i+ strftime(dend, sizeof(dend), "%Y/%m/%d", localtime(&time)); Err bitreich.org 70
i+ printf("\n %-*s %s\n", (int)(beg - end) + 4, dbeg, dend); Err bitreich.org 70
i+ } Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Print two rows of a plot into a single line using ' ', '.' and ':'. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Print two rows of a plot into a single line using ' ', '.' and ':'. Err bitreich.org 70
i+*/ Err bitreich.org 70
i void Err bitreich.org 70
i line(double *beg, double *end, double top, double bot) Err bitreich.org 70
i { Err bitreich.org 70
i@@ -135,11 +148,11 @@ line(double *beg, double *end, double top, double bot) Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Plot values between `beg' and `end' in a plot of height `height'. Err bitreich.org 70
i- * If `str' is not NULL, it is set as a title above the graph. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Plot values between `beg' and `end' in a plot of height `height'. Err bitreich.org 70
i+** If `str' is not NULL, it is set as a title above the graph. Err bitreich.org 70
i+*/ Err bitreich.org 70
i void Err bitreich.org 70
i-plot(double *beg, double *end, int height, char *str) Err bitreich.org 70
i+plot(double *beg, double *end, int height, char *str, time_t start) Err bitreich.org 70
i { Err bitreich.org 70
i double top, bot, max; Err bitreich.org 70
i int h; Err bitreich.org 70
i@@ -156,16 +169,16 @@ plot(double *beg, double *end, int height, char *str) Err bitreich.org 70
i vaxis(top, h); Err bitreich.org 70
i line(beg, end, top, bot); Err bitreich.org 70
i } Err bitreich.org 70
i- haxis(beg, end); Err bitreich.org 70
i+ haxis(beg, end, start); Err bitreich.org 70
i Err bitreich.org 70
i putchar('\n'); Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Read a simple format with one double per line and save the last `MAX_WIDTH' Err bitreich.org 70
i- * values into `buf' which must be at least MAX_VAL wide and return a pointer Err bitreich.org 70
i- * to the last element or NULL if the input contains error. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Read a simple format with one double per line and save the last `MAX_WIDTH' Err bitreich.org 70
i+** values into `buf' which must be at least MAX_VAL wide and return a pointer Err bitreich.org 70
i+** to the last element or NULL if the input contains error. Err bitreich.org 70
i+*/ Err bitreich.org 70
i double * Err bitreich.org 70
i read_simple(double buf[MAX_VAL]) Err bitreich.org 70
i { Err bitreich.org 70
i@@ -183,11 +196,11 @@ read_simple(double buf[MAX_VAL]) Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Read a format with blank separated time_t-double pairs, one per line and save Err bitreich.org 70
i- * the last `MAX_WIDTH' values into `tbuf' and `vbuf' which must both be at Err bitreich.org 70
i- * least MAX_VAL wide and return a pointer to the last element of `vbuf' or Err bitreich.org 70
i- * NULL if the input contains error. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Read a format with blank separated time_t-double pairs, one per line and save Err bitreich.org 70
i+** the last `MAX_WIDTH' values into `tbuf' and `vbuf' which must both be at Err bitreich.org 70
i+** least MAX_VAL wide and return a pointer to the last element of `vbuf' or Err bitreich.org 70
i+** NULL if the input contains error. Err bitreich.org 70
i+*/ Err bitreich.org 70
i time_t * Err bitreich.org 70
i read_time_series(double *vbuf, time_t *tbuf) Err bitreich.org 70
i { Err bitreich.org 70
i@@ -210,9 +223,9 @@ read_time_series(double *vbuf, time_t *tbuf) Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i /* Err bitreich.org 70
i- * Walk from `tbeg' and `tend' and add offset in `tbuf' every time there is no Err bitreich.org 70
i- * value in `step' amount of time, by setting a value to -1. Err bitreich.org 70
i- */ Err bitreich.org 70
i+** Walk from `tbeg' and `tend' and add offset in `tbuf' every time there is no Err bitreich.org 70
i+** value in `step' amount of time, by setting a value to -1. Err bitreich.org 70
i+*/ Err bitreich.org 70
i double * Err bitreich.org 70
i skip_gaps(time_t *tbeg, time_t *tend, double *vbuf, time_t step) Err bitreich.org 70
i { Err bitreich.org 70
i@@ -221,14 +234,14 @@ skip_gaps(time_t *tbeg, time_t *tend, double *vbuf, time_t step) Err bitreich.org 70
i double *vp, vrbuf[MAX_VAL]; Err bitreich.org 70
i Err bitreich.org 70
i /* Compute the average alignment of the timestamps values according to Err bitreich.org 70
i- * the step size. */ Err bitreich.org 70
i+ ** the step size. */ Err bitreich.org 70
i toff = 0; Err bitreich.org 70
i for (tp = tbeg; tp < tend; tp++) Err bitreich.org 70
i toff += *tp % step; Err bitreich.org 70
i toff = *tbeg + toff / (tend - tbeg) + step / 2; Err bitreich.org 70
i Err bitreich.org 70
i /* Fill `vbuf' with gap added at each time gap using vrbuf as Err bitreich.org 70
i- * intermediate ring buffer. */ Err bitreich.org 70
i+ ** intermediate ring buffer. */ Err bitreich.org 70
i len = LEN(vrbuf); Err bitreich.org 70
i for (p = pos = 0, tp = tbeg, vp = vbuf; tp < tend; p++, vp++, tp++) { Err bitreich.org 70
i for (; toff < *tp; toff += step) Err bitreich.org 70
i@@ -253,7 +266,7 @@ usage(void) Err bitreich.org 70
i int Err bitreich.org 70
i main(int argc, char **argv) Err bitreich.org 70
i { Err bitreich.org 70
i- time_t tbuf[MAX_VAL], *tend; Err bitreich.org 70
i+ time_t tbuf[MAX_VAL], *tend, start; Err bitreich.org 70
i double vbuf[MAX_VAL], *vend; Err bitreich.org 70
i int c; Err bitreich.org 70
i Err bitreich.org 70
i@@ -278,11 +291,13 @@ main(int argc, char **argv) Err bitreich.org 70
i Err bitreich.org 70
i if (flag_o == 0) { Err bitreich.org 70
i vend = read_simple(vbuf); Err bitreich.org 70
i+ start = 0; Err bitreich.org 70
i } else { Err bitreich.org 70
i tend = read_time_series(vbuf, tbuf); Err bitreich.org 70
i vend = skip_gaps(tbuf, tend, vbuf, flag_o); Err bitreich.org 70
i+ start = *tbuf; Err bitreich.org 70
i } Err bitreich.org 70
i Err bitreich.org 70
i- plot(vbuf, vend, flag_h, flag_t); Err bitreich.org 70
i+ plot(vbuf, vend, flag_h, flag_t, start); Err bitreich.org 70
i return 0; Err bitreich.org 70
i } Err bitreich.org 70
1diff --git a/ploot.core b/ploot.core /scm/ploot/file/ploot.core.gph bitreich.org 70
iBinary files differ. Err bitreich.org 70
1diff --git a/txt b/txt /scm/ploot/file/txt.gph bitreich.org 70
.
Response:
text/plain