Skip to content

Commit 1987454

Browse files
authored
Add tests (#74)
* partial test coverage of common/mod.rs * finish tests for common.rs * start layout tests * finish tests for enums * just a few more structs to go for layout... * more tests * make tests pass * update changelog
1 parent bd00555 commit 1987454

File tree

7 files changed

+2062
-661
lines changed

7 files changed

+2062
-661
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Support for [configuration options](https://plotly.com/javascript/configuration-options/)
1111
- Support for layout templates and pre-defined themes
1212
- Support for WASM environments
13+
- Lots of tests
1314
### Changed
1415
- Improve implementation of `private::NumOrString` to support more primitive types ([Issue
1516
#47](https://github.com/igiagkiozis/plotly/issues/47))

plotly/examples/basic_charts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use itertools_num::linspace;
22
use plotly::common::{
33
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
44
};
5-
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
5+
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection, TraceOrder};
66
use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter, ScatterPolar};
77
use rand_distr::{Distribution, Normal, Uniform};
88

@@ -394,7 +394,7 @@ fn line_shape_options_for_interpolation(show: bool) {
394394
let layout = Layout::new().legend(
395395
Legend::new()
396396
.y(0.5)
397-
.trace_order("reversed")
397+
.trace_order(TraceOrder::Reversed)
398398
.font(Font::new().size(16)),
399399
);
400400
plot.set_layout(layout);
@@ -445,7 +445,7 @@ fn line_dash(show: bool) {
445445
.legend(
446446
Legend::new()
447447
.y(0.5)
448-
.trace_order("reversed")
448+
.trace_order(TraceOrder::Reversed)
449449
.font(Font::new().size(16)),
450450
)
451451
.x_axis(Axis::new().range(vec![0.95, 5.05]).auto_range(false))

plotly/examples/fundamentals.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use itertools_num::linspace;
2-
use plotly::common::{Fill, Font, Mode};
2+
use plotly::common::{DashType, Fill, Font, Mode};
33
use plotly::layout::{
44
Axis, GridPattern, Layout, LayoutGrid, Margin, Shape, ShapeLayer, ShapeLine, ShapeType,
55
};
@@ -56,7 +56,7 @@ fn vertical_and_horizontal_lines_positioned_relative_to_axes(show: bool) {
5656
ShapeLine::new()
5757
.color(NamedColor::LightSeaGreen)
5858
.width(3.)
59-
.dash("dashdot"),
59+
.dash(DashType::DashDot),
6060
),
6161
);
6262
layout.add_shape(
@@ -70,7 +70,7 @@ fn vertical_and_horizontal_lines_positioned_relative_to_axes(show: bool) {
7070
ShapeLine::new()
7171
.color(NamedColor::MediumPurple)
7272
.width(3.)
73-
.dash("dot"),
73+
.dash(DashType::Dot),
7474
),
7575
);
7676

plotly/examples/subplots.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use plotly::common::{Font, Side, Title};
2-
use plotly::layout::{Axis, GridPattern, Layout, LayoutGrid, Legend, RowOrder};
1+
use plotly::common::{AxisSide, Font, Title};
2+
use plotly::layout::{Axis, GridPattern, Layout, LayoutGrid, Legend, RowOrder, TraceOrder};
33
use plotly::{Plot, Rgb, Scatter};
44

55
// Subplots
@@ -124,7 +124,7 @@ fn stacked_subplots_with_shared_x_axis(show: bool) {
124124

125125
let layout = Layout::new()
126126
.y_axis(Axis::new().domain(&[0., 0.33]))
127-
.legend(Legend::new().trace_order("reversed"))
127+
.legend(Legend::new().trace_order(TraceOrder::Reversed))
128128
.y_axis2(Axis::new().domain(&[0.33, 0.66]))
129129
.y_axis3(Axis::new().domain(&[0.66, 1.]));
130130
plot.set_layout(layout);
@@ -197,7 +197,7 @@ fn two_y_axes(show: bool) {
197197
.title(Title::new("yaxis2 title").font(Font::new().color(Rgb::new(148, 103, 189))))
198198
.tick_font(Font::new().color(Rgb::new(148, 103, 189)))
199199
.overlaying("y")
200-
.side(Side::Right),
200+
.side(AxisSide::Right),
201201
);
202202
plot.set_layout(layout);
203203
if show {
@@ -235,7 +235,7 @@ fn multiple_axes(show: bool) {
235235
.tick_font(Font::new().color("#ff7f0e"))
236236
.anchor("free")
237237
.overlaying("y")
238-
.side(Side::Left)
238+
.side(AxisSide::Left)
239239
.position(0.15),
240240
)
241241
.y_axis3(
@@ -244,15 +244,15 @@ fn multiple_axes(show: bool) {
244244
.tick_font(Font::new().color("#d62728"))
245245
.anchor("x")
246246
.overlaying("y")
247-
.side(Side::Right),
247+
.side(AxisSide::Right),
248248
)
249249
.y_axis4(
250250
Axis::new()
251251
.title(Title::new("yaxis4 title").font(Font::new().color("#9467bd")))
252252
.tick_font(Font::new().color("#9467bd"))
253253
.anchor("free")
254254
.overlaying("y")
255-
.side(Side::Right)
255+
.side(AxisSide::Right)
256256
.position(0.85),
257257
);
258258
plot.set_layout(layout);

0 commit comments

Comments
 (0)