diff --git a/_examples/scatter/main.go b/_examples/scatter/main.go index 9aed893..4417d0d 100644 --- a/_examples/scatter/main.go +++ b/_examples/scatter/main.go @@ -16,26 +16,8 @@ func drawChart(res http.ResponseWriter, req *http.Request) { StrokeWidth: chart.Disabled, DotWidth: 3, }, - XValues: chart.Sequence.Random(32, 1024), - YValues: chart.Sequence.Random(32, 1024), - }, - chart.ContinuousSeries{ - Style: chart.Style{ - Show: true, - StrokeWidth: chart.Disabled, - DotWidth: 5, - }, - XValues: chart.Sequence.Random(16, 1024), - YValues: chart.Sequence.Random(16, 1024), - }, - chart.ContinuousSeries{ - Style: chart.Style{ - Show: true, - StrokeWidth: chart.Disabled, - DotWidth: 7, - }, - XValues: chart.Sequence.Random(8, 1024), - YValues: chart.Sequence.Random(8, 1024), + XValues: chart.Sequence.Random(4096, 1024), + YValues: chart.Sequence.Random(4096, 1024), }, }, } diff --git a/chart.go b/chart.go index 47597ed..ed91b8d 100644 --- a/chart.go +++ b/chart.go @@ -98,11 +98,11 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error { xr, yr, yra := c.getRanges() canvasBox := c.getDefaultCanvasBox() xf, yf, yfa := c.getValueFormatters() + xr, yr, yra = c.setRangeDomains(canvasBox, xr, yr, yra) err = c.checkRanges(xr, yr, yra) if err != nil { - // (try to) dump the raw background to the stream. r.Save(w) return err } @@ -260,11 +260,15 @@ func (c Chart) getRanges() (xrange, yrange, yrangeAlt Range) { yrange.SetMin(miny) yrange.SetMax(maxy) - delta := yrange.GetDelta() - roundTo := Math.GetRoundToForDelta(delta) - rmin, rmax := Math.RoundDown(yrange.GetMin(), roundTo), Math.RoundUp(yrange.GetMax(), roundTo) - yrange.SetMin(rmin) - yrange.SetMax(rmax) + // only round if we're showing the axis + if c.YAxis.Style.Show { + delta := yrange.GetDelta() + roundTo := Math.GetRoundToForDelta(delta) + rmin, rmax := Math.RoundDown(yrange.GetMin(), roundTo), Math.RoundUp(yrange.GetMax(), roundTo) + + yrange.SetMin(rmin) + yrange.SetMax(rmax) + } } if len(c.YAxisSecondary.Ticks) > 0 { diff --git a/defaults.go b/defaults.go index f4d773e..37bdc5a 100644 --- a/defaults.go +++ b/defaults.go @@ -205,6 +205,7 @@ func GetAlternateColor(index int) drawing.Color { var ( // DefaultAnnotationPadding is the padding around an annotation. DefaultAnnotationPadding = Box{Top: 5, Left: 5, Right: 5, Bottom: 5} + // DefaultBackgroundPadding is the default canvas padding config. DefaultBackgroundPadding = Box{Top: 5, Left: 5, Right: 5, Bottom: 5} )