mirror of https://github.com/mum4k/termdash.git
Improving option comment and test coverage.
This commit is contained in:
parent
587185eb73
commit
52ae7d1807
|
@ -376,7 +376,7 @@ func (lc *LineChart) drawSeries(cvs *canvas.Canvas, xd *axes.XDetails, yd *axes.
|
||||||
// Skip over series that don't have at least two points since we can't
|
// Skip over series that don't have at least two points since we can't
|
||||||
// draw a line for just one point.
|
// draw a line for just one point.
|
||||||
// Skip over series that fall under the minimum value on the X axis.
|
// Skip over series that fall under the minimum value on the X axis.
|
||||||
if got := len(sv.values); got <= 1 || got < int(xdForCap.Scale.Min.Value) {
|
if got := len(sv.values); got <= 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,33 @@ func TestLineChartDraws(t *testing.T) {
|
||||||
return ft
|
return ft
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "empty with just one point",
|
||||||
|
canvas: image.Rect(0, 0, 3, 4),
|
||||||
|
writes: func(lc *LineChart) error {
|
||||||
|
return lc.Series("first", []float64{1})
|
||||||
|
},
|
||||||
|
wantCapacity: 2,
|
||||||
|
want: func(size image.Point) *faketerm.Terminal {
|
||||||
|
ft := faketerm.MustNew(size)
|
||||||
|
c := testcanvas.MustNew(ft.Area())
|
||||||
|
|
||||||
|
// Y and X axis.
|
||||||
|
lines := []draw.HVLine{
|
||||||
|
{Start: image.Point{1, 0}, End: image.Point{1, 2}},
|
||||||
|
{Start: image.Point{1, 2}, End: image.Point{2, 2}},
|
||||||
|
}
|
||||||
|
testdraw.MustHVLines(c, lines)
|
||||||
|
|
||||||
|
// Value labels.
|
||||||
|
testdraw.MustText(c, "…", image.Point{0, 0})
|
||||||
|
testdraw.MustText(c, "0", image.Point{0, 1})
|
||||||
|
testdraw.MustText(c, "0", image.Point{2, 3})
|
||||||
|
|
||||||
|
testcanvas.MustApply(c, ft)
|
||||||
|
return ft
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: "sets axes cell options",
|
desc: "sets axes cell options",
|
||||||
canvas: image.Rect(0, 0, 3, 4),
|
canvas: image.Rect(0, 0, 3, 4),
|
||||||
|
|
|
@ -151,10 +151,11 @@ func YAxisCustomScale(min, max float64) Option {
|
||||||
|
|
||||||
// XAxisUnscaled when provided, stops the LineChart from rescaling the X axis
|
// XAxisUnscaled when provided, stops the LineChart from rescaling the X axis
|
||||||
// when it can't fit all the values in the series, instead the LineCharts only
|
// when it can't fit all the values in the series, instead the LineCharts only
|
||||||
// displays the last n values that fit into its width. This results in hiding
|
// displays the last n values that fit into its width. This is useful to create
|
||||||
// some values from the beginning of the series that didn't fit completely and
|
// an impression of values rolling through the linechart right to left. Note
|
||||||
// might hide some shorter series as this effectively maked the X axis start at
|
// that this results in hiding of values from the beginning of the series
|
||||||
// a non-zero value.
|
// that didn't fit completely and might hide some shorter series as this
|
||||||
|
// effectively makes the X axis start at a non-zero value.
|
||||||
//
|
//
|
||||||
// The default behavior is to rescale the X axis to display all the values.
|
// The default behavior is to rescale the X axis to display all the values.
|
||||||
// This option takes no effect if all the values on the series fit into the
|
// This option takes no effect if all the values on the series fit into the
|
||||||
|
|
Loading…
Reference in New Issue