Skip to content

Commit ea40026

Browse files
Update readme
1 parent b7e3ff6 commit ea40026

File tree

1 file changed

+64
-73
lines changed

1 file changed

+64
-73
lines changed

README.md

Lines changed: 64 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -77,111 +77,102 @@ Nested Properties, are defined as new types. This is great for auto completion u
7777

7878
Flaglist and Enumerated fields are defined with a type and its constant values. This provides useful autocompletion. Keep in mind that you can compose multiple values for a Flaglist like `Mode: grob.ScatterModeMarkers + "+" + grob.ScatterModeLines,`. You can read de inline documentation to see the default value.
7979

80-
## Tested
81-
82-
Examples, Code generation and Offline package are based on version 1.58.4, but It should work with other versions as this library just generates standard JSON.
83-
84-
## Testing
85-
86-
The package lacks of unit testing basically because it's just building JSON to be consumed by plotly.js. This means that I do not see a clear way of building valuable unit testing that doesn't involve the usage of plotly.js. If the package compiles, It means that types are generated correctly.
87-
88-
Said that, I'm thinking about adding some integration testing with Docker, but for now, I've enough if the examples are working.
89-
90-
If you have any good idea of how to test this code, I will be happy to hear it.
91-
9280
## Progress
9381

9482
The main focus is to have the structures to hold the data and provide auto competition. Once we get there, we will be on v1.0.0.
9583

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

86+
- [x] Traces
87+
- [x] Layout
88+
- [x] Config
89+
- [x] Animation
90+
- [x] Frames
91+
- [ ] defs
92+
- [ ] defs valobjects
93+
- [ ] angle
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+
- [ ] integer **Needs support for nil values**
104+
- [ ] number **Needs support for nil values**
105+
- [x] string
106+
- [ ] subplotid
107+
- [ ] defs_modifier
108+
- [ ] 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
114+
98115
## FAQ
99116

100117
### What's the meaning of "grob"?
101118

102119
In python, the component is called graph_objects, like in this package, but that's too long to write it over and over again. In Python, usually it's called "go" from Graph_Objects but in Go... that's not possible for a conflict with a keyword. as an alternative, I've decided to use "grob" from GRaph_OBjects.
103120

104-
### How are the graph_object files generated?
105-
106-
I was using "[plate](https://github.com/MetalBlueberry/plate)", but it was a bad idea. Now it is just plan go code inside the **generator package**. This should be much easier to understand and to contribute. Let me know if you want to contribute!!
107-
108121
### What are the usecases?
109122

110-
1. Send plotly figures to the frontend ready to be drawn, avoiding possible mistakes in JS thanks to types!
111-
112-
2. Generate an awesome dynamic plot in a local file with offline package.
113-
114-
3. I don't know, just do something awesome and let me know it.
123+
1. Quickly visualize data using only Go
115124

116-
### Why are the String and Bool types defined?
125+
2. Send plotly figures to the frontend ready to be drawn, avoiding possible mistakes in JS thanks to types!
117126

118-
> I'm thinking about defining everything as a pointer, it should be better in the long run
127+
3. Generate an awesome dynamic plot in a local file with offline package.
119128

120-
This is to handle the omitempty flag in json serialization. Turns out that if the flag is set, you cannot create a json object with a flag set to `false`. For example, turn off visibility of the legend will be impossible without this.
129+
4. I don't know, just do something awesome and let me know it.
121130

122-
For bool, the solution is as simple as defining the types again inside graph_objects and it feels like using normal bool values.
131+
### Go Plotly Update to any json schema version
123132

124-
For strings... This is a little bit more complicated, In AWS package they are using `aws.String` which maps to `*string` to workaround this issue, but I find that really annoying because you have to wrap every single string with `aws.String("whatever")`. For now I've decided to define the type String but leave it as `interface{}` instead of `*string` to allow you to use raw strings. The draw back is that you can pass any value of your choice... Hopefully you can live with this :).
133+
[Example PR](https://github.com/MetalBlueberry/go-plotly/pull/29)
125134

126-
For numbers... It's similar to strings, Right now you cannot create plots with integer/float numbers with 0 value. I've only encounter problems when trying to remove the margin and can be workaround with an small value like `0.001`. I would like to avoid using interface{} or defining types again to keep the package interface as simple as possible.
135+
#### Update the config to add a new version
127136

128-
### Go Plotly Update to any json schema version
137+
1. To add a new version, add a new entry in: [schemas.yaml](schemas.yaml)
138+
> The documentation for each field can be found in [schema.go](generator%2Fschema.go)
129139
130-
#### Update the config to add a new version
140+
Example entry:
131141

132-
To add a new version, add a new entry in: [schemas.yaml](schemas.yaml)
142+
```yaml
143+
- Name: Plotly 2.31.1
144+
Tag: v2.31.1
145+
URL: https://raw.githubusercontent.com/plotly/plotly.js/v2.31.1/test/plot-schema.json
146+
# relative to the project root.
147+
Path: schemas/v2.31.1/plot-schema.json
148+
Generated: generated/v2.31.1
149+
CDN: https://cdn.plot.ly/plotly-2.31.1.min.js
150+
```
133151
134-
The documentation for each field can be found in [schema.go](generator%2Fschema.go)
152+
#### Run download and regeneration
135153
136-
Example entry:
137-
```yaml
138-
- Name: Plotly 2.31.1
139-
Tag: v2.31.1
140-
URL: https://raw.githubusercontent.com/plotly/plotly.js/v2.31.1/test/plot-schema.json
141-
Path: schemas/v2.31.1/plot-schema.json
142-
Generated: generated/v2.31.1
143-
CDN: https://cdn.plot.ly/plotly-2.31.1.min.js
144-
```
154+
1. Download all the schemas:
145155
146-
The local paths are relative to the project root.
147-
148-
#### run download and regeneration
149-
150-
> [!TIP]
151-
> Use this script for easier download of plotly json schemas.
152-
> ```shell
153-
> go run generator/cmd/downloader/main.go --config="schemas.yaml"
154-
> ```
155-
> Then run the generator, which will clean up the generated files in **graph_objects** folder of each version and regenerate the new graph objects. DO NOT REMOVE **graph_objects/plotly.go**
156-
> ```shell
157-
> go run generator/cmd/generator/main.go --config="schemas.yaml"
158-
> ```
159-
> Alternatively, you can also generate the go package using following command from the project root:
160-
> ```shell
161-
> go generate ./...
162-
> ```
163-
164-
#### Missing Files?
165-
166-
if in doubt whether all types and traces have been generated, you can use the jsonviewer tool to introspect the json:
167-
https://jsonviewer.stack.hu/
168-
169-
Or use `jq` tool for quick introspection into the json files.
170-
Example:
171-
Display all traces in the schema.json file.
172-
```shell
173-
jq '.schema.traces | keys' schema.json --sort-keys | less
174-
```
156+
```shell
157+
go run generator/cmd/downloader/main.go --config="schemas.yaml"
158+
```
175159

176-
More on the `jq` tool on: https://jqlang.github.io/jq/manual/
160+
2. Then run the generator:
177161

178-
### plotly online editor sandbox
179-
http://plotly-json-editor.getforge.io/
162+
```shell
163+
go generate ./...
164+
```
180165

181166
## Star History
182167

183168
[![Star History Chart](https://api.star-history.com/svg?repos=Metalblueberry/go-plotly&type=Date)](https://star-history.com/#Metalblueberry/go-plotly&Date)
184169

170+
## Other tools and information links
171+
172+
### Plotly online editor sandbox
173+
174+
http://plotly-json-editor.getforge.io/
175+
176+
### Official Plotly Release Notes
185177

186-
## Official Plotly Release Notes
187178
For detailed changes please follow the release notes of the original JS repo: https://github.com/plotly/plotly.js/releases

0 commit comments

Comments
 (0)