go-plotly
go-plotly copied to clipboard
enable using all features of array types
@MetalBlueberry
as requested, separated out in a separate PR the change to enable array types as in JS
Enable using array types:
examples/scatter/scatter.html
@MetalBlueberry ready for review
I see the problem here, but I think we can find a better solution than just using interface everywhere.
here is one proposal I just came up with. but it looks promissing.
- https://github.com/MetalBlueberry/go-plotly/pull/24
We can provably predefine most of the types.
OR would it work with generics? maybe a generic function will solve our problems :blush:
@MetalBlueberry thanks for checking it and your suggestions. Not sure how generics could help here unfortunately since we can have valuetype (string, int, float), we can have arrays ([]string, []int, []float) and then the pointers as well, which we need to represent nil
So it's almost like we need something like
type ArrayElement struct {
IsValid bool // if false -> value is marshalled as 'nil'
Text string
Num float64
}
// type to use for arrayOK types
type Array []ArrayElement
I'm not convinced yet of this solution as well though.
This has been merged already, Thank you :heart: