MCPcopy Index your code
hub / github.com/gonum/plot / Rectangle

Method Rectangle

legend.go:144–171  ·  view source on GitHub ↗

Rectangle returns the extent of the Legend.

(c draw.Canvas)

Source from the content-addressed store, hash-verified

142
143// Rectangle returns the extent of the Legend.
144func (l *Legend) Rectangle(c draw.Canvas) vg.Rectangle {
145 var width, height vg.Length
146 sty := l.TextStyle
147 entryHeight := l.entryHeight()
148 for i, e := range l.entries {
149 width = vg.Length(math.Max(float64(width), float64(l.ThumbnailWidth+sty.Rectangle(" "+e.text).Max.X)))
150 height += entryHeight
151 if i != 0 {
152 height += l.Padding
153 }
154 }
155 var r vg.Rectangle
156 if l.Left {
157 r.Max.X = c.Max.X
158 r.Min.X = c.Max.X - width
159 } else {
160 r.Max.X = c.Min.X + width
161 r.Min.X = c.Min.X
162 }
163 if l.Top {
164 r.Max.Y = c.Max.Y
165 r.Min.Y = c.Max.Y - height
166 } else {
167 r.Max.Y = c.Min.Y + height
168 r.Min.Y = c.Min.Y
169 }
170 return r
171}
172
173// entryHeight returns the height of the tallest legend
174// entry text.

Callers 15

ExampleLegend_standaloneFunction · 0.95
ExampleHeatMapFunction · 0.95
DrawMethod · 0.45
entryHeightMethod · 0.45
GlyphBoxesMethod · 0.45
GlyphBoxesMethod · 0.45
tickLabelHeightFunction · 0.45
tickLabelWidthFunction · 0.45
DrawMethod · 0.45
DataCanvasMethod · 0.45
DrawGlyphBoxesMethod · 0.45
GlyphBoxesMethod · 0.45

Calls 2

entryHeightMethod · 0.95
MaxMethod · 0.65

Tested by 2

ExampleLegend_standaloneFunction · 0.76
ExampleHeatMapFunction · 0.76