Helper API refactor (#40)

* api cleaup

* updates

* wtf

* updates

* snapshot.

* tweaks

* snapshot

* api tweaks.

* updates

* updates

* updates

* changes.

* updates

* updates

* sequence => seq

* dont need to use curl, just using wget

* fixing examples
This commit is contained in:
Will Charczuk 2017-05-12 17:12:23 -07:00 committed by GitHub
parent 43212f871f
commit 03708a90ef
100 changed files with 1687 additions and 1055 deletions

View file

@ -7,6 +7,8 @@ import (
"math"
"github.com/golang/freetype/truetype"
"github.com/wcharczuk/go-chart/seq"
util "github.com/wcharczuk/go-chart/util"
)
// StackedBar is a bar within a StackedBarChart.
@ -145,7 +147,7 @@ func (sbc StackedBarChart) drawBar(r Renderer, canvasBox Box, xoffset int, bar S
Top: yoffset,
Left: bxl,
Right: bxr,
Bottom: Math.MinInt(yoffset+barHeight, canvasBox.Bottom-DefaultStrokeWidth),
Bottom: util.Math.MinInt(yoffset+barHeight, canvasBox.Bottom-DefaultStrokeWidth),
}
Draw.Box(r, barBox, bv.Style.InheritFrom(sbc.styleDefaultsStackedBarValue(index)))
yoffset += barHeight
@ -200,7 +202,7 @@ func (sbc StackedBarChart) drawYAxis(r Renderer, canvasBox Box) {
r.LineTo(canvasBox.Right+DefaultHorizontalTickWidth, canvasBox.Bottom)
r.Stroke()
ticks := Sequence.Float64(1.0, 0.0, 0.2)
ticks := seq.RangeWithStep(0.0, 1.0, 0.2)
for _, t := range ticks {
axisStyle.GetStrokeOptions().WriteToRenderer(r)
ty := canvasBox.Bottom - int(t*float64(canvasBox.Height()))
@ -252,7 +254,7 @@ func (sbc StackedBarChart) getAdjustedCanvasBox(r Renderer, canvasBox Box) Box {
lines := Text.WrapFit(r, bar.Name, barLabelBox.Width(), axisStyle)
linesBox := Text.MeasureLines(r, lines, axisStyle)
xaxisHeight = Math.MaxInt(linesBox.Height()+(2*DefaultXAxisMargin), xaxisHeight)
xaxisHeight = util.Math.MaxInt(linesBox.Height()+(2*DefaultXAxisMargin), xaxisHeight)
}
}
return Box{
@ -304,7 +306,7 @@ func (sbc StackedBarChart) styleDefaultsTitle() Style {
}
func (sbc StackedBarChart) getTitleFontSize() float64 {
effectiveDimension := Math.MinInt(sbc.GetWidth(), sbc.GetHeight())
effectiveDimension := util.Math.MinInt(sbc.GetWidth(), sbc.GetHeight())
if effectiveDimension >= 2048 {
return 48
} else if effectiveDimension >= 1024 {