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
allow users to set Kaleido path via envionment variable (#262)
* allow users to set Kaleido path via envionment variable
- introduced a new feature to allow users to download Kaleido at
compile time when the applications are targeted for the host machine
- this can be overriden by the runtime environment variable
* add no-sanbox arg to Kaleido process
- something fishy is happening in the CI, without this argument
empty files are generated because of chromium security issues
- print stderr of Kaleido to console
Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+31-10Lines changed: 31 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@
40
40
*[Introduction](#introduction)
41
41
*[Basic Usage](#basic-usage)
42
42
*[Exporting an Interactive Plot](#exporting-an-interactive-plot)
43
-
*[Exporting a Static Image](#exporting-a-static-image)
43
+
*[Exporting Static Images with Kaleido](#exporting-static-images-with-kaleido)
44
44
*[Usage Within a Wasm Environment](#usage-within-a-wasm-environment)
45
45
*[Crate Feature Flags](#crate-feature-flags)
46
46
*[Contributing](#contributing)
@@ -96,18 +96,38 @@ If you only want to view the plot in the browser quickly, use the `Plot.show()`
96
96
plot.show(); // The default web browser will open, displaying an interactive plot
97
97
```
98
98
99
-
## Exporting a Static Image
99
+
## Exporting Static Images with Kaleido
100
100
101
-
To save a plot as a static image, the `kaleido` feature is required:
101
+
To save a plot as a static image, the `kaleido` feature is required as well as installing an **external dependency**.
102
102
103
+
### Kaleido external dependency
104
+
105
+
When developing applications for your host, enabling both `kaleido` and `kaleido_download` features will ensure that the `kaleido` binary is downloaded for your system's architecture at compile time. After download, it is unpacked into a specific path, e.g., on Linux this is `/home/USERNAME/.config/kaleido`. With these two features enabled, static images can be exported as described in the next section as long as the application run on the same host where where this crate was compiled on.
106
+
107
+
When the applications developed with `plotly.rs` are intended for other targets or when the user wants to control where the `kaleido` binary is installed then Kaleido must be manually downloaded and installed. Setting the environment variable `KALEIDO_PATH=/path/installed/kaleido/` will ensure that applications that were built with the `kaleido` feature enabled can locate the `kaleido` executable and use it to generate static images.
108
+
109
+
Kaleido binaries are available on Github [release page](https://github.com/plotly/Kaleido/releases). It currently supports Linux(`x86_64`), Windows(`x86_64`) and MacOS(`x86_64`/`aarch64`).
110
+
111
+
## Exporting a Static Images
112
+
113
+
Enable the `kaleido` feature and opt in for automatic downloading of the `kaleido` binaries by doing the following
114
+
115
+
```toml
116
+
# Cargo.toml
117
+
118
+
[dependencies]
119
+
plotly = { version = "0.11", features = ["kaleido", "kaleido_download"] }
120
+
```
121
+
122
+
Alternatively, enable only the `kaleido` feature and manually install Kaleido.
103
123
```toml
104
124
# Cargo.toml
105
125
106
126
[dependencies]
107
127
plotly = { version = "0.11", features = ["kaleido"] }
108
128
```
109
129
110
-
With this feature enabled, plots can be saved as any of `png`, `jpeg`, `webp`, `svg`, `pdf` and `eps`. Note that the plot will be a static image, i.e. they will be non-interactive.
130
+
With the feature enabled, plots can be saved as any of `png`, `jpeg`, `webp`, `svg`, `pdf` and `eps`. Note that the plot will be a static image, i.e. they will be non-interactive.
On your host, when building this project with the `kaleido` feature enabled the Kaleido binary is downloaded automatically for your system's architecture at compile time from the official Kaleido [release page](https://github.com/plotly/Kaleido/releases). This library currently supports `x86_64` on Linux and Windows, and both `x86_64` and `aarch64` on macOS.
127
-
128
-
When building application for other targets that depend on this feature, the `Kaleido` binary will need to be installed manually on the target machine. Currently, the location where the binary is expected is hardcoded depending on the target OS. E.g., on Linux this defaults to `~/.config/kaleido`. This is defined in source code [here](https://github.com/plotly/plotly.rs/blob/1405731b5121c1343b491e307222a21ef4becc5e/plotly_kaleido/src/lib.rs#L89)
129
-
130
144
## Usage Within a Wasm Environment
131
145
132
146
Using `Plotly.rs` in a Wasm-based frontend framework is possible by enabling the `wasm` feature:
@@ -198,6 +212,13 @@ The following feature flags are available:
198
212
199
213
Adds plot save functionality to the following formats: `png`, `jpeg`, `webp`, `svg`, `pdf` and `eps`.
200
214
215
+
Requires `Kaleido` to have been previously installed on the host machine. See the following feature flag and [Kaleido external dependency](#kaleido-external-dependency).
216
+
217
+
### `kaleido_download`
218
+
219
+
Enable download and install of Kaleido binary at build time from [Kaleido releases](https://github.com/plotly/Kaleido/releases/) on the host machine.
220
+
See [Kaleido external dependency](#kaleido-external-dependency) for more details.
221
+
201
222
### `plotly_image`
202
223
203
224
Adds trait implementations so that `image::RgbImage` and `image::RgbaImage` can be used more directly with the `plotly::Image` trace.
0 commit comments