mirror of
https://github.com/navidys/tvxwidgets.git
synced 2025-05-05 19:30:27 +08:00
add parameters to control auto scaling behavior and prevent breaking change
Signed-off-by: Markus Ressel <mail@markusressel.de>
This commit is contained in:
parent
4632165f80
commit
7e3024f613
16
plot.go
16
plot.go
@ -66,6 +66,8 @@ type Plot struct {
|
|||||||
drawXAxisLabel bool
|
drawXAxisLabel bool
|
||||||
drawYAxisLabel bool
|
drawYAxisLabel bool
|
||||||
yAxisLabelDataType PlotYAxisLabelDataType
|
yAxisLabelDataType PlotYAxisLabelDataType
|
||||||
|
YAxisAutoScaleMin bool
|
||||||
|
YAxisAutoScaleMax bool
|
||||||
brailleCellMap map[image.Point]brailleCell
|
brailleCellMap map[image.Point]brailleCell
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
@ -83,6 +85,8 @@ func NewPlot() *Plot {
|
|||||||
drawXAxisLabel: true,
|
drawXAxisLabel: true,
|
||||||
drawYAxisLabel: true,
|
drawYAxisLabel: true,
|
||||||
yAxisLabelDataType: PlotYAxisLabelDataFloat,
|
yAxisLabelDataType: PlotYAxisLabelDataFloat,
|
||||||
|
YAxisAutoScaleMin: false,
|
||||||
|
YAxisAutoScaleMax: true,
|
||||||
lineColors: []tcell.Color{
|
lineColors: []tcell.Color{
|
||||||
tcell.ColorSteelBlue,
|
tcell.ColorSteelBlue,
|
||||||
},
|
},
|
||||||
@ -118,6 +122,14 @@ func (plot *Plot) SetYAxisLabelDataType(dataType PlotYAxisLabelDataType) {
|
|||||||
plot.yAxisLabelDataType = dataType
|
plot.yAxisLabelDataType = dataType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plot *Plot) SetYAxisAutoScaleMin(autoScale bool) {
|
||||||
|
plot.YAxisAutoScaleMin = autoScale
|
||||||
|
}
|
||||||
|
|
||||||
|
func (plot *Plot) SetYAxisAutoScaleMax(autoScale bool) {
|
||||||
|
plot.YAxisAutoScaleMax = autoScale
|
||||||
|
}
|
||||||
|
|
||||||
// SetAxesColor sets axes x and y lines color.
|
// SetAxesColor sets axes x and y lines color.
|
||||||
func (plot *Plot) SetAxesColor(color tcell.Color) {
|
func (plot *Plot) SetAxesColor(color tcell.Color) {
|
||||||
plot.axesColor = color
|
plot.axesColor = color
|
||||||
@ -160,8 +172,12 @@ func (plot *Plot) SetData(data [][]float64) {
|
|||||||
|
|
||||||
plot.brailleCellMap = make(map[image.Point]brailleCell)
|
plot.brailleCellMap = make(map[image.Point]brailleCell)
|
||||||
plot.data = data
|
plot.data = data
|
||||||
|
if plot.YAxisAutoScaleMax {
|
||||||
plot.maxVal = getMaxFloat64From2dSlice(data)
|
plot.maxVal = getMaxFloat64From2dSlice(data)
|
||||||
|
}
|
||||||
|
if plot.YAxisAutoScaleMin {
|
||||||
plot.minVal = getMinFloat64From2dSlice(data)
|
plot.minVal = getMinFloat64From2dSlice(data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plot *Plot) SetMaxVal(maxVal float64) {
|
func (plot *Plot) SetMaxVal(maxVal float64) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user