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

Method Add

widgets/sparkline/sparkline.go:225–240  ·  view source on GitHub ↗

Add adds data points to the SparkLine. Each data point is represented by one bar on the SparkLine. Zero value data points are valid and are represented by an empty space on the SparkLine (i.e. a missing bar). At least one data point must be provided. All data points must be positive integers. The

(data []int, opts ...Option)

Source from the content-addressed store, hash-verified

223//
224// Provided options override values set when New() was called.
225func (sl *SparkLine) Add(data []int, opts ...Option) error {
226 sl.mu.Lock()
227 defer sl.mu.Unlock()
228
229 for _, opt := range opts {
230 opt.set(sl.opts)
231 }
232
233 for i, d := range data {
234 if d < 0 {
235 return fmt.Errorf("data point[%d]: %v must be a positive integer", i, d)
236 }
237 }
238 sl.data = append(sl.data, data...)
239 return nil
240}
241
242// Clear removes all the data points in the SparkLine, effectively returning to
243// an empty graph.

Callers 13

WriteMethod · 0.45
mainFunction · 0.45
TestSparkLineFunction · 0.45
playSparkLineFunction · 0.45
fillSparkLineFunction · 0.45
mainFunction · 0.45
newTestDemoContainerFunction · 0.45

Calls 1

setMethod · 0.65