tests pass
This commit is contained in:
parent
fa93bd8abb
commit
781a45d770
5 changed files with 35 additions and 5 deletions
11
chart.go
11
chart.go
|
@ -103,6 +103,8 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error {
|
|||
canvasBox := c.getDefaultCanvasBox()
|
||||
xf, yf, yfa := c.getValueFormatters()
|
||||
|
||||
Debugf(c.Log, "chart; canvas box: %v", canvasBox)
|
||||
|
||||
xr, yr, yra = c.setRangeDomains(canvasBox, xr, yr, yra)
|
||||
|
||||
err = c.checkRanges(xr, yr, yra)
|
||||
|
@ -116,6 +118,8 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error {
|
|||
canvasBox = c.getAxesAdjustedCanvasBox(r, canvasBox, xr, yr, yra, xt, yt, yta)
|
||||
xr, yr, yra = c.setRangeDomains(canvasBox, xr, yr, yra)
|
||||
|
||||
Debugf(c.Log, "chart; axes adjusted canvas box: %v", canvasBox)
|
||||
|
||||
// do a second pass in case things haven't settled yet.
|
||||
xt, yt, yta = c.getAxesTicks(r, xr, yr, yra, xf, yf, yfa)
|
||||
canvasBox = c.getAxesAdjustedCanvasBox(r, canvasBox, xr, yr, yra, xt, yt, yta)
|
||||
|
@ -126,6 +130,8 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error {
|
|||
canvasBox = c.getAnnotationAdjustedCanvasBox(r, canvasBox, xr, yr, yra, xf, yf, yfa)
|
||||
xr, yr, yra = c.setRangeDomains(canvasBox, xr, yr, yra)
|
||||
xt, yt, yta = c.getAxesTicks(r, xr, yr, yra, xf, yf, yfa)
|
||||
|
||||
Debugf(c.Log, "chart; annotation adjusted canvas box: %v", canvasBox)
|
||||
}
|
||||
|
||||
c.drawCanvas(r, canvasBox)
|
||||
|
@ -382,14 +388,17 @@ func (c Chart) getAxesAdjustedCanvasBox(r Renderer, canvasBox Box, xr, yr, yra R
|
|||
axesOuterBox := canvasBox.Clone()
|
||||
if !c.XAxis.Style.Hidden {
|
||||
axesBounds := c.XAxis.Measure(r, canvasBox, xr, c.styleDefaultsAxes(), xticks)
|
||||
Debugf(c.Log, "chart; x-axis measured %v", axesBounds)
|
||||
axesOuterBox = axesOuterBox.Grow(axesBounds)
|
||||
}
|
||||
if !c.YAxis.Style.Hidden {
|
||||
axesBounds := c.YAxis.Measure(r, canvasBox, yr, c.styleDefaultsAxes(), yticks)
|
||||
Debugf(c.Log, "chart; y-axis measured %v", axesBounds)
|
||||
axesOuterBox = axesOuterBox.Grow(axesBounds)
|
||||
}
|
||||
if !c.YAxisSecondary.Style.Hidden {
|
||||
if !c.YAxisSecondary.Style.Hidden && c.hasSecondarySeries() {
|
||||
axesBounds := c.YAxisSecondary.Measure(r, canvasBox, yra, c.styleDefaultsAxes(), yticksAlt)
|
||||
Debugf(c.Log, "chart; y-axis secondary measured %v", axesBounds)
|
||||
axesOuterBox = axesOuterBox.Grow(axesBounds)
|
||||
}
|
||||
|
||||
|
|
|
@ -484,8 +484,12 @@ func TestChartE2ELine(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
|
||||
c := Chart{
|
||||
Height: 50,
|
||||
Width: 50,
|
||||
Height: 50,
|
||||
Width: 50,
|
||||
TitleStyle: Hidden(),
|
||||
XAxis: HideXAxis(),
|
||||
YAxis: HideYAxis(),
|
||||
YAxisSecondary: HideYAxis(),
|
||||
Canvas: Style{
|
||||
Padding: BoxZero,
|
||||
},
|
||||
|
@ -532,6 +536,10 @@ func TestChartE2ELineWithFill(t *testing.T) {
|
|||
Background: Style{
|
||||
Padding: BoxZero,
|
||||
},
|
||||
TitleStyle: Hidden(),
|
||||
XAxis: HideXAxis(),
|
||||
YAxis: HideYAxis(),
|
||||
YAxisSecondary: HideYAxis(),
|
||||
Series: []Series{
|
||||
ContinuousSeries{
|
||||
Style: Style{
|
||||
|
@ -542,6 +550,7 @@ func TestChartE2ELineWithFill(t *testing.T) {
|
|||
YValues: LinearRangeWithStep(0, 4, 1),
|
||||
},
|
||||
},
|
||||
Log: NewLogger(),
|
||||
}
|
||||
|
||||
assert.Equal(5, len(c.Series[0].(ContinuousSeries).XValues))
|
||||
|
@ -551,8 +560,6 @@ func TestChartE2ELineWithFill(t *testing.T) {
|
|||
err := c.Render(PNG, buffer)
|
||||
assert.Nil(err)
|
||||
|
||||
// do color tests ...
|
||||
|
||||
i, err := png.Decode(buffer)
|
||||
assert.Nil(err)
|
||||
|
||||
|
|
BIN
e2efill.png
Executable file
BIN
e2efill.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
7
xaxis.go
7
xaxis.go
|
@ -4,6 +4,13 @@ import (
|
|||
"math"
|
||||
)
|
||||
|
||||
// HideXAxis hides the x-axis.
|
||||
func HideXAxis() XAxis {
|
||||
return XAxis{
|
||||
Style: Hidden(),
|
||||
}
|
||||
}
|
||||
|
||||
// XAxis represents the horizontal axis.
|
||||
type XAxis struct {
|
||||
Name string
|
||||
|
|
7
yaxis.go
7
yaxis.go
|
@ -4,6 +4,13 @@ import (
|
|||
"math"
|
||||
)
|
||||
|
||||
// HideYAxis hides a y-axis.
|
||||
func HideYAxis() YAxis {
|
||||
return YAxis{
|
||||
Style: Hidden(),
|
||||
}
|
||||
}
|
||||
|
||||
// YAxis is a veritcal rule of the range.
|
||||
// There can be (2) y-axes; a primary and secondary.
|
||||
type YAxis struct {
|
||||
|
|
Loading…
Reference in a new issue