Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
Update README.md

Remove Test from REQUIRE

Update Manifest.toml

Add `start` and images to README
  • Loading branch information
EricForgy committed Jan 3, 2019
1 parent 0c2732a commit d34842c
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ version = "1.0.2"

[[Pages]]
deps = ["HTTP", "JSON", "PlotlyBase", "Sockets", "Test"]
path = "C:\\Users\\Eric\\.julia\\dev\\Pages"
git-tree-sha1 = "332f7eb1ad0b59f130bae643db6e0ea76b1146d2"
uuid = "7c165e09-dada-5b64-9fdc-39b801c58527"
version = "0.2.1+"
version = "0.2.2"

[[Pidfile]]
deps = ["FileWatching", "Test"]
Expand Down
83 changes: 82 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,90 @@

[![][travis-img]][travis-url] [![][appveyor-img]][appveyor-url]

`Figures.jl` is a simple package that creates draggable figures in a browser window to display plots from various plotting packages. It currently works with `PlotlyJS.jl`.

### Example

```julia
julia> using PlotlyJS, Figures
julia> Figures.start() # You can enter a port, e.g. Figures.start(3000). Default is 8000.
```

This launches a server on localhost. Opening the browser to `http://localhost:8000` will show a blank page.

Running

```julia
julia> figure(1)
```

displays a draggable figure in the browser.

![Figure 1](docs/images/figure1.png)


Running

```julia
julia> function linescatter1()
trace1 = PlotlyJS.scatter(;x = 1:4, y = rand(4), mode = "markers")
trace2 = PlotlyJS.scatter(;x = 2:5, y = rand(4), mode = "lines")
trace3 = PlotlyJS.scatter(;x = 1:4, y = rand(4), mode = "lines+markers")
PlotlyJS.plot([trace1, trace2, trace3]) |> display
end
julia> linescatter1()
```

displays the interactive PlotlyJS chart in the figure.

![Plotly Chart 1](docs/images/plotly1.png)

A second figure can be created by running

```julia
julia> figure(2)
julia> linescatter1()
```

![Plotly Chart 2](docs/images/plotly2.png)

In addition to creating figures, the `figure` method can make an existing figure active again so that subsequent plots will be rendered on the active figure, e.g.

```julia
julia> figure(1)
julia> linescatter1()
```

will display a new chart on the existing figure.

You can add as many figures to the browser as you like

![Plotly Chart 3](docs/images/plotly3.png)

To remove figures, there is the method

```julia
julia> closeall()
```

which closes all figures and

```julia
julia> close(1)
```

which closes the specified figure.

Alternatively, figures can be closed directly in the browser by double clicking them.

### To Do

* Add support for `VegaLite.jl`
* Add support for `Plots.jl`
* Add support for resizing figures, etc.

[travis-img]: https://travis-ci.org/EricForgy/Figures.jl.svg?branch=master
[travis-url]: https://travis-ci.org/EricForgy/Figures.jl

[appveyor-img]: https://ci.appveyor.com/api/projects/status/github/EricForgy/Figures.jl?branch=master&svg=true
[appveyor-url]: https://ci.appveyor.com/project/EricForgy/figures-jl
[appveyor-url]: https://ci.appveyor.com/project/EricForgy/figures-jl
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
julia 1.0
Pages
Requires
Test
Requires
Binary file added docs/images/figure1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/plotly1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/plotly2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/plotly3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/Figures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ function close(id::String)
end
close(id) = close(string(id))

start(port=8000) = @async Pages.start(port)
syncstart(port=8000) = Pages.start(port)

function __init__()
@require PlotlyJS="f0f68f2c-4968-5e81-91da-67840de0976a" include("packages/plotlyjs.jl")

Expand All @@ -52,8 +55,6 @@ function __init__()
read(joinpath(@__DIR__,"..","libs","plotly.min.js"),String)
end

@async Pages.start()

pushdisplay(Display())
end

Expand Down

0 comments on commit d34842c

Please # to comment.