Skip to content

Commit 88ed50e

Browse files
committed
merge issue #220
2 parents 067d439 + 77f5823 commit 88ed50e

File tree

4 files changed

+42
-137
lines changed

4 files changed

+42
-137
lines changed

Cargo.toml

+3-122
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,4 @@
1-
[package]
2-
name = "plotters"
3-
version = "0.3.1"
4-
authors = ["Hao Hou <[email protected]>"]
5-
edition = "2021"
6-
license = "MIT"
7-
description = "A Rust drawing library focus on data plotting for both WASM and native applications"
8-
repository = "https://github.com/38/plotters"
9-
homepage = "https://plotters-rs.github.io/"
10-
keywords = ["WebAssembly", "Visualization", "Plotting", "Drawing"]
11-
categories = ["visualization", "wasm"]
12-
readme = "README.md"
13-
exclude = ["doc-template", "plotters-doc-data"]
1+
[workspace]
2+
members = ["plotters", "plotters-backend", "plotters-bitmap", "plotters-svg"]
3+
default-members = ["plotters"]
144

15-
[dependencies]
16-
num-traits = "0.2.14"
17-
chrono = { version = "0.4.19", optional = true }
18-
19-
[dependencies.plotters-backend]
20-
path = "../plotters-backend"
21-
22-
[dependencies.plotters-bitmap]
23-
default_features = false
24-
path = "../plotters-bitmap"
25-
optional = true
26-
27-
[dependencies.plotters-svg]
28-
path = "../plotters-svg"
29-
optional = true
30-
31-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
32-
ttf-parser = { version = "0.15.0", optional = true }
33-
lazy_static = { version = "1.4.0", optional = true }
34-
pathfinder_geometry = { version = "0.5.1", optional = true }
35-
font-kit = { version = "0.11.0", optional = true }
36-
37-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.image]
38-
version = "0.24.2"
39-
optional = true
40-
default-features = false
41-
features = ["jpeg", "png", "bmp"]
42-
43-
[target.'cfg(target_arch = "wasm32")'.dependencies.wasm-bindgen]
44-
version = "0.2.62"
45-
46-
[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
47-
version = "0.3.51"
48-
features = [
49-
"Document",
50-
"DomRect",
51-
"Element",
52-
"HtmlElement",
53-
"Node",
54-
"Window",
55-
"HtmlCanvasElement",
56-
"CanvasRenderingContext2d",
57-
]
58-
59-
[features]
60-
default = [
61-
"bitmap_backend", "bitmap_encoder", "bitmap_gif",
62-
"svg_backend",
63-
"chrono",
64-
"ttf",
65-
"image",
66-
"deprecated_items", "all_series", "all_elements",
67-
"full_palette"
68-
]
69-
all_series = ["area_series", "line_series", "point_series", "surface_series"]
70-
all_elements = ["errorbar", "candlestick", "boxplot", "histogram"]
71-
72-
# Tier 1 Backends
73-
bitmap_backend = ["plotters-bitmap", "ttf"]
74-
bitmap_encoder = ["plotters-bitmap/image_encoder"]
75-
bitmap_gif = ["plotters-bitmap/gif_backend"]
76-
svg_backend = ["plotters-svg"]
77-
78-
# Colors
79-
full_palette = []
80-
81-
# Elements
82-
errorbar = []
83-
candlestick = []
84-
boxplot = []
85-
86-
# Series
87-
histogram = []
88-
area_series = []
89-
line_series = []
90-
point_series = []
91-
surface_series = []
92-
93-
# Font implementation
94-
ttf = ["font-kit", "ttf-parser", "lazy_static", "pathfinder_geometry"]
95-
# dlopen fontconfig C library at runtime instead of linking at build time
96-
# Can be useful for cross compiling, especially considering fontconfig has lots of C dependencies
97-
fontconfig-dlopen = ["font-kit/source-fontconfig-dlopen"]
98-
99-
# Misc
100-
datetime = ["chrono"]
101-
evcxr = ["svg_backend"]
102-
deprecated_items = [] # Keep some of the deprecated items for backward compatibility
103-
104-
[dev-dependencies]
105-
itertools = "0.10.0"
106-
criterion = "0.3.4"
107-
rayon = "1.5.1"
108-
serde_json = "1.0.64"
109-
serde = "1.0.126"
110-
serde_derive = "1.0.126"
111-
112-
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
113-
rand = "0.8.3"
114-
rand_distr = "0.4.0"
115-
rand_xorshift = "0.3.0"
116-
117-
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
118-
wasm-bindgen-test = "0.3.24"
119-
120-
[[bench]]
121-
name = "benchmark"
122-
harness = false
123-
path = "benches/main.rs"

plotters/Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ optional = true
2828
path = "../plotters-svg"
2929
optional = true
3030

31-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
31+
[target.'cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))'.dependencies]
3232
ttf-parser = { version = "0.15.0", optional = true }
3333
lazy_static = { version = "1.4.0", optional = true }
3434
pathfinder_geometry = { version = "0.5.1", optional = true }
3535
font-kit = { version = "0.11.0", optional = true }
3636

37-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.image]
37+
[target.'cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))'.dependencies.image]
3838
version = "0.24.2"
3939
optional = true
4040
default-features = false
4141
features = ["jpeg", "png", "bmp"]
4242

