Introduction
Introduction Statistics Contact Development Disclaimer Help
fix the scales - ploot - simple plotting tools
git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65…
Log
Files
Refs
Tags
README
LICENSE
---
commit c7ebe97a6b085ad58fc77f47e98a785def7cd7d4
parent c3911021718dc5e5b2dd6469495e7f3bc4befdd2
Author: Josuah Demangeon <[email protected]>
Date: Wed, 2 May 2018 07:34:05 +0200
fix the scales
Diffstat:
M ffplot.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/ffplot.c b/ffplot.c
@@ -22,6 +22,9 @@
#define MARGIN 4
+#define XDENSITY 7 /* how many values to be displayed on x axis */
+#define YDENSITY 7 /* how many values to be displayed on y axis */
+
#define FONT_H 14
#define FONT_W 7
@@ -122,9 +125,9 @@ yaxis(Canvas *can, Color *label, Color *grid,
{
time_t t;
int y;
- char str[sizeof("YYYY/MM/DD")], *fmt;
+ char str[sizeof(" YYYY/MM/DD ")], *fmt;
- fmt = (tstep < 3600 * 24) ? " %H:%M:%S " : " %Y/%m/%d ";
+ fmt = (tstep < 3600 * 12) ? " %H:%M:%S " : " %Y/%m/%d ";
for (t = tmax - tmax % tstep; t >= tmin; t -= tstep) {
y = t2y(t, tmin, tmax);
@@ -203,11 +206,11 @@ find_scales(Vlist *v, int n,
double *vmin, double *vmax, double *vstep,
time_t *tmin, time_t *tmax, time_t *tstep)
{
- double dv, *vs, vscale[] = { 5, 2, 1 };
+ double dv, *vs, vscale[] = { 1, 2, 3, 5 };
time_t dt, *ts, tscale[] = {
- 3600*24*30, 3600*24*5, 3600*24*2, 3600*24, 3600*18, 3600*10,
- 3600*5, 3600*2, 3600, 60*30, 60*20, 60*10, 60*5, 60*2, 60, 30,
- 20, 10, 5, 2, 1
+ 1, 5, 2, 10, 20, 30, 60, 60*2, 60*5, 60*10, 60*20, 60*30, 3600…
+ 3600*2, 3600*5, 3600*10, 3600*18, 3600*24, 3600*24*2,
+ 3600*24*5, 3600*24*30
};
int i;
@@ -230,7 +233,7 @@ find_scales(Vlist *v, int n,
dt = *tmax - *tmin;
for (ts = tscale; ts < tscale + LEN(tscale); ts++) {
- if (dt > *ts * 5) {
+ if (dt < *ts * YDENSITY) {
*tstep = *ts;
break;
}
@@ -238,8 +241,8 @@ find_scales(Vlist *v, int n,
for (i = 1; i != 0; i *= 10) {
for (vs = vscale; vs < vscale + LEN(vscale); vs++) {
- if (dv > *vs * i * 1) {
- *vstep = *vs * i * 10;
+ if (dv < *vs * i * XDENSITY) {
+ *vstep = *vs * i;
i = 0;
break;
}
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.