Hi all,
(Disclosure: QML & go-qml n00b! :) )
I'd appreciate a bit of guidance on how to pass data structures from Go to QML so that they can be used by QML-side JavaScript code.
The Chart.js code expects JavaScript objects as graph data arguments, e.g. for a pie chart you would use a JS object like this:
(NB: JavaScript)
var ChartPieData = [ |
| { |
| value: 300, |
| color:"#F7464A", |
| highlight: "#FF5A5E", |
| label: "Red" |
| }, |
| { |
| value: 50, |
| color: "#46BFBD", |
| highlight: "#5AD3D1", |
| label: "Green" |
| }
] |
Other Chart.js graph types use more complicated objects as graph data parameter.
Any tips about how I should code this up as a data structure in Go, and how I should pass the data into QML (e.g. via Object.SetVar(), Object.Call(), etc) so that the Chart.js JavaScript code can understand it?
I've tried various combinations of Go structs, slices, etc., but these don't seem to be 'understood' by the Chart.js code. I read elsewhere in this group about marshalling/unmarshalling via JSON strings - but is there a better way?
Thanks,
Tim.