Skip to content

Commit 249150c

Browse files
authored
[docs] Full edit review of wording and references. (#511)
Extensive review of all documentation with edits, corrections and explanation. Updates wording and references alongside general fixes and cleaning up in documentation.
1 parent 11f2410 commit 249150c

8 files changed

Lines changed: 412 additions & 249 deletions

File tree

docs/make.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ makedocs(
113113
modules=[PlotlyJS, PlotlyBase],
114114
linkcheck=true,
115115
pages=[
116-
"Home" => "index.md",
116+
"Introduction" => "index.md",
117117
"User Guide" => [
118118
"Preliminaries" => "basics.md",
119-
"Building Blocks" => "building_traces_layouts.md",
119+
"Building blocks" => "building_traces_layouts.md",
120120
"Putting it together" => "syncplots.md",
121121
"Working with plots" => "manipulating_plots.md",
122122
"Contributing" => "contributing.md",

docs/src/basics.md

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,81 @@
1-
## Basics
1+
## Preliminaries
22

3-
[plotly.js][_plotlyjs] figures are constructed by calling the function:
3+
PlotlyJS.jl is a Julia package that relies on the [plotly.js](https://plotly.com/javascript/) JavaScript library.
4+
5+
In that library, figures are constructed by calling the function:
46

57
```js
68
Plotly.newPlot(divid, data, layout, config, frames)
79
```
810

911
where
1012

11-
- `divid` is an html `div` element where the plot should appear
12-
- `data` is an array of JSON objects describing the various `trace`s in the visualization
13-
- `layout` is a JSON object describing the layout properties of the visualization.
14-
- `config` is a JSON object describing the configuration properties of the visualization. See more detail [here](https://plotly.com/javascript/configuration-options/)
15-
- `frames` can contain data and layout objects, which define any changes to be animated, and a traces object that defines which traces to animate.
16-
17-
The `divid` argument is handled automatically by one of the supported
18-
frontends, so users of this package will mostly be concerned about constructing
19-
the `data`, `layout`, and (optionally) `config` and `frames` arguments.
20-
21-
For a complete list of traces and their attributes see the [plotly.js chart attribute reference][_plotlyref].
22-
23-
<!-- As of version 0.6.0 of this package you can also view a local version of this
24-
page that is a bit easier to navigate by calling the `PlotlyJS.docs()` function
25-
from the Julia prompt. This will open an electron window with a local webpage
26-
containing a version of that reference page. -->
13+
- `data` is an array of [JSON](https://developer.mozilla.org/en-US/docs/Glossary/JSON) objects
14+
describing the various data _traces_ in the visualization (see Note)
15+
- `layout` is a JSON object describing the presentation properties of the visualization
16+
- `config` is a JSON object describing the configuration properties of the visualization
17+
(see more detail [here](https://plotly.com/julia/configuration-options/))
18+
- `frames` can contain data and layout objects, which define any changes to be animated,
19+
and a traces object that defines which traces to animate.
20+
21+
The `divid` argument refers to an [html `<div>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/div)
22+
to control the plot on a page and is handled automatically by one of the supported
23+
front-ends. Users of this package will mostly be concerned about constructing
24+
the `data` and the `layout`, and (optionally) `config` and `frames` arguments.
25+
26+
!!! note
27+
A _trace_ is a general term for how data is shown graphically on a plot,
28+
whether it is a scatter plot, bar chart, 3D surface, choropleth map or some other plot type.
29+
A trace is fundamentally a collection of data and the specifications of how that data should be plotted.
30+
For a complete list of traces and their attributes see the
31+
[plotly figure reference](https://plotly.com/julia/reference/).
32+
33+
When we want to construct a `Plot` in PlotlyJS.jl for plotting on some display, we will usually have
34+
at least one trace `tr` along with a layout object `ly` which we combine together as `Plot(tr, ly)`.
35+
If we don't have a layout object then a template will supply a default layout for us.
2736

2837
## Julia types
2938

30-
There are a handful of core Julia types for representing a visualization
39+
There are a handful of core Julia types for representing a visualization.
3140

32-
These are
41+
The `data`, `layout`, `frames`, `divid` and `config` fields of the `Plot` type, shown below,
42+
map to the arguments to the `Plotly.newplot` function.
43+
These types are defined in the PlotlyBase.jl package (a dependency of PlotlyJS.jl).
44+
These are shown (in a much simplified form) here:
3345

3446
```julia
3547
abstract type AbstractTrace end
3648
abstract type AbstractLayout end
3749

38-
mutable struct GenericTrace{T <: AbstractDict{Symbol,Any}} <: AbstractTrace
39-
fields::T
50+
mutable struct GenericTrace <: AbstractTrace
51+
fields::Dict{Symbol,Any}
4052
end
4153

42-
mutable struct Layout{T <: AbstractDict{Symbol,Any}} <: AbstractLayout
43-
fields::T
44-
subplots::_Maybe{Subplots}
54+
mutable struct Layout <: AbstractLayout
55+
fields::Dict{Symbol,Any}
56+
subplots::Subplots
4557
end
4658

47-
mutable struct PlotlyFrame{T <: AbstractDict{Symbol,Any}} <: AbstractPlotlyAttribute
48-
fields::T
59+
mutable struct PlotlyFrame <: AbstractPlotlyAttribute
60+
fields::Dict{Symbol,Any}
4961
end
5062

51-
mutable struct Plot{TT<:AbstractVector{<:AbstractTrace},TL<:AbstractLayout,TF<:AbstractVector{<:PlotlyFrame}}
52-
data::TT
53-
layout::TL
63+
mutable struct PlotConfig
64+
scrollZoom::Union{Nothing,Bool} = true
65+
editable::Union{Nothing,Bool} = false
66+
staticPlot::Union{Nothing,Bool} = false
67+
...
68+
end
69+
70+
mutable struct Plot
71+
data::Vector{<:AbstractTrace}
72+
layout::AbstractLayout
73+
frames::Vector{<:PlotlyFrame}
5474
divid::UUID
5575
config::PlotConfig
56-
frames::TF
5776
end
5877
```
5978

60-
The `data`, `layout`, `divid`, `config`, and `frames` fields of the `Plot` type map 1-1 to the arguments to the `Plotly.newplot` function.
61-
62-
63-
[_plotlyjs]: https://plotly.com/javascript/
64-
[_plotlyref]: https://plotly.com/julia/reference/
79+
The `data` field of the `Plot` type can be constructed from a single trace or a vector of multiple traces.
80+
Each trace is itself made up of a `Dict` type holding information about the type of trace
81+
and its data along with attributes for customising the plotting of that data.

0 commit comments

Comments
 (0)