diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 578f393c1..081327265 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -2851,14 +2851,15 @@ API int ncmenu_destroy(struct ncmenu* n); // // This options structure works for both the ncuplot (uint64_t) and ncdplot // (double) types. -#define NCPLOT_OPTION_LABELTICKSD 0x0001ull // show labels for dependent axis -#define NCPLOT_OPTION_EXPONENTIALD 0x0002ull // exponential dependent axis -#define NCPLOT_OPTION_VERTICALI 0x0004ull // independent axis is vertical -#define NCPLOT_OPTION_NODEGRADE 0x0008ull // fail rather than degrade blitter +#define NCPLOT_OPTION_LABELTICKSD 0x0001ull // show labels for dependent axis +#define NCPLOT_OPTION_EXPONENTIALD 0x0002ull // exponential dependent axis +#define NCPLOT_OPTION_VERTICALI 0x0004ull // independent axis is vertical +#define NCPLOT_OPTION_NODEGRADE 0x0008ull // fail rather than degrade blitter +#define NCPLOT_OPTION_DETECTMAXONLY 0x0010ull // use domain detection only for max typedef struct ncplot_options { - // channels for the maximum and minimum levels. linear interpolation will be - // applied across the domain between these two. + // channels for the maximum and minimum levels. linear or exponential + // interpolation will be applied across the domain between these two. uint64_t maxchannel; uint64_t minchannel; // if you don't care, pass NCBLIT_DEFAULT and get NCBLIT_8x1 (assuming diff --git a/src/lib/plot.h b/src/lib/plot.h index a898c13a1..2af44c109 100644 --- a/src/lib/plot.h +++ b/src/lib/plot.h @@ -14,16 +14,24 @@ class ncppplot { // these were all originally plain C, sorry for the non-idiomatic usage FIXME // ought admit nullptr opts FIXME static bool create(ncppplot* ncpp, ncplane* n, const ncplot_options* opts, T miny, T maxy) { - // if miny == maxy, they both must be equal to 0 + struct notcurses* nc = n->nc; + // if miny == maxy (enabling domain detection), they both must be equal to 0 if(miny == maxy && miny){ + logerror(nc, "Supplied non-zero domain detection param %d\n", miny); return false; } if(opts->rangex < 0){ + logerror(nc, "Supplied negative independent range %d\n", opts->rangex); return false; } if(maxy < miny){ return false; } + // DETECTMAXONLY can't be used without domain detection + if(opts->flags & NCPLOT_OPTION_DETECTMAXONLY && (miny != maxy)){ + logerror(nc, "Supplied DETECTMAXONLY without domain detection"); + return false; + } ncblitter_e blitter = opts ? opts->gridtype : NCBLIT_DEFAULT; if(blitter == NCBLIT_DEFAULT){ if(notcurses_canutf8(ncplane_notcurses(n))){ @@ -272,8 +280,10 @@ class ncppplot { if(val > maxy){ maxy = val; } - if(val < miny){ - miny = val; + if(!detectonlymax){ + if(val < miny){ + miny = val; + } } return 0; } @@ -356,7 +366,8 @@ class ncppplot { int slotstart; // index of most recently-written slot bool labelaxisd; // label dependent axis (consumes PREFIXCOLUMNS columns) bool exponentiali; // exponential independent axis - bool detectdomain; // is domain detection in effect (stretch the domain)? + bool detectdomain; // is domain detection in effect (stretch the domain)? + bool detectonlymax; // domain detection applies only to max, not min };