sbc looking alright, need to debug bar gaps at the bottom

This commit is contained in:
Will Charczuk 2016-07-29 19:38:37 -07:00
parent e44cdd5600
commit 1269397821
2 changed files with 7 additions and 3 deletions

View File

@ -26,9 +26,9 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
{Value: 5, Label: "Blue"},
{Value: 5, Label: "Green"},
{Value: 4, Label: "Gray"},
{Value: 4, Label: "Orange"},
{Value: 3, Label: "Orange"},
{Value: 3, Label: "Test"},
{Value: 3, Label: "??"},
{Value: 2, Label: "??"},
{Value: 1, Label: "!!"},
},
},

View File

@ -197,13 +197,17 @@ func (sbc StackedBarChart) drawYAxis(r Renderer, canvasBox Box) {
ticks := Sequence.Float64(1.0, 0.0, 0.2)
for _, t := range ticks {
axisStyle.GetStrokeOptions().WriteToRenderer(r)
ty := canvasBox.Bottom - int(t*float64(canvasBox.Height()))
r.MoveTo(canvasBox.Right, ty)
r.LineTo(canvasBox.Right+DefaultHorizontalTickWidth, ty)
r.Stroke()
axisStyle.GetTextOptions().WriteToRenderer(r)
text := fmt.Sprintf("%0.0f%%", t*100)
Draw.Text(r, text, canvasBox.Right+DefaultYAxisMargin, ty, axisStyle)
tb := r.MeasureText(text)
Draw.Text(r, text, canvasBox.Right+DefaultYAxisMargin+5, ty+(tb.Height()>>1), axisStyle)
}
}