fixing bug with annotations with axis turned off.
This commit is contained in:
parent
7e876eadf4
commit
9aa2a45a39
5 changed files with 186 additions and 15 deletions
|
|
@ -29,10 +29,49 @@ func (as AnnotationSeries) GetYAxis() YAxisType {
|
|||
return as.YAxis
|
||||
}
|
||||
|
||||
// Measure returns a bounds box of the series.
|
||||
func (as AnnotationSeries) Measure(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) Box {
|
||||
box := Box{
|
||||
Top: canvasBox.Bottom,
|
||||
Left: canvasBox.Right,
|
||||
Right: canvasBox.Left,
|
||||
Bottom: canvasBox.Top,
|
||||
}
|
||||
if as.Style.Show {
|
||||
style := as.Style.WithDefaultsFrom(Style{
|
||||
Font: defaults.Font,
|
||||
FillColor: DefaultAnnotationFillColor,
|
||||
FontSize: DefaultAnnotationFontSize,
|
||||
StrokeColor: defaults.StrokeColor,
|
||||
StrokeWidth: defaults.StrokeWidth,
|
||||
Padding: DefaultAnnotationPadding,
|
||||
})
|
||||
for _, a := range as.Annotations {
|
||||
lx := canvasBox.Right - xrange.Translate(a.X)
|
||||
ly := yrange.Translate(a.Y) + canvasBox.Top
|
||||
aBox := MeasureAnnotation(r, canvasBox, xrange, yrange, style, lx, ly, a.Label)
|
||||
if aBox.Top < box.Top {
|
||||
box.Top = aBox.Top
|
||||
}
|
||||
if aBox.Left < box.Left {
|
||||
box.Left = aBox.Left
|
||||
}
|
||||
if aBox.Right > box.Right {
|
||||
box.Right = aBox.Right
|
||||
}
|
||||
if aBox.Bottom > box.Bottom {
|
||||
box.Bottom = aBox.Bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
return box
|
||||
}
|
||||
|
||||
// Render draws the series.
|
||||
func (as AnnotationSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) {
|
||||
if as.Style.Show {
|
||||
style := as.Style.WithDefaultsFrom(Style{
|
||||
Font: defaults.Font,
|
||||
FillColor: DefaultAnnotationFillColor,
|
||||
FontSize: DefaultAnnotationFontSize,
|
||||
StrokeColor: defaults.StrokeColor,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue