mirror of https://github.com/mum4k/termdash.git
Add linechart y-axis value formatter option API
Signed-off-by: Xabier Larrakoetxea <slok69@gmail.com>
This commit is contained in:
parent
2f1d16bbea
commit
560aef66d5
|
@ -40,6 +40,7 @@ type options struct {
|
||||||
xAxisUnscaled bool
|
xAxisUnscaled bool
|
||||||
yAxisMode axes.YScaleMode
|
yAxisMode axes.YScaleMode
|
||||||
yAxisCustomScale *customScale
|
yAxisCustomScale *customScale
|
||||||
|
yAxisValueFormatter ValueFormatter
|
||||||
zoomHightlightColor cell.Color
|
zoomHightlightColor cell.Color
|
||||||
zoomStepPercent int
|
zoomStepPercent int
|
||||||
}
|
}
|
||||||
|
@ -194,3 +195,18 @@ func ZoomStepPercent(perc int) Option {
|
||||||
opts.zoomStepPercent = perc
|
opts.zoomStepPercent = perc
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// YAxisFormattedValues sets a value formatter for the Y axis values.
|
||||||
|
// If a formatter is set, it will format the values with the desired
|
||||||
|
// ValueFormatter and will use the retuning string from the formatter
|
||||||
|
// instead of the numeric value to represent this value on the Y axis.
|
||||||
|
func YAxisFormattedValues(vfmt ValueFormatter) Option {
|
||||||
|
return option(func(opts *options) {
|
||||||
|
opts.yAxisValueFormatter = vfmt
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueFormatter will be used to format values onto string based
|
||||||
|
// representation.
|
||||||
|
// The received float64 value could be a math.NaN value.
|
||||||
|
type ValueFormatter func(value float64) string
|
||||||
|
|
Loading…
Reference in New Issue