Skip to content

Commit 86e39c9

Browse files
Implement Nilable values
1 parent ea40026 commit 86e39c9

File tree

223 files changed

+22799
-22750
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+22799
-22750
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Currently, most common use cases should be already covered. Feel free to create
9090
- [x] Frames
9191
- [ ] defs
9292
- [ ] defs valobjects
93-
- [ ] angle
93+
- [ ] angle **needs validations**
9494
- [x] any
9595
- [x] boolean
9696
- [x] color
@@ -100,12 +100,12 @@ Currently, most common use cases should be already covered. Feel free to create
100100
- [x] enumerated
101101
- [x] flaglist
102102
- [ ] info_array
103-
- [ ] integer **Needs support for nil values**
104-
- [ ] number **Needs support for nil values**
103+
- [x] integer
104+
- [x] number
105105
- [x] string
106106
- [ ] subplotid
107107
- [ ] defs_modifier
108-
- [ ] arrayOK
108+
- [x] arrayOK
109109
- [ ] min/max validations
110110
- [x] dflt **This is not needed in the output, as plotly will do it. But it would be nice to have a method to fetch it**
111111
- [ ] noBlank validation

examples/animation/animation.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ func main() {
5959
},
6060
Updatemenus: []grob.LayoutUpdatemenu{
6161
{
62-
Type: "buttons",
62+
Type: grob.UpdatemenuTypeButtons,
6363
Showactive: types.False,
6464
Buttons: []grob.UpdatemenuButton{
6565
{
66-
Label: "Play",
67-
Method: "animate",
66+
Label: types.S("Play"),
67+
Method: grob.ButtonMethodAnimate,
6868
Args: []*ButtonArgs{
6969
nil,
7070
{
@@ -80,11 +80,11 @@ func main() {
8080
Frames: frames,
8181
Animation: &grob.Animation{
8282
Transition: &grob.AnimationTransition{
83-
Duration: 500,
83+
Duration: types.N(500),
8484
Easing: grob.AnimationTransitionEasingCubicInOut,
8585
},
8686
Frame: &grob.AnimationFrame{
87-
Duration: 500,
87+
Duration: types.N(500),
8888
Redraw: types.True,
8989
},
9090
},

examples/bar_custom/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ func main() {
6161
Color: types.ArrayOKValue(types.UseColor(types.Color(
6262
markerColor.Hex(), // Use colorfull
6363
))),
64-
Opacity: types.ArrayOKValue(0.6),
64+
Opacity: types.ArrayOKValue(types.N(0.6)),
6565
Line: &grob.BarMarkerLine{
6666
Color: types.ArrayOKValue(types.UseColor("rgb(8,48,107)")), // Or just write the string
67-
Width: types.ArrayOKValue(1.5),
67+
Width: types.ArrayOKValue(types.N(1.5)),
6868
},
6969
},
7070
}
7171

7272
layout := &grob.Layout{
7373
Title: &grob.LayoutTitle{
74-
Text: "A Figure Specified By Go Struct",
74+
Text: types.S("A Figure Specified By Go Struct"),
7575
},
7676
}
7777

@@ -84,10 +84,10 @@ func main() {
8484
offline.Show(fig)
8585
}
8686

87-
func toString(in []int) []types.String {
88-
out := make([]types.String, len(in))
87+
func toString(in []int) []types.StringType {
88+
out := make([]types.StringType, len(in))
8989
for i := range in {
90-
out[i] = strconv.Itoa(in[i])
90+
out[i] = types.S(strconv.Itoa(in[i]))
9191
}
9292
return out
9393
}

examples/colorscale/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ func main() {
2323
Marker: &grob.Scatter3dMarker{
2424
Autocolorscale: types.False,
2525
Cauto: types.False,
26-
Cmin: 0,
27-
Cmid: 5,
28-
Cmax: 10,
26+
Cmin: types.N(0),
27+
Cmid: types.N(5),
28+
Cmax: types.N(10),
2929
Color: types.ArrayOKArray(types.UseColorScaleValues(z)...),
3030
Colorscale: &types.ColorScale{
3131
Values: []types.ColorScaleReference{
@@ -43,15 +43,15 @@ func main() {
4343
},
4444
},
4545
Showscale: types.True,
46-
Size: types.ArrayOKValue(4.0),
46+
Size: types.ArrayOKValue(types.N(4.0)),
4747
},
4848
},
4949
},
5050
Layout: &grob.Layout{
51-
Height: 700,
52-
Width: 1200,
51+
Height: types.N(700),
52+
Width: types.N(1200),
5353
Title: &grob.LayoutTitle{
54-
Text: "3D Spiral",
54+
Text: types.S("3D Spiral"),
5555
},
5656
},
5757
}

examples/range_slider/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,32 +86,32 @@ func main() {
8686

8787
fig.Layout = &grob.Layout{
8888
Title: &grob.LayoutTitle{
89-
Text: "Time series with range slider and selectors",
89+
Text: types.S("Time series with range slider and selectors"),
9090
},
9191
Xaxis: &grob.LayoutXaxis{
9292
Rangeselector: &grob.LayoutXaxisRangeselector{
9393
Buttons: []grob.LayoutXaxisRangeselectorButton{
9494
{
95-
Count: 1,
96-
Label: "1m",
95+
Count: types.N(1),
96+
Label: types.S("1m"),
9797
Step: "month",
9898
Stepmode: "backward",
9999
},
100100
{
101-
Count: 6,
102-
Label: "6m",
101+
Count: types.N(6),
102+
Label: types.S("6m"),
103103
Step: "month",
104104
Stepmode: "backward",
105105
},
106106
{
107-
Count: 1,
108-
Label: "YTD",
107+
Count: types.N(1),
108+
Label: types.S("YTD"),
109109
Step: "year",
110110
Stepmode: "todate",
111111
},
112112
{
113-
Count: 1,
114-
Label: "1y",
113+
Count: types.N(1),
114+
Label: types.S("1y"),
115115
Step: "year",
116116
Stepmode: "backward",
117117
},

examples/responsive/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func main() {
2424
},
2525
Layout: &grob.Layout{
2626
Title: &grob.LayoutTitle{
27-
Text: "A Figure Specified By Go Struct",
27+
Text: types.S("A Figure Specified By Go Struct"),
2828
},
2929
},
3030
Config: &grob.Config{

examples/shapes/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
grob "github.com/MetalBlueberry/go-plotly/generated/v2.19.0/graph_objects"
55
"github.com/MetalBlueberry/go-plotly/pkg/offline"
6+
"github.com/MetalBlueberry/go-plotly/pkg/types"
67
)
78

89
func main() {
@@ -17,7 +18,7 @@ func main() {
1718
fig := &grob.Fig{
1819
Layout: &grob.Layout{
1920
Title: &grob.LayoutTitle{
20-
Text: "A Figure Specified By Go Struct",
21+
Text: types.S("A Figure Specified By Go Struct"),
2122
},
2223
Shapes: []grob.LayoutShape{
2324
{
@@ -28,7 +29,7 @@ func main() {
2829
Y1: 2,
2930
Line: &grob.ShapeLine{
3031
Color: "RoyalBlue",
31-
Width: 3,
32+
Width: types.N(3),
3233
},
3334
},
3435
{
@@ -39,8 +40,8 @@ func main() {
3940
Y1: 2,
4041
Line: &grob.ShapeLine{
4142
Color: "LightSeaGreen",
42-
Width: 4,
43-
Dash: string(grob.Scatter3dLineDashDashdot),
43+
Width: types.N(4),
44+
Dash: types.S(string(grob.Scatter3dLineDashDashdot)),
4445
},
4546
},
4647
{
@@ -51,8 +52,8 @@ func main() {
5152
Y1: 2,
5253
Line: &grob.ShapeLine{
5354
Color: "MediumPurple",
54-
Width: 4,
55-
Dash: string(grob.Scatter3dLineDashDot),
55+
Width: types.N(4),
56+
Dash: types.S(string(grob.Scatter3dLineDashDot)),
5657
},
5758
},
5859
},

examples/stargazers/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ func main() {
5555

5656
x := []string{}
5757
y := []int{}
58-
text := []types.String{}
58+
text := []types.StringType{}
5959
link := []interface{}{}
6060

6161
for i := 0; i < len(starredAt); i++ {
6262
x = append(x, starredAt[i].StarredAt.Format(time.RFC3339))
6363
y = append(y, i+1)
64-
text = append(text, starredAt[i].User.Login)
64+
text = append(text, types.S(starredAt[i].User.Login))
6565
link = append(link, starredAt[i].User.AvatarURL)
6666

6767
}
@@ -74,7 +74,7 @@ func main() {
7474
Text: types.ArrayOKArray(text...),
7575
Meta: types.ArrayOKArray(link...),
7676
Mode: grob.ScatterModeLines + "+" + grob.ScatterModeMarkers,
77-
Name: "Stars",
77+
Name: types.S("Stars"),
7878
Line: &grob.ScatterLine{
7979
Color: "#f0ed46",
8080
},
@@ -83,7 +83,7 @@ func main() {
8383

8484
Layout: &grob.Layout{
8585
Title: &grob.LayoutTitle{
86-
Text: "Metalblueberry/go-plotly Stargazers",
86+
Text: types.S("Metalblueberry/go-plotly Stargazers"),
8787
},
8888
Legend: &grob.LayoutLegend{},
8989
},

examples/static_image/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func main() {
3030
},
3131
Layout: &grob.Layout{
3232
Title: &grob.LayoutTitle{
33-
Text: "A Figure Specified By Go Struct",
33+
Text: types.S("A Figure Specified By Go Struct"),
3434
},
3535
},
3636
}

examples/subplots_share_axes/main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,26 @@ func main() {
6262
&grob.Scatter{
6363
X: types.DataArray([]float64{20, 30, 40}),
6464
Y: types.DataArray([]float64{5, 5, 5}),
65-
Xaxis: "x2",
66-
Yaxis: "y",
65+
Xaxis: types.S("x2"),
66+
Yaxis: types.S("y"),
6767
},
6868
&grob.Scatter{
6969
X: types.DataArray([]float64{2, 3, 4}),
7070
Y: types.DataArray([]float64{600, 700, 800}),
71-
Xaxis: "x",
72-
Yaxis: "y3",
71+
Xaxis: types.S("x"),
72+
Yaxis: types.S("y3"),
7373
},
7474
&grob.Scatter{
7575
X: types.DataArray([]float64{4000, 5000, 6000}),
7676
Y: types.DataArray([]float64{7000, 8000, 9000}),
77-
Xaxis: "x4",
78-
Yaxis: "y4",
77+
Xaxis: types.S("x4"),
78+
Yaxis: types.S("y4"),
7979
},
8080
},
8181
Layout: &grob.Layout{
8282
Grid: &grob.LayoutGrid{
83-
Rows: 2,
84-
Columns: 2,
83+
Rows: types.I(2),
84+
Columns: types.I(2),
8585
Subplots: [][]string{
8686
{"xy", "x2y"},
8787
{"xy3", "x4y4"},

examples/transforms/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func main() {
2424
},
2525
Layout: &grob.Layout{
2626
Title: &grob.LayoutTitle{
27-
Text: "A Figure Specified By Go Struct",
27+
Text: types.S("A Figure Specified By Go Struct"),
2828
},
2929
},
3030
}

examples/waterfall_bar_chart/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func main() {
138138
Color: types.ArrayOKValue(types.UseColor("rgba(55,128,191,0.7)")),
139139
Line: &grob.BarMarkerLine{
140140
Color: types.ArrayOKValue(types.UseColor("rgba(55,128,191,1.0)")),
141-
Width: types.ArrayOKValue(2.0),
141+
Width: types.ArrayOKValue(types.N(2.0)),
142142
},
143143
},
144144
}
@@ -152,7 +152,7 @@ func main() {
152152
Color: types.ArrayOKValue(types.UseColor("rgba(219, 64, 82, 0.7)")),
153153
Line: &grob.BarMarkerLine{
154154
Color: types.ArrayOKValue(types.UseColor("rgba(219, 64, 82, 1.0)")),
155-
Width: types.ArrayOKValue(2.0),
155+
Width: types.ArrayOKValue(types.N(2.0)),
156156
},
157157
},
158158
}
@@ -166,7 +166,7 @@ func main() {
166166
Color: types.ArrayOKValue(types.UseColor("rgba(50,171, 96, 0.7)")),
167167
Line: &grob.BarMarkerLine{
168168
Color: types.ArrayOKValue(types.UseColor("rgba(50,171,96,1.0)")),
169-
Width: types.ArrayOKValue(2.0),
169+
Width: types.ArrayOKValue(types.N(2.0)),
170170
},
171171
},
172172
}
@@ -178,10 +178,10 @@ func main() {
178178
annotations[i] = grob.LayoutAnnotation{
179179
X: xData[i],
180180
Y: yData[i],
181-
Text: textList[i],
181+
Text: types.S(textList[i]),
182182
Font: &grob.AnnotationFont{
183-
Family: "Arial",
184-
Size: 14,
183+
Family: types.S("Arial"),
184+
Size: types.N(14),
185185
Color: "rgba(245,246,249,1)",
186186
},
187187
Showarrow: types.False,
@@ -190,13 +190,13 @@ func main() {
190190

191191
layout := &grob.Layout{
192192
Title: &grob.LayoutTitle{
193-
Text: "Annual Profit 2015",
193+
Text: types.S("Annual Profit 2015"),
194194
},
195195
Barmode: grob.BarBarmodeStack,
196196
PaperBgcolor: "rgba(245,246,249,1)",
197197
PlotBgcolor: "rgba(245,246,249,1)",
198-
Width: 600,
199-
Height: 600,
198+
Width: types.N(600),
199+
Height: types.N(600),
200200
Showlegend: types.False,
201201
Annotations: annotations,
202202
}

0 commit comments

Comments
 (0)