-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_values.go
30 lines (26 loc) · 866 Bytes
/
update_values.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package charts
import (
"github.com/cnguy/gopherjs-frappe-charts/utils"
"github.com/gopherjs/gopherjs/js"
)
// UpdateValuesArgs is a wrapper that contains the two parameters
// that chart.update_values(values, labels) requires.
// https://frappe.github.io/charts/
// Ctrl + F "update_values"
type UpdateValuesArgs struct {
Values []*UpdateValueSet
Labels []string
}
// UpdateValueSet represents the JS object frappe-chart uses
// as parameters for chart.update_values(values, labels).
// e.g. { values: [1, 2, 3, 4] }
type UpdateValueSet struct {
*js.Object
Values []interface{} `js:"values"`
}
// NewUpdateValueSet is a helper to conveniently create an UpdateValueSet.
func NewUpdateValueSet(values []float64) *UpdateValueSet {
new := &UpdateValueSet{Object: js.Global.Get("Object").New()}
new.Values = utils.FloatSliceToInterface(values)
return new
}