43-
[target.'cfg(target_arch = "wasm32")'.dependencies.wasm-bindgen]
43+
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies.wasm-bindgen]
4444
version = "0.2.62"
4545

46-
[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
46+
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies.web-sys]
4747
version = "0.3.51"
4848
features = [
4949
"Document",
@@ -114,7 +114,7 @@ rand = "0.8.3"
114114
rand_distr = "0.4.0"
115115
rand_xorshift = "0.3.0"
116116

117-
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
117+
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies]
118118
wasm-bindgen-test = "0.3.24"
119119

120120
[[bench]]

plotters/src/element/image.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
#[cfg(all(not(target_arch = "wasm32"), feature = "image"))]
1+
#[cfg(all(
2+
not(all(target_arch = "wasm32", not(target_os = "wasi"))),
3+
feature = "image"
4+
))]
25
use image::{DynamicImage, GenericImageView};
36

47
use super::{Drawable, PointCollection};
58
use plotters_backend::{BackendCoord, DrawingBackend, DrawingErrorKind};
69

710
use plotters_bitmap::bitmap_pixel::{PixelFormat, RGBPixel};
811

9-
#[cfg(all(not(target_arch = "wasm32"), feature = "image"))]
12+
#[cfg(all(
13+
not(all(target_arch = "wasm32", not(target_os = "wasi"))),
14+
feature = "image"
15+
))]
1016
use plotters_bitmap::bitmap_pixel::BGRXPixel;
1117

1218
use plotters_bitmap::BitMapBackend;
@@ -164,7 +170,10 @@ impl<'a, Coord, P: PixelFormat> BitMapElement<'a, Coord, P> {
164170
}
165171
}
166172

167-
#[cfg(all(not(target_arch = "wasm32"), feature = "image"))]
173+
#[cfg(all(
174+
not(all(target_arch = "wasm32", not(target_os = "wasi"))),
175+
feature = "image"
176+
))]
168177
impl<'a, Coord> From<(Coord, DynamicImage)> for BitMapElement<'a, Coord, RGBPixel> {
169178
fn from((pos, image): (Coord, DynamicImage)) -> Self {
170179
let (w, h) = image.dimensions();
@@ -178,7 +187,10 @@ impl<'a, Coord> From<(Coord, DynamicImage)> for BitMapElement<'a, Coord, RGBPixe
178187
}
179188
}
180189

181-
#[cfg(all(not(target_arch = "wasm32"), feature = "image"))]
190+
#[cfg(all(
191+
not(all(target_arch = "wasm32", not(target_os = "wasi"))),
192+
feature = "image"
193+
))]
182194
impl<'a, Coord> From<(Coord, DynamicImage)> for BitMapElement<'a, Coord, BGRXPixel> {
183195
fn from((pos, image): (Coord, DynamicImage)) -> Self {
184196
let (w, h) = image.dimensions();

plotters/src/style/font/mod.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,31 @@
66
///
77
/// Thus we need different mechanism for the font implementation
88
9-
#[cfg(all(not(target_arch = "wasm32"), feature = "ttf"))]
9+
#[cfg(all(
10+
not(all(target_arch = "wasm32", not(target_os = "wasi"))),
11+
feature = "ttf"
12+
))]
1013
mod ttf;
11-
#[cfg(all(not(target_arch = "wasm32"), feature = "ttf"))]
14+
#[cfg(all(
15+
not(all(target_arch = "wasm32", not(target_os = "wasi"))),
16+
feature = "ttf"
17+
))]
1218
use ttf::FontDataInternal;
1319

14-
#[cfg(all(not(target_arch = "wasm32"), not(feature = "ttf")))]
20+
#[cfg(all(
21+
not(all(target_arch = "wasm32", not(target_os = "wasi"))),
22+
not(feature = "ttf")
23+
))]
1524
mod naive;
16-
#[cfg(all(not(target_arch = "wasm32"), not(feature = "ttf")))]
25+
#[cfg(all(
26+
not(all(target_arch = "wasm32", not(target_os = "wasi"))),
27+
not(feature = "ttf")
28+
))]
1729
use naive::FontDataInternal;
1830

19-
#[cfg(target_arch = "wasm32")]
31+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
2032
mod web;
21-
#[cfg(target_arch = "wasm32")]
33+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
2234
use web::FontDataInternal;
2335

2436
mod font_desc;

0 commit comments

Comments
 (0)