MCPcopy
hub / github.com/mum4k/termdash / Draw

Method Draw

widgets/heatmap/heatmap.go:176–200  ·  view source on GitHub ↗

Draw draws cells, X labels and Y labels as HeatMap. Implements widgetapi.Widget.Draw.

(cvs *canvas.Canvas, meta *widgetapi.Meta)

Source from the content-addressed store, hash-verified

174// Draw draws cells, X labels and Y labels as HeatMap.
175// Implements widgetapi.Widget.Draw.
176func (hp *HeatMap) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error {
177 _ = meta
178
179 hp.mu.Lock()
180 defer hp.mu.Unlock()
181
182 hp.lastWidth = cvs.Area().Dx()
183 hp.lastCapacity = hp.visibleCapacity(cvs.Area().Size())
184
185 if len(hp.values) == 0 {
186 return nil
187 }
188 if need := hp.minSize(); need.X > cvs.Area().Dx() || need.Y > cvs.Area().Dy() {
189 return draw.ResizeNeeded(cvs)
190 }
191
192 xd, yd, err := hp.axesDetails(cvs)
193 if err != nil {
194 return err
195 }
196 if err := hp.drawCells(cvs, xd, yd); err != nil {
197 return err
198 }
199 return hp.drawLabels(cvs, xd, yd)
200}
201
202// drawCells draws m*n cells (rectangles) representing the stored values.
203// The height of each cell is 1 and the default width is 3.

Callers

nothing calls this directly

Calls 8

visibleCapacityMethod · 0.95
minSizeMethod · 0.95
axesDetailsMethod · 0.95
drawCellsMethod · 0.95
drawLabelsMethod · 0.95
ResizeNeededFunction · 0.92
SizeMethod · 0.65
AreaMethod · 0.45

Tested by

no test coverage detected