Skip to content

Commit 96c8591

Browse files
authored
allow plotly to be compiled for android (#284)
- disable show/render functionality when target_os is android Closes #282 Signed-off-by: Andrei Gherghescu <[email protected]>
1 parent 0301259 commit 96c8591

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
88
- [[#277](https://github.com/plotly/plotly.rs/pull/277)] Removed `wasm` feature flag and put evrything behind target specific dependencies. Added `.cargo/config.toml` for configuration flags needed by `getrandom` version 0.3 on `wasm` targets.
99
- [[#281]((https://github.com/plotly/plotly.rs/pull/xxx))] Update to askama 0.13.0
1010

11+
### Fixed
12+
- [[#284](https://github.com/plotly/plotly.rs/pull/284)] Allow plotly package to be compiled for android
13+
1114
## [0.12.1] - 2025-01-02
1215
### Fixed
1316
- [[#269](https://github.com/plotly/plotly.rs/pull/269)] Fix publishing to crates.io issue

Diff for: plotly/src/plot.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct PlotTemplate<'a> {
2020

2121
#[derive(Template)]
2222
#[template(path = "static_plot.html", escape = "none")]
23-
#[cfg(not(target_family = "wasm"))]
23+
#[cfg(all(not(target_family = "wasm"), not(target_os = "android")))]
2424
struct StaticPlotTemplate<'a> {
2525
plot: &'a Plot,
2626
format: ImageFormat,
@@ -43,7 +43,7 @@ struct JupyterNotebookPlotTemplate<'a> {
4343
plot_div_id: &'a str,
4444
}
4545

46-
#[cfg(not(target_family = "wasm"))]
46+
#[cfg(all(not(target_family = "wasm"), not(target_os = "android")))]
4747
const DEFAULT_HTML_APP_NOT_FOUND: &str = r#"Could not find default application for HTML files.
4848
Consider using the `to_html` method obtain a string representation instead. If using the `kaleido` feature the
4949
`write_image` method can be used to produce a static image in one of the following formats:
@@ -246,7 +246,7 @@ impl Plot {
246246
///
247247
/// The HTML file is saved in a temp file, from which it is read and
248248
/// displayed by the browser.
249-
#[cfg(not(target_family = "wasm"))]
249+
#[cfg(all(not(target_family = "wasm"), not(target_os = "android")))]
250250
pub fn show(&self) {
251251
use std::env;
252252

@@ -278,7 +278,7 @@ impl Plot {
278278
/// The HTML file is generated and saved in the provided filename as long as
279279
/// the path already exists, after the file is saved, it is read and
280280
/// displayed by the browser.
281-
#[cfg(not(target_family = "wasm"))]
281+
#[cfg(all(not(target_family = "wasm"), not(target_os = "android")))]
282282
pub fn show_html<P: AsRef<Path> + std::clone::Clone>(&self, filename: P) {
283283
let path = filename.as_ref().to_str().unwrap();
284284
self.write_html(filename.clone());
@@ -288,7 +288,7 @@ impl Plot {
288288

289289
/// Display the fully rendered `Plot` as a static image of the given format
290290
/// in the default system browser.
291-
#[cfg(not(target_family = "wasm"))]
291+
#[cfg(all(not(target_family = "wasm"), not(target_os = "android")))]
292292
pub fn show_image(&self, format: ImageFormat, width: usize, height: usize) {
293293
use std::env;
294294

@@ -471,7 +471,7 @@ impl Plot {
471471
tmpl.render().unwrap()
472472
}
473473

474-
#[cfg(not(target_family = "wasm"))]
474+
#[cfg(all(not(target_family = "wasm"), not(target_os = "android")))]
475475
fn render_static(&self, format: ImageFormat, width: usize, height: usize) -> String {
476476
let tmpl = StaticPlotTemplate {
477477
plot: self,

0 commit comments

Comments
 (0)