NewBarChart returns a new bar chart with a single bar for each value. The bars heights correspond to the values and their x locations correspond to the index of their value in the Valuer.
(vs Valuer, width vg.Length)
| 54 | // The bars heights correspond to the values and their x locations correspond |
| 55 | // to the index of their value in the Valuer. |
| 56 | func NewBarChart(vs Valuer, width vg.Length) (*BarChart, error) { |
| 57 | if width <= 0 { |
| 58 | return nil, errors.New("plotter: width parameter was not positive") |
| 59 | } |
| 60 | values, err := CopyValues(vs) |
| 61 | if err != nil { |
| 62 | return nil, err |
| 63 | } |
| 64 | return &BarChart{ |
| 65 | Values: values, |
| 66 | Width: width, |
| 67 | Color: color.Black, |
| 68 | LineStyle: DefaultLineStyle, |
| 69 | }, nil |
| 70 | } |
| 71 | |
| 72 | // BarHeight returns the maximum y value of the |
| 73 | // ith bar, taking into account any bars upon |