bug fixes and refinements.
This commit is contained in:
parent
52e80c183d
commit
debd56f494
|
@ -55,9 +55,9 @@ func TestAnnotationSeriesMeasure(t *testing.T) {
|
|||
|
||||
box := as.Measure(r, cb, xrange, yrange, sd)
|
||||
assert.False(box.IsZero())
|
||||
assert.Equal(-5.0, box.Top)
|
||||
assert.Equal(-3.0, box.Top)
|
||||
assert.Equal(5.0, box.Left)
|
||||
assert.Equal(146.0, box.Right) //the top,left annotation sticks up 5px and out ~44px.
|
||||
assert.Equal(147.0, box.Right) //the top,left annotation sticks up 5px and out ~44px.
|
||||
assert.Equal(115.0, box.Bottom)
|
||||
}
|
||||
|
||||
|
@ -114,10 +114,10 @@ func TestAnnotationSeriesRender(t *testing.T) {
|
|||
assert.True(isRaster)
|
||||
assert.NotNil(rr)
|
||||
|
||||
c := rr.i.At(39, 70)
|
||||
c := rr.i.At(38, 70)
|
||||
converted, isRGBA := color.RGBAModel.Convert(c).(color.RGBA)
|
||||
assert.True(isRGBA)
|
||||
assert.Equal(3, converted.R)
|
||||
assert.Equal(3, converted.G)
|
||||
assert.Equal(3, converted.B)
|
||||
assert.Equal(0, converted.R)
|
||||
assert.Equal(0, converted.G)
|
||||
assert.Equal(0, converted.B)
|
||||
}
|
||||
|
|
15
chart.go
15
chart.go
|
@ -144,7 +144,7 @@ func (c Chart) getRanges() (xrange, yrange, yrangeAlt Range) {
|
|||
} else {
|
||||
xrange.Min = globalMinX
|
||||
xrange.Max = globalMaxX
|
||||
xrange.Min, xrange.Max = xrange.GetRoundedRangeBounds()
|
||||
//xrange.Min, xrange.Max = xrange.GetRoundedRangeBounds()
|
||||
}
|
||||
|
||||
if !c.YAxis.Range.IsZero() {
|
||||
|
@ -285,11 +285,14 @@ func (c Chart) getAxisAdjustedCanvasBox(r Renderer, canvasBox Box, xr, yr, yra R
|
|||
return newBox
|
||||
}
|
||||
|
||||
func (c Chart) setRangeDomains(canvasBox Box, xrange, yrange, yrangeAlt Range) (Range, Range, Range) {
|
||||
xrange.Domain = canvasBox.Width
|
||||
yrange.Domain = canvasBox.Height
|
||||
yrangeAlt.Domain = canvasBox.Height
|
||||
return xrange, yrange, yrangeAlt
|
||||
func (c Chart) setRangeDomains(canvasBox Box, xr, yr, yra Range) (xr2, yr2, yra2 Range) {
|
||||
xr2.Min, xr2.Max = xr.Min, xr.Max
|
||||
xr2.Domain = canvasBox.Width
|
||||
yr2.Min, yr2.Max = yr.Min, yr.Max
|
||||
yr2.Domain = canvasBox.Height
|
||||
yra2.Min, yra2.Max = yra.Min, yra.Max
|
||||
yra2.Domain = canvasBox.Height
|
||||
return
|
||||
}
|
||||
|
||||
func (c Chart) hasAnnotationSeries() bool {
|
||||
|
|
|
@ -8,8 +8,15 @@ import (
|
|||
|
||||
func TestRangeTranslate(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
values := []float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}
|
||||
values := []float64{1.0, 2.0, 2.5, 2.7, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}
|
||||
r := Range{Domain: 1000}
|
||||
r.Min, r.Max = MinAndMax(values...)
|
||||
assert.Equal(428, r.Translate(5.0))
|
||||
|
||||
// delta = ~7.0
|
||||
// value = ~5.0
|
||||
// domain = ~1000
|
||||
// 5/8 * 1000 ~=
|
||||
assert.Equal(0, r.Translate(1.0))
|
||||
assert.Equal(1000, r.Translate(8.0))
|
||||
assert.Equal(572, r.Translate(5.0))
|
||||
}
|
||||
|
|
2
tick.go
2
tick.go
|
@ -3,7 +3,7 @@ package chart
|
|||
// GenerateTicksWithStep generates a set of ticks.
|
||||
func GenerateTicksWithStep(ra Range, step float64, vf ValueFormatter) []Tick {
|
||||
var ticks []Tick
|
||||
min, max := ra.GetRoundedRangeBounds()
|
||||
min, max := ra.Min, ra.Max
|
||||
for cursor := min; cursor <= max; cursor += step {
|
||||
ticks = append(ticks, Tick{
|
||||
Value: cursor,
|
||||
|
|
|
@ -10,5 +10,5 @@ func TestGenerateTicksWithStep(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
|
||||
ticks := GenerateTicksWithStep(Range{Min: 1.0, Max: 10.0, Domain: 100}, 1.0, FloatValueFormatter)
|
||||
assert.Len(ticks, 9)
|
||||
assert.Len(ticks, 10)
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func TestVectorRendererMeasureText(t *testing.T) {
|
|||
vr.SetFont(f)
|
||||
vr.SetFontSize(12.0)
|
||||
|
||||
w, h := vr.MeasureText("Ljp")
|
||||
assert.Equal(21, w)
|
||||
assert.Equal(15, h)
|
||||
tb := vr.MeasureText("Ljp")
|
||||
assert.Equal(21, tb.Width)
|
||||
assert.Equal(15, tb.Height)
|
||||
}
|
||||
|
|
4
yaxis.go
4
yaxis.go
|
@ -122,10 +122,10 @@ func (ya YAxis) Render(r Renderer, canvasBox Box, ra Range, ticks []Tick) {
|
|||
var tx int
|
||||
if ya.AxisType == YAxisPrimary {
|
||||
lx = canvasBox.Right
|
||||
tx = canvasBox.Right + DefaultYAxisMargin
|
||||
tx = lx + DefaultYAxisMargin
|
||||
} else if ya.AxisType == YAxisSecondary {
|
||||
lx = canvasBox.Left
|
||||
tx = canvasBox.Left - DefaultYAxisMargin
|
||||
tx = lx - DefaultYAxisMargin
|
||||
}
|
||||
|
||||
r.MoveTo(lx, canvasBox.Bottom)
|
||||
|
|
Loading…
Reference in New Issue
Block a user