Skip to content

Commit

Permalink
Implement Nilable values
Browse files Browse the repository at this point in the history
  • Loading branch information
MetalBlueberry committed Aug 25, 2024
1 parent ea40026 commit 86e39c9
Show file tree
Hide file tree
Showing 223 changed files with 22,799 additions and 22,750 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Currently, most common use cases should be already covered. Feel free to create
- [x] Frames
- [ ] defs
- [ ] defs valobjects
- [ ] angle
- [ ] angle **needs validations**
- [x] any
- [x] boolean
- [x] color
Expand All @@ -100,12 +100,12 @@ Currently, most common use cases should be already covered. Feel free to create
- [x] enumerated
- [x] flaglist
- [ ] info_array
- [ ] integer **Needs support for nil values**
- [ ] number **Needs support for nil values**
- [x] integer
- [x] number
- [x] string
- [ ] subplotid
- [ ] defs_modifier
- [ ] arrayOK
- [x] arrayOK
- [ ] min/max validations
- [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**
- [ ] noBlank validation
Expand Down
10 changes: 5 additions & 5 deletions examples/animation/animation.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ func main() {
},
Updatemenus: []grob.LayoutUpdatemenu{
{
Type: "buttons",
Type: grob.UpdatemenuTypeButtons,
Showactive: types.False,
Buttons: []grob.UpdatemenuButton{
{
Label: "Play",
Method: "animate",
Label: types.S("Play"),
Method: grob.ButtonMethodAnimate,
Args: []*ButtonArgs{
nil,
{
Expand All @@ -80,11 +80,11 @@ func main() {
Frames: frames,
Animation: &grob.Animation{
Transition: &grob.AnimationTransition{
Duration: 500,
Duration: types.N(500),
Easing: grob.AnimationTransitionEasingCubicInOut,
},
Frame: &grob.AnimationFrame{
Duration: 500,
Duration: types.N(500),
Redraw: types.True,
},
},
Expand Down
12 changes: 6 additions & 6 deletions examples/bar_custom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ func main() {
Color: types.ArrayOKValue(types.UseColor(types.Color(
markerColor.Hex(), // Use colorfull
))),
Opacity: types.ArrayOKValue(0.6),
Opacity: types.ArrayOKValue(types.N(0.6)),
Line: &grob.BarMarkerLine{
Color: types.ArrayOKValue(types.UseColor("rgb(8,48,107)")), // Or just write the string
Width: types.ArrayOKValue(1.5),
Width: types.ArrayOKValue(types.N(1.5)),
},
},
}

layout := &grob.Layout{
Title: &grob.LayoutTitle{
Text: "A Figure Specified By Go Struct",
Text: types.S("A Figure Specified By Go Struct"),
},
}

Expand All @@ -84,10 +84,10 @@ func main() {
offline.Show(fig)
}

func toString(in []int) []types.String {
out := make([]types.String, len(in))
func toString(in []int) []types.StringType {
out := make([]types.StringType, len(in))
for i := range in {
out[i] = strconv.Itoa(in[i])
out[i] = types.S(strconv.Itoa(in[i]))
}
return out
}
14 changes: 7 additions & 7 deletions examples/colorscale/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func main() {
Marker: &grob.Scatter3dMarker{
Autocolorscale: types.False,
Cauto: types.False,
Cmin: 0,
Cmid: 5,
Cmax: 10,
Cmin: types.N(0),
Cmid: types.N(5),
Cmax: types.N(10),
Color: types.ArrayOKArray(types.UseColorScaleValues(z)...),
Colorscale: &types.ColorScale{
Values: []types.ColorScaleReference{
Expand All @@ -43,15 +43,15 @@ func main() {
},
},
Showscale: types.True,
Size: types.ArrayOKValue(4.0),
Size: types.ArrayOKValue(types.N(4.0)),
},
},
},
Layout: &grob.Layout{
Height: 700,
Width: 1200,
Height: types.N(700),
Width: types.N(1200),
Title: &grob.LayoutTitle{
Text: "3D Spiral",
Text: types.S("3D Spiral"),
},
},
}
Expand Down
18 changes: 9 additions & 9 deletions examples/range_slider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,32 +86,32 @@ func main() {

fig.Layout = &grob.Layout{
Title: &grob.LayoutTitle{
Text: "Time series with range slider and selectors",
Text: types.S("Time series with range slider and selectors"),
},
Xaxis: &grob.LayoutXaxis{
Rangeselector: &grob.LayoutXaxisRangeselector{
Buttons: []grob.LayoutXaxisRangeselectorButton{
{
Count: 1,
Label: "1m",
Count: types.N(1),
Label: types.S("1m"),
Step: "month",
Stepmode: "backward",
},
{
Count: 6,
Label: "6m",
Count: types.N(6),
Label: types.S("6m"),
Step: "month",
Stepmode: "backward",
},
{
Count: 1,
Label: "YTD",
Count: types.N(1),
Label: types.S("YTD"),
Step: "year",
Stepmode: "todate",
},
{
Count: 1,
Label: "1y",
Count: types.N(1),
Label: types.S("1y"),
Step: "year",
Stepmode: "backward",
},
Expand Down
2 changes: 1 addition & 1 deletion examples/responsive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
},
Layout: &grob.Layout{
Title: &grob.LayoutTitle{
Text: "A Figure Specified By Go Struct",
Text: types.S("A Figure Specified By Go Struct"),
},
},
Config: &grob.Config{
Expand Down
13 changes: 7 additions & 6 deletions examples/shapes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
grob "github.com/MetalBlueberry/go-plotly/generated/v2.19.0/graph_objects"
"github.com/MetalBlueberry/go-plotly/pkg/offline"
"github.com/MetalBlueberry/go-plotly/pkg/types"
)

func main() {
Expand All @@ -17,7 +18,7 @@ func main() {
fig := &grob.Fig{
Layout: &grob.Layout{
Title: &grob.LayoutTitle{
Text: "A Figure Specified By Go Struct",
Text: types.S("A Figure Specified By Go Struct"),
},
Shapes: []grob.LayoutShape{
{
Expand All @@ -28,7 +29,7 @@ func main() {
Y1: 2,
Line: &grob.ShapeLine{
Color: "RoyalBlue",
Width: 3,
Width: types.N(3),
},
},
{
Expand All @@ -39,8 +40,8 @@ func main() {
Y1: 2,
Line: &grob.ShapeLine{
Color: "LightSeaGreen",
Width: 4,
Dash: string(grob.Scatter3dLineDashDashdot),
Width: types.N(4),
Dash: types.S(string(grob.Scatter3dLineDashDashdot)),
},
},
{
Expand All @@ -51,8 +52,8 @@ func main() {
Y1: 2,
Line: &grob.ShapeLine{
Color: "MediumPurple",
Width: 4,
Dash: string(grob.Scatter3dLineDashDot),
Width: types.N(4),
Dash: types.S(string(grob.Scatter3dLineDashDot)),
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions examples/stargazers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ func main() {

x := []string{}
y := []int{}
text := []types.String{}
text := []types.StringType{}
link := []interface{}{}

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

}
Expand All @@ -74,7 +74,7 @@ func main() {
Text: types.ArrayOKArray(text...),
Meta: types.ArrayOKArray(link...),
Mode: grob.ScatterModeLines + "+" + grob.ScatterModeMarkers,
Name: "Stars",
Name: types.S("Stars"),
Line: &grob.ScatterLine{
Color: "#f0ed46",
},
Expand All @@ -83,7 +83,7 @@ func main() {

Layout: &grob.Layout{
Title: &grob.LayoutTitle{
Text: "Metalblueberry/go-plotly Stargazers",
Text: types.S("Metalblueberry/go-plotly Stargazers"),
},
Legend: &grob.LayoutLegend{},
},
Expand Down
2 changes: 1 addition & 1 deletion examples/static_image/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {
},
Layout: &grob.Layout{
Title: &grob.LayoutTitle{
Text: "A Figure Specified By Go Struct",
Text: types.S("A Figure Specified By Go Struct"),
},
},
}
Expand Down
16 changes: 8 additions & 8 deletions examples/subplots_share_axes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,26 @@ func main() {
&grob.Scatter{
X: types.DataArray([]float64{20, 30, 40}),
Y: types.DataArray([]float64{5, 5, 5}),
Xaxis: "x2",
Yaxis: "y",
Xaxis: types.S("x2"),
Yaxis: types.S("y"),
},
&grob.Scatter{
X: types.DataArray([]float64{2, 3, 4}),
Y: types.DataArray([]float64{600, 700, 800}),
Xaxis: "x",
Yaxis: "y3",
Xaxis: types.S("x"),
Yaxis: types.S("y3"),
},
&grob.Scatter{
X: types.DataArray([]float64{4000, 5000, 6000}),
Y: types.DataArray([]float64{7000, 8000, 9000}),
Xaxis: "x4",
Yaxis: "y4",
Xaxis: types.S("x4"),
Yaxis: types.S("y4"),
},
},
Layout: &grob.Layout{
Grid: &grob.LayoutGrid{
Rows: 2,
Columns: 2,
Rows: types.I(2),
Columns: types.I(2),
Subplots: [][]string{
{"xy", "x2y"},
{"xy3", "x4y4"},
Expand Down
2 changes: 1 addition & 1 deletion examples/transforms/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
},
Layout: &grob.Layout{
Title: &grob.LayoutTitle{
Text: "A Figure Specified By Go Struct",
Text: types.S("A Figure Specified By Go Struct"),
},
},
}
Expand Down
18 changes: 9 additions & 9 deletions examples/waterfall_bar_chart/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func main() {
Color: types.ArrayOKValue(types.UseColor("rgba(55,128,191,0.7)")),
Line: &grob.BarMarkerLine{
Color: types.ArrayOKValue(types.UseColor("rgba(55,128,191,1.0)")),
Width: types.ArrayOKValue(2.0),
Width: types.ArrayOKValue(types.N(2.0)),
},
},
}
Expand All @@ -152,7 +152,7 @@ func main() {
Color: types.ArrayOKValue(types.UseColor("rgba(219, 64, 82, 0.7)")),
Line: &grob.BarMarkerLine{
Color: types.ArrayOKValue(types.UseColor("rgba(219, 64, 82, 1.0)")),
Width: types.ArrayOKValue(2.0),
Width: types.ArrayOKValue(types.N(2.0)),
},
},
}
Expand All @@ -166,7 +166,7 @@ func main() {
Color: types.ArrayOKValue(types.UseColor("rgba(50,171, 96, 0.7)")),
Line: &grob.BarMarkerLine{
Color: types.ArrayOKValue(types.UseColor("rgba(50,171,96,1.0)")),
Width: types.ArrayOKValue(2.0),
Width: types.ArrayOKValue(types.N(2.0)),
},
},
}
Expand All @@ -178,10 +178,10 @@ func main() {
annotations[i] = grob.LayoutAnnotation{
X: xData[i],
Y: yData[i],
Text: textList[i],
Text: types.S(textList[i]),
Font: &grob.AnnotationFont{
Family: "Arial",
Size: 14,
Family: types.S("Arial"),
Size: types.N(14),
Color: "rgba(245,246,249,1)",
},
Showarrow: types.False,
Expand All @@ -190,13 +190,13 @@ func main() {

layout := &grob.Layout{
Title: &grob.LayoutTitle{
Text: "Annual Profit 2015",
Text: types.S("Annual Profit 2015"),
},
Barmode: grob.BarBarmodeStack,
PaperBgcolor: "rgba(245,246,249,1)",
PlotBgcolor: "rgba(245,246,249,1)",
Width: 600,
Height: 600,
Width: types.N(600),
Height: types.N(600),
Showlegend: types.False,
Annotations: annotations,
}
Expand Down
Loading

0 comments on commit 86e39c9

Please sign in to comment.