Skip to content

Commit 4d63465

Browse files
Update readme
1 parent f86c937 commit 4d63465

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

README.md

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,17 @@ See the examples dir for more examples.
6565

6666
## Structure
6767

68+
> Auto completion is your best friend on this package. It will get the right type (almost) every time!
69+
6870
To keep the plotly.js independent of the version of this package, the generated directory contains a directory per plotly version supported. The plan is to support all minor releases and update as patches are released. But because I can not do it myself, I will accept PRs if anyone wants any specific version.
6971

7072
Updates to the package will affect all schemas. This will be done as we improve the generator.
7173

7274
Each trace type has its own file on **graph_objecs (grob)** package. The file contains the main structure and all the needed nested objects. Files ending with **_gen** are automatically generated files running `go generate`. This is executing the code in **generator** package to generate the structures from the plotly schema. The types are documented, but you can find more examples and extended documentation at [Plotly's documentation](https://plotly.com/python/).
7375

74-
The values that can hold single values or arrays are defined as custom types that are a type definition of `interfaces{}`. Most common case are X and Y values. You can pass any number slice and it will work (`[]float64`,`[]int`,`[]int64`...). In case of Hovertext, you can provide a `[]string` to display a text for each point, a `string` to display the same for all or `[]int` to display a number.
76+
Types that can have single values or lists, are defined as `types.ArrayOK` types. You can use the helper methods `types.ArrayOKArray` and `types.ArrayOKValue` depending on which value you want to set.
77+
78+
Basic types have been defined to follow plotly specs. Than means you will find types for strings, bools, numbers and integers. Those types are basically pointers to the equivalent value in Go, as plotly supports null values on any of those fields. To make it easier to work with the library, you can find utility functions to build such types. For example. `types.N()` will create a `types.Number` value from a `float64` value. `types.NS()` attempts to parse a string as a number to follow what plotly specifications says about Number type. `types.NA()` converts `[]float64` into `[]types.Number`. Equivalent functions can be found for other types.
7579

7680
Nested Properties, are defined as new types. This is great for auto completion using vscode because you can write all the boilerplate with ctrl+space. For example, the field `Title.Text` is accessed by the property `Title` of type {{Type}}Title that contains the property `Text`. The Type is always the struct that contains the field. For Layout It is `LayoutTitle`.
7781

@@ -83,34 +87,35 @@ The main focus is to have the structures to hold the data and provide auto compe
8387

8488
Currently, most common use cases should be already covered. Feel free to create an issue if you find something that it's not working.
8589

86-
- [x] Traces
87-
- [x] Layout
88-
- [x] Config
89-
- [x] Animation
90-
- [x] Frames
91-
- [ ] defs
92-
- [ ] defs valobjects
93-
- [ ] angle **needs validations**
94-
- [x] any
95-
- [x] boolean
96-
- [x] color
97-
- [x] colorlist
98-
- [x] colorscale
99-
- [x] data_array
100-
- [x] enumerated
101-
- [x] flaglist
102-
- [ ] info_array
103-
- [x] integer
104-
- [x] number
105-
- [x] string
106-
- [ ] subplotid
107-
- [ ] defs_modifier
108-
- [x] arrayOK
109-
- [ ] min/max validations
110-
- [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**
111-
- [ ] noBlank validation
112-
- [ ] strict validation
113-
- [ ] values list validation
90+
- [x] Basic types
91+
- [x] Traces
92+
- [x] Layout
93+
- [x] Config
94+
- [x] Animation
95+
- [x] Frames
96+
- [ ] Type definitions
97+
- [ ] defs valobjects
98+
- [ ] angle **needs validations**
99+
- [x] any
100+
- [x] boolean
101+
- [x] color
102+
- [x] colorlist
103+
- [x] colorscale
104+
- [x] data_array
105+
- [x] enumerated
106+
- [x] flaglist
107+
- [ ] info_array
108+
- [x] integer
109+
- [x] number
110+
- [x] string
111+
- [ ] subplotid
112+
- [ ] defs_modifier
113+
- [x] arrayOK
114+
- [ ] min/max validations
115+
- [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**
116+
- [ ] noBlank validation
117+
- [ ] strict validation
118+
- [ ] values list validation
114119

115120
## FAQ
116121

0 commit comments

Comments
 (0)