Skip to content

Commit

Permalink
merged with master
Browse files Browse the repository at this point in the history
  • Loading branch information
fredo-dedup committed Sep 3, 2016
2 parents bcd1b4e + cefe12c commit 23bdedb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ os:
- linux
- osx
julia:
- release
- 0.4
- 0.5
- nightly
notifications:
email: false
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ _Julia bindings to Vega-Lite_

This package provides access to the Vega-Lite high-level visualization grammar (http://vega.github.io/vega-lite/) from Julia.

Vega-Lite is a simpler version of the Vega grammar allowing smaller and more expressive chart specifications. If you don't find this library powerful enough for your needs you can turn to Vega.jl (https://github.com/johnmyleswhite/Vega.jl) on which this project is partially based (thanks !).
`Vega-Lite` is a simpler version of the Vega grammar allowing smaller and more expressive chart specifications. `Vega-Lite` is intentionaly more limited than Vega, if you need a finer control over the produced graph you can turn instead to the Vega.jl package (https://github.com/johnmyleswhite/Vega.jl). Parts of the VegaLite package (rendering functions, IJulia integration) are based on Vega.jl (thanks !).

Install with `Pkg.add("VegaLite")` (or `Pkg.clone("https://github.com/fredo-dedup/VegaLite.jl.git")`
until it reaches the official repository). You can use the integrated documentation, e.g. `? config_mark` to get the full list of properties of the `config_mark` function.
until it reaches the official repository). Most functions are documented, with the full list of their properties listed and explained, e.g. type `? config_mark` to get the full list of properties of the `config_mark` function, etc.

The julia functions follow pretty closely the Vega-Lite JSON format: `data_values()` creates the `{"data": {values: { ...} }}` part of the spec file, etc.

Only two functions are added:
- `svg(Bool)` : sets the drawing mode of the plots, SVG if `true`, canvas if `false`. Default = `true`
- `buttons(Bool)` : indicates if the plot should be accompanied with links 'Save as PNG', 'View source' and 'Open in Vega Editor'.
- `buttons(Bool)` : indicates if the plot should be accompanied with links 'Save as PNG', 'View source' and 'Open in Vega Editor'. Default = `true`.

Currently, VegaLite.jl works with IJulia/Jupyter, Escher and in the standard REPL (a browser window will open).

Expand Down
9 changes: 9 additions & 0 deletions examples/histogram.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using VegaLite
using DataFrames

# a simple histogram of random standard normal draws

data_values(DataFrame(x=randn(200))) +
mark_bar() +
encoding_x_quant(:x; bin=Dict(:maxbins=>20), axis=Dict(:title=>"values")) +
encoding_y_quant(:*, aggregate="count", axis=Dict(:title=>"number of draws"))
14 changes: 14 additions & 0 deletions examples/histogram_facet.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using VegaLite
using DataFrames

## histograms by group

df= DataFrame(group=rand(0:1, 200))
df[:x] = df[:group]*2 + randn(size(df,1))

data_values(df) +
mark_bar() +
encoding_x_quant(:x; bin=Dict(:maxbins=>15)) +
encoding_y_quant(:*, aggregate="count") +
encoding_row_nominal(:group) +
encoding_color_nominal(:group)
2 changes: 1 addition & 1 deletion src/ijulia_integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Base.writemime
# => libraries are loaded externally in the `require.config`

# function jslibpath(url...)
# libpath = Pkg.dir("VegaLite", "assets", "bower_components", url...)
# libpath = joinpath(dirname(@__FILE__), "..", "assets", "bower_components", url...)
# replace(libpath, "\\", "/") # for windows...
# end
# // d3: "$(jslibpath("d3","d3.min.js"))",
Expand Down
4 changes: 2 additions & 2 deletions src/render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
######################################################################

asset(url...) = @compat readstring(Pkg.dir("VegaLite", "assets", "bower_components", url...))
asset(url...) = @compat readstring(joinpath(dirname(@__FILE__), "..", "assets", "bower_components", url...))

#Vega Scaffold: https://github.com/vega/vega/wiki/Runtime
function writehtml(io::IO, v::VegaLiteVis; title="VegaLite plot")
Expand All @@ -15,11 +15,11 @@ function writehtml(io::IO, v::VegaLiteVis; title="VegaLite plot")
<html>
<head>
<title>$title</title>
<meta charset="UTF-8">
<script>$(asset("d3","d3.min.js"))</script>
<script>$(asset("vega", "vega.js"))</script>
<script>$(asset("vega-lite", "vega-lite.js"))</script>
<script>$(asset("vega-embed", "vega-embed.js"))</script>
</head>
<body>
<div id="$divid"></div>
Expand Down

0 comments on commit 23bdedb

Please sign in to comment.