ncplot: add_sample(), set_sample() #430

pull/434/head
nick black 4 years ago committed by Nick Black
parent b3e874a179
commit a2170a4291

@ -12,11 +12,20 @@ notcurses_plot - high level widget for selecting from a set
```c
typedef struct ncplot_options {
// styling of the maximum and minimum levels.
// linear interpolation will be applied across
// the domain between these two.
// channels for the maximum and minimum levels.
// lerp across the domain between these two.
uint64_t maxchannel;
uint64_t minchannel;
// independent variable is vertical, not horizontal
bool vertical_indep;
// number of "pixels" per row x column
ncgridgeom_e gridtype;
// independent variable is a contiguous range
uint64_t rangex;
// y axis min and max. set both equal to 0
// for autodiscovery of range.
int64_t miny, maxy;
bool exponentialy; // is y-axis exponential?
} ncplot_options;
```
@ -24,7 +33,10 @@ typedef struct ncplot_options {
**struct ncplane* ncplot_plane(struct ncplot* n);**
**void ncplot_destroy(struct ncplot* n, char\*\* item);**
**int ncplot_add_sample(struct ncplot* n, uint64_t x, int64_t y);**
**int ncplot_set_sample(struct ncplot* n, uint64_t x, int64_t y);**
**void ncplot_destroy(struct ncplot* n);**
# DESCRIPTION

@ -410,6 +410,20 @@ int ncplane_rotate_cw(struct ncplane* n);
int ncplane_rotate_ccw(struct ncplane* n);
void ncplane_translate(const struct ncplane* src, const struct ncplane* dst, int* y, int* x);
bool ncplane_translate_abs(const struct ncplane* n, int* y, int* x);
typedef struct ncplot_options {
uint64_t maxchannel;
uint64_t minchannel;
bool vertical_indep;
ncgridgeom_e gridtype;
uint64_t rangex;
int64_t miny, maxy;
bool exponentialy;
} ncplot_options;
struct ncplot* ncplot_create(struct ncplane* n, const ncplot_options* opts);
struct ncplane* ncplot_plane(struct ncplot* n);
int ncplot_add_sample(struct ncplot* n, uint64_t x, int64_t y);
int ncplot_set_sample(struct ncplot* n, uint64_t x, int64_t y);
void ncplot_destroy(struct ncplot* n);
""")
if __name__ == "__main__":

@ -153,6 +153,11 @@ typedef struct ncplot {
ncplane* ncp;
uint64_t maxchannel;
uint64_t minchannel;
bool vertical_indep;
ncgridgeom_e gridtype;
uint64_t rangex;
int64_t miny, maxy;
bool exponentialy;
} ncplot;
typedef struct ncmenu {

@ -6,7 +6,12 @@ ncplot* ncplot_create(ncplane* n, const ncplot_options* opts){
ret->ncp = n;
ret->maxchannel = opts->maxchannel;
ret->minchannel = opts->minchannel;
// FIXME
ret->rangex = opts->rangex;
ret->miny = opts->miny;
ret->maxy = opts->maxy;
ret->vertical_indep = opts->vertical_indep;
ret->gridtype = opts->gridtype;
ret->exponentialy = opts->exponentialy;
}
return ret;
}
@ -15,6 +20,16 @@ ncplane* ncplot_plane(ncplot* n){
return n->ncp;
}
// Add to or set the value corresponding to this x. If x is beyond the current
// x window, the x window is advanced to include x, and values passing beyond
// the window are lost. The first call will place the initial window. The plot
// will be redrawn, but notcurses_render() is not called.
int ncplot_add_sample(struct ncplot* n, uint64_t x, int64_t y){
}
int ncplot_set_sample(struct ncplot* n, uint64_t x, int64_t y){
}
void ncplot_destroy(ncplot* n){
if(n){
free(n);

Loading…
Cancel
Save