You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+64-73Lines changed: 64 additions & 73 deletions
Original file line number
Diff line number
Diff line change
@@ -77,111 +77,102 @@ Nested Properties, are defined as new types. This is great for auto completion u
77
77
78
78
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.
79
79
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
-
92
80
## Progress
93
81
94
82
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.
95
83
96
84
Currently, most common use cases should be already covered. Feel free to create an issue if you find something that it's not working.
97
85
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
+
98
115
## FAQ
99
116
100
117
### What's the meaning of "grob"?
101
118
102
119
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.
103
120
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
-
108
121
### What are the usecases?
109
122
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
115
124
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!
117
126
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.
119
128
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.
121
130
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
123
132
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 :).
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
127
136
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)
129
139
130
-
#### Update the config to add a new version
140
+
Example entry:
131
141
132
-
To add a new version, add a new entry in: [schemas.yaml](schemas.yaml)
> 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
+
```
175
159
176
-
More on the `jq` tool on: https://jqlang.github.io/jq/manual/
160
+
2. Then run the generator:
177
161
178
-
### plotly online editor sandbox
179
-
http://plotly-json-editor.getforge.io/
162
+
```shell
163
+
go generate ./...
164
+
```
180
165
181
166
## Star History
182
167
183
168
[](https://star-history.com/#Metalblueberry/go-plotly&Date)
184
169
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
185
177
186
-
## Official Plotly Release Notes
187
178
For detailed changes please follow the release notes of the original JS repo: https://github.com/plotly/plotly.js/releases
0 commit comments