Skip to content

Commit e6951fd

Browse files
committed
Add feature options for elements
1 parent 4fb916f commit e6951fd

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ version = "0.3.29"
4848
features = ['Document', 'DomRect', 'Element', 'HtmlElement', 'Node', 'Window', 'HtmlCanvasElement', 'CanvasRenderingContext2d']
4949

5050
[features]
51-
default = ["image_encoder", "svg", "chrono", "palette_ext", "gif_backend", "deprecated_items", "bitmap", "ttf"]
51+
default = ["image_encoder", "svg", "chrono", "palette_ext", "gif_backend", "deprecated_items", "bitmap", "ttf", "errorbar", "candlestick", "boxplot"]
5252
ttf = ["font-kit", "rusttype", "lazy_static"]
5353
image_encoder = ["image", "bitmap"]
5454
palette_ext = ["palette"]
@@ -61,6 +61,9 @@ cairo = ["cairo-rs", "ttf"]
6161
bitmap = ["ttf"]
6262
deprecated_items = [] # Keep some of the deprecated items for backward compatibility
6363
debug = [] # Enable debugging code
64+
errorbar = []
65+
candlestick = []
66+
boxplot = []
6467

6568

6669
[dev-dependencies]

src/drawing/backend_impl/svg.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use crate::style::text_anchor::{HPos, VPos};
77
use crate::style::{Color, FontStyle, FontTransform, RGBAColor, TextStyle};
88

99
use std::fs::File;
10-
use std::io::{BufWriter, Cursor, Error, Write};
10+
#[allow(unused_imports)]
11+
use std::io::Cursor;
12+
use std::io::{BufWriter, Error, Write};
1113
use std::path::Path;
1214

1315
fn make_svg_color<C: Color>(color: &C) -> String {
@@ -42,6 +44,7 @@ enum SVGTag {
4244
Polyline,
4345
Rectangle,
4446
Text,
47+
#[allow(dead_code)]
4548
Image,
4649
}
4750

src/element/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,19 @@ pub use points::*;
170170
mod composable;
171171
pub use composable::{ComposedElement, EmptyElement};
172172

173+
#[cfg(feature = "candlestick")]
173174
mod candlestick;
175+
#[cfg(feature = "candlestick")]
174176
pub use candlestick::CandleStick;
175177

178+
#[cfg(feature = "errorbar")]
176179
mod errorbar;
180+
#[cfg(feature = "errorbar")]
177181
pub use errorbar::{ErrorBar, ErrorBarOrientH, ErrorBarOrientV};
178182

183+
#[cfg(feature = "boxplot")]
179184
mod boxplot;
185+
#[cfg(feature = "boxplot")]
180186
pub use boxplot::Boxplot;
181187

182188
#[cfg(feature = "bitmap")]

src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,10 +687,17 @@ pub mod prelude {
687687
pub use crate::style::{BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, TRANSPARENT, WHITE, YELLOW};
688688

689689
pub use crate::element::{
690-
Boxplot, CandleStick, Circle, Cross, DynElement, EmptyElement, ErrorBar, IntoDynElement,
691-
MultiLineText, PathElement, Pixel, Polygon, Rectangle, Text, TriangleMarker,
690+
Circle, Cross, DynElement, EmptyElement, IntoDynElement, MultiLineText, PathElement, Pixel,
691+
Polygon, Rectangle, Text, TriangleMarker,
692692
};
693693

694+
#[cfg(feature = "boxplot")]
695+
pub use crate::element::Boxplot;
696+
#[cfg(feature = "candlestick")]
697+
pub use crate::element::CandleStick;
698+
#[cfg(feature = "errorbar")]
699+
pub use crate::element::ErrorBar;
700+
694701
#[cfg(feature = "bitmap")]
695702
pub use crate::element::BitMapElement;
696703

0 commit comments

Comments
 (0)