fixing svg renderer
This commit is contained in:
parent
b4dfae683d
commit
1e62f7ce3b
32
style.go
32
style.go
|
@ -149,3 +149,35 @@ func (s Style) SVG(dpi float64) string {
|
|||
}
|
||||
return strings.Join([]string{strokeWidthText, strokeText, fillText, fontSizeText}, ";")
|
||||
}
|
||||
|
||||
// SVGStroke returns the stroke components.
|
||||
func (s Style) SVGStroke() Style {
|
||||
return Style{
|
||||
StrokeColor: s.StrokeColor,
|
||||
StrokeWidth: s.StrokeWidth,
|
||||
}
|
||||
}
|
||||
|
||||
// SVGFill returns the fill components.
|
||||
func (s Style) SVGFill() Style {
|
||||
return Style{
|
||||
FillColor: s.FillColor,
|
||||
}
|
||||
}
|
||||
|
||||
// SVGFillAndStroke returns the fill and stroke components.
|
||||
func (s Style) SVGFillAndStroke() Style {
|
||||
return Style{
|
||||
FillColor: s.FillColor,
|
||||
StrokeColor: s.StrokeColor,
|
||||
StrokeWidth: s.StrokeWidth,
|
||||
}
|
||||
}
|
||||
|
||||
// SVGText returns just the text components of the style.
|
||||
func (s Style) SVGText() Style {
|
||||
return Style{
|
||||
FontColor: s.FontColor,
|
||||
FontSize: s.FontSize,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,12 +35,12 @@ func chartHandler(rc *web.RequestContext) web.ControllerResult {
|
|||
Height: 400,
|
||||
XAxis: chart.XAxis{
|
||||
Style: chart.Style{
|
||||
Show: false,
|
||||
Show: true,
|
||||
},
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: false,
|
||||
Show: true,
|
||||
},
|
||||
Range: chart.Range{
|
||||
Min: 0.0,
|
||||
|
@ -49,7 +49,7 @@ func chartHandler(rc *web.RequestContext) web.ControllerResult {
|
|||
},
|
||||
YAxisSecondary: chart.YAxis{
|
||||
Style: chart.Style{
|
||||
Show: false,
|
||||
Show: true,
|
||||
},
|
||||
Range: chart.Range{
|
||||
Min: 0.8,
|
||||
|
|
|
@ -77,28 +77,22 @@ func (vr *vectorRenderer) Close() {
|
|||
|
||||
// Stroke draws the path with no fill.
|
||||
func (vr *vectorRenderer) Stroke() {
|
||||
vr.s.FillColor = drawing.ColorTransparent
|
||||
vr.s.FontColor = drawing.ColorTransparent
|
||||
vr.drawPath()
|
||||
vr.drawPath(vr.s.SVGStroke())
|
||||
}
|
||||
|
||||
// Fill draws the path with no stroke.
|
||||
func (vr *vectorRenderer) Fill() {
|
||||
vr.s.StrokeColor = drawing.ColorTransparent
|
||||
vr.s.StrokeWidth = 0
|
||||
vr.s.FontColor = drawing.ColorTransparent
|
||||
vr.drawPath()
|
||||
vr.drawPath(vr.s.SVGFill())
|
||||
}
|
||||
|
||||
// FillStroke draws the path with both fill and stroke.
|
||||
func (vr *vectorRenderer) FillStroke() {
|
||||
vr.s.FontColor = drawing.ColorTransparent
|
||||
vr.drawPath()
|
||||
vr.drawPath(vr.s.SVGFillAndStroke())
|
||||
}
|
||||
|
||||
func (vr *vectorRenderer) drawPath() {
|
||||
vr.c.Path(strings.Join(vr.p, "\n"), vr.s.SVG(vr.dpi))
|
||||
vr.p = []string{}
|
||||
func (vr *vectorRenderer) drawPath(s Style) {
|
||||
vr.c.Path(strings.Join(vr.p, "\n"), s.SVG(vr.dpi))
|
||||
vr.p = []string{} // clear the path
|
||||
}
|
||||
|
||||
// Circle implements the interface method.
|
||||
|
@ -134,10 +128,8 @@ func (vr *vectorRenderer) svgFontFace() string {
|
|||
|
||||
// Text draws a text blob.
|
||||
func (vr *vectorRenderer) Text(body string, x, y int) {
|
||||
vr.s.FillColor = drawing.ColorTransparent
|
||||
vr.s.StrokeColor = drawing.ColorTransparent
|
||||
vr.s.StrokeWidth = 0
|
||||
vr.c.Text(x, y, body, vr.s.SVG(vr.dpi)+";"+vr.svgFontFace())
|
||||
s := vr.s.SVGText()
|
||||
vr.c.Text(x, y, body, s.SVG(vr.dpi)+";"+vr.svgFontFace())
|
||||
}
|
||||
|
||||
// MeasureText uses the truetype font drawer to measure the width of text.
|
||||
|
|
4
yaxis.go
4
yaxis.go
|
@ -66,7 +66,9 @@ func (ya YAxis) generateTicksWithStep(ra Range, step float64, vf ValueFormatter)
|
|||
func (ya YAxis) Render(r Renderer, canvasBox Box, ra Range, axisType YAxisType, ticks []Tick) {
|
||||
r.SetStrokeColor(ya.Style.GetStrokeColor(DefaultAxisColor))
|
||||
r.SetStrokeWidth(ya.Style.GetStrokeWidth(DefaultAxisLineWidth))
|
||||
r.SetFontColor(ya.Style.GetFontColor(DefaultAxisColor))
|
||||
|
||||
fontColor := ya.Style.GetFontColor(DefaultAxisColor)
|
||||
r.SetFontColor(fontColor)
|
||||
fontSize := ya.Style.GetFontSize(DefaultFontSize)
|
||||
r.SetFontSize(fontSize)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user