Values sets the values to be displayed by the HeatMap. Each value in values has a xLabel and a yLabel, which means len(yLabels) == len(values) and len(xLabels) == len(values[i]). But labels could be empty strings. When no labels are provided, labels will be "0", "1", "2"... Each call to Values ove
(xLabels []string, yLabels []string, values [][]float64, opts ...Option)
| 88 | // Each call to Values overwrites any previously provided values. |
| 89 | // Provided options override values set when New() was called. |
| 90 | func (hp *HeatMap) Values(xLabels []string, yLabels []string, values [][]float64, opts ...Option) error { |
| 91 | clonedValues, minValue, maxValue, err := cloneValues(values) |
| 92 | if err != nil { |
| 93 | return err |
| 94 | } |
| 95 | |
| 96 | nextOpts := *hp.opts |
| 97 | for _, opt := range opts { |
| 98 | opt.set(&nextOpts) |
| 99 | } |
| 100 | if err := nextOpts.validate(); err != nil { |
| 101 | return err |
| 102 | } |
| 103 | |
| 104 | rows := len(clonedValues) |
| 105 | cols := len(clonedValues[0]) |
| 106 | xs, err := normalizeLabels(xLabels, cols) |
| 107 | if err != nil { |
| 108 | return fmt.Errorf("invalid x labels: %w", err) |
| 109 | } |
| 110 | ys, err := normalizeLabels(yLabels, rows) |
| 111 | if err != nil { |
| 112 | return fmt.Errorf("invalid y labels: %w", err) |
| 113 | } |
| 114 | |
| 115 | hp.mu.Lock() |
| 116 | defer hp.mu.Unlock() |
| 117 | hp.values = clonedValues |
| 118 | hp.xLabels = xs |
| 119 | hp.yLabels = ys |
| 120 | hp.minValue = minValue |
| 121 | hp.maxValue = maxValue |
| 122 | hp.opts = &nextOpts |
| 123 | return nil |
| 124 | } |
| 125 | |
| 126 | // ClearXLabels clear the X labels. |
| 127 | func (hp *HeatMap) ClearXLabels() { |