1
+ # TODO: remove on v1.0
1
2
defmodule VegaLite.Export do
2
- @ moduledoc """
3
- Various export methods for a `VegaLite` specification.
4
-
5
- All of the export functions depend on the `:jason` package.
6
- Additionally the PNG, SVG and PDF exports rely on npm packages,
7
- so you will need Node.js, `npm`, and the following dependencies:
8
-
9
- ```console
10
- $ npm install -g vega vega-lite canvas
11
- ```
12
-
13
- Alternatively you can install the dependencies in a local directory:
14
-
15
- ```console
16
- $ npm install vega vega-lite canvas
17
- ```
18
- """
3
+ @ moduledoc false
19
4
20
5
alias VegaLite.Utils
21
6
22
- @ doc """
23
- Saves a `VegaLite` specification to file in one of
24
- the supported formats.
25
-
26
- ## Options
27
-
28
- * `:format` - the format to export the graphic as,
29
- must be either of: `:json`, `:html`, `:png`, `:svg`, `:pdf`.
30
- By default the format is inferred from the file extension.
31
-
32
- * `:local_npm_prefix` - a relative path pointing to a local npm project directory
33
- where the necessary npm packages are installed. For instance, in Phoenix projects
34
- you may want to pass `local_npm_prefix: "assets"`. By default the npm packages
35
- are searched for in the current directory and globally.
36
-
37
- """
7
+ @ deprecated "Use VegaLite.Convert.save!/3 in from the :vega_lite_convert package instead"
38
8
@ spec save! ( VegaLite . t ( ) , binary ( ) , keyword ( ) ) :: :ok
39
9
def save! ( vl , path , opts \\ [ ] ) do
40
10
{ format , opts } =
@@ -69,9 +39,7 @@ defmodule VegaLite.Export do
69
39
70
40
@ compile { :no_warn_undefined , { Jason , :encode! , 1 } }
71
41
72
- @ doc """
73
- Returns the underlying Vega-Lite specification as JSON.
74
- """
42
+ @ deprecated "Use VegaLite.Convert.to_json/1 in from the :vega_lite_convert package instead"
75
43
@ spec to_json ( VegaLite . t ( ) ) :: String . t ( )
76
44
def to_json ( vl ) do
77
45
Utils . assert_jason! ( "to_json/1" )
@@ -81,12 +49,7 @@ defmodule VegaLite.Export do
81
49
|> Jason . encode! ( )
82
50
end
83
51
84
- @ doc """
85
- Builds an HTML page that renders the given graphic.
86
-
87
- The HTML page loads necessary JavaScript dependencies from a CDN
88
- and then renders the graphic in a root element.
89
- """
52
+ @ deprecated "Use VegaLite.Convert.to_html/1 in from the :vega_lite_convert package instead"
90
53
@ spec to_html ( VegaLite . t ( ) ) :: binary ( )
91
54
def to_html ( vl ) do
92
55
json = to_json ( vl )
@@ -113,62 +76,26 @@ defmodule VegaLite.Export do
113
76
"""
114
77
end
115
78
79
+ @ doc false
80
+ def to_html_no_deprecation ( vl ) , do: to_html ( vl )
81
+
116
82
defp escape_double_quotes ( json ) do
117
83
String . replace ( json , ~s{ "} , ~s{ \\ "} )
118
84
end
119
85
120
- @ doc """
121
- Renders the given graphic as a PNG image and returns
122
- its binary content.
123
-
124
- Relies on the `npm` packages mentioned above.
125
-
126
- ## Options
127
-
128
- * `:local_npm_prefix` - a relative path pointing to a local npm project directory
129
- where the necessary npm packages are installed. For instance, in Phoenix projects
130
- you may want to pass `local_npm_prefix: "assets"`. By default the npm packages
131
- are searched for in the current directory and globally.
132
-
133
- """
86
+ @ deprecated "Use VegaLite.Convert.to_png/1 in from the :vega_lite_convert package instead"
134
87
@ spec to_png ( VegaLite . t ( ) , keyword ( ) ) :: binary ( )
135
88
def to_png ( vl , opts \\ [ ] ) do
136
89
node_convert ( vl , "png" , "to_png/1" , opts )
137
90
end
138
91
139
- @ doc """
140
- Renders the given graphic as an SVG image and returns
141
- its binary content.
142
-
143
- Relies on the `npm` packages mentioned above.
144
-
145
- ## Options
146
-
147
- * `:local_npm_prefix` - a relative path pointing to a local npm project directory
148
- where the necessary npm packages are installed. For instance, in Phoenix projects
149
- you may want to pass `local_npm_prefix: "assets"`. By default the npm packages
150
- are searched for in the current directory and globally.
151
-
152
- """
92
+ @ deprecated "Use VegaLite.Convert.to_svg/1 in from the :vega_lite_convert package instead"
153
93
@ spec to_svg ( VegaLite . t ( ) , keyword ( ) ) :: binary ( )
154
94
def to_svg ( vl , opts \\ [ ] ) do
155
95
node_convert ( vl , "svg" , "to_svg/1" , opts )
156
96
end
157
97
158
- @ doc """
159
- Renders the given graphic into a PDF and returns its
160
- binary content.
161
-
162
- Relies on the `npm` packages mentioned above.
163
-
164
- ## Options
165
-
166
- * `:local_npm_prefix` - a relative path pointing to a local npm project directory
167
- where the necessary npm packages are installed. For instance, in Phoenix projects
168
- you may want to pass `local_npm_prefix: "assets"`. By default the npm packages
169
- are searched for in the current directory and globally.
170
-
171
- """
98
+ @ deprecated "Use VegaLite.Convert.to_pdf/1 in from the :vega_lite_convert package instead"
172
99
@ spec to_pdf ( VegaLite . t ( ) , keyword ( ) ) :: binary ( )
173
100
def to_pdf ( vl , opts \\ [ ] ) do
174
101
node_convert ( vl , "pdf" , "to_pdf/1" , opts )
0 commit comments