Skip to content

Commit 707a698

Browse files
author
Ioannis Giagkiozis
committed
Default impl
1 parent a87d999 commit 707a698

File tree

20 files changed

+174
-753
lines changed

20 files changed

+174
-753
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
8+
## [0.5.1] - 2020-07-12
9+
### Added
10+
- From<&str> implementation for `Title`.
11+
### Changed
12+
- Optimised dependencies.
13+
- Clearer deprecation message for `orca` related methods.
14+
- Wider use of `Default`.
15+
16+
717
## [0.5.0] - 2020-07-12
818
### Added
919
- [Plotly.rs Book](https://igiagkiozis.github.io/plotly/).

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Add this to your `Cargo.toml`:
4040

4141
```toml
4242
[dependencies]
43-
plotly = "0.5.0"
43+
plotly = "0.5.1"
4444
```
4545

4646
For changes since the last version please consult the [change log](https://github.com/igiagkiozis/plotly/blob/master/CHANGELOG.md).
@@ -51,13 +51,13 @@ The following feature flags are available:
5151
* Optional, compatible with Rust stable.
5252
* Adds plot save functionality to the following formats: png, jpeg, webp, svg, pdf and eps.
5353
* Requires some additional configuration, see [plotly_kaleido](https://github.com/igiagkiozis/plotly/tree/master/plotly_kaleido).
54-
* `orca` - This feature is **Deprecated**, please use `kaleido` instead.
54+
* `orca` - This feature is **deprecated**, please use `kaleido` instead.
5555

5656
Saving to png, jpeg, webp, svg, pdf and eps formats can be made available by enabling the `kaleido` feature:
5757

5858
```toml
5959
[dependencies]
60-
plotly = { version = "0.5.0", features = ["kaleido"] }
60+
plotly = { version = "0.5.1", features = ["kaleido"] }
6161
```
6262
For further details please see [plotly_kaleido](https://github.com/igiagkiozis/plotly/tree/master/plotly_kaleido).
6363

docs/book/src/getting_started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ To start using `Plotly.rs` in your project add the following to your `Cargo.toml
44

55
```toml
66
[dependencies]
7-
plotly = "0.5.0"
7+
plotly = "0.5.1"
88
```
99

1010
To add the ability to save plots in the following formats: png, jpeg, webp, svg, pdf and eps, you can use the `kaleido` feature. This feature depends on [plotly/Kaleido](https://github.com/plotly/Kaleido); a cross-platform library for generating static images. All the necessary binaries have been included with `plotly_kaleido` for `linux`, `windows` and `macos`. Previous versions of `Plotly.rs` used the `orca` feature; however this has been deprecated as it provided the same functionality but required additional installation steps. To enable the `kaleido` feature add the following to your `Cargo.toml` instead:
1111

1212
```toml
1313
[dependencies]
14-
plotly = { version = "0.5.0", features = ["kaleido"] }
14+
plotly = { version = "0.5.1", features = ["kaleido"] }
1515
```
1616

1717
Plotly Kaleido is an open source project

plotly/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "plotly"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
description = "A plotting library powered by Plotly.js"
55
authors = ["Ioannis Giagkiozis <[email protected]>"]
66
license = "MIT"
@@ -34,7 +34,6 @@ num = "0.2.1"
3434
[dev-dependencies]
3535
plotly_orca = { version = "0.2.1", path = "../plotly_orca" }
3636
plotly_kaleido = { version = "0.1.0", path = "../plotly_kaleido" }
37-
3837
itertools = "0.9.0"
3938
itertools-num = "0.1.3"
4039
csv = "1.1.3"

plotly/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Add this to your `Cargo.toml`:
4040

4141
```toml
4242
[dependencies]
43-
plotly = "0.5.0"
43+
plotly = "0.5.1"
4444
```
4545

4646
For changes since the last version please consult the [change log](https://github.com/igiagkiozis/plotly/blob/master/CHANGELOG.md).
@@ -51,13 +51,13 @@ The following feature flags are available:
5151
* Optional, compatible with Rust stable.
5252
* Adds plot save functionality to the following formats: png, jpeg, webp, svg, pdf and eps.
5353
* Requires some additional configuration, see [plotly_kaleido](https://github.com/igiagkiozis/plotly/tree/master/plotly_kaleido).
54-
* `orca` - This feature is **Deprecated**, please use `kaleido` instead.
54+
* `orca` - This feature is **deprecated**, please use `kaleido` instead.
5555

5656
Saving to png, jpeg, webp, svg, pdf and eps formats can be made available by enabling the `kaleido` feature:
5757

5858
```toml
5959
[dependencies]
60-
plotly = { version = "0.5.0", features = ["kaleido"] }
60+
plotly = { version = "0.5.1", features = ["kaleido"] }
6161
```
6262
For further details please see [plotly_kaleido](https://github.com/igiagkiozis/plotly/tree/master/plotly_kaleido).
6363

plotly/examples/basic_charts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ fn data_labels_hover(show: bool) {
9797
plot.add_trace(trace2);
9898

9999
let layout = Layout::new()
100-
.title(Title::new("Data Labels Hover"))
101-
.x_axis(Axis::new().title(Title::new("x")).range(vec![0.75, 5.25]))
102-
.y_axis(Axis::new().title(Title::new("y")).range(vec![0., 8.]));
100+
.title("Data Labels Hover".into())
101+
.x_axis(Axis::new().title("x".into()).range(vec![0.75, 5.25]))
102+
.y_axis(Axis::new().title("y".into()).range(vec![0., 8.]));
103103
plot.set_layout(layout);
104104
if show {
105105
plot.show();
@@ -124,7 +124,7 @@ fn data_labels_on_the_plot(show: bool) {
124124
plot.add_trace(trace2);
125125

126126
let layout = Layout::new()
127-
.title(Title::new("Data Labels on the Plot"))
127+
.title("Data Labels on the Plot".into())
128128
.x_axis(Axis::new().range(vec![0.75, 5.25]))
129129
.y_axis(Axis::new().range(vec![0., 8.]));
130130
plot.set_layout(layout);

plotly/src/bar.rs

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ use serde::Serialize;
99

1010
use crate::private;
1111

12-
#[derive(Serialize, Debug)]
12+
#[derive(Serialize, Debug, Default)]
1313
pub struct Bar<X, Y>
1414
where
15-
X: Serialize,
16-
Y: num::Num + Serialize,
15+
X: Serialize + Default,
16+
Y: num::Num + Serialize + Default,
1717
{
1818
x: Vec<X>,
1919
y: Vec<Y>,
@@ -86,46 +86,15 @@ where
8686

8787
impl<X, Y> Bar<X, Y>
8888
where
89-
X: Serialize,
90-
Y: num::Num + Serialize,
89+
X: Serialize + Default,
90+
Y: num::Num + Serialize + Default,
9191
{
9292
pub fn new(x: Vec<X>, y: Vec<Y>) -> Box<Bar<X, Y>> {
9393
Box::new(Bar {
9494
x,
9595
y,
9696
r#type: PlotType::Bar,
97-
name: None,
98-
visible: None,
99-
show_legend: None,
100-
legend_group: None,
101-
opacity: None,
102-
ids: None,
103-
width: None,
104-
offset: None,
105-
text: None,
106-
text_position: None,
107-
text_template: None,
108-
hover_text: None,
109-
hover_info: None,
110-
hover_template: None,
111-
x_axis: None,
112-
y_axis: None,
113-
orientation: None,
114-
alignment_group: None,
115-
offset_group: None,
116-
marker: None,
117-
text_angle: None,
118-
text_font: None,
119-
error_x: None,
120-
error_y: None,
121-
clip_on_axis: None,
122-
constrain_text: None,
123-
hover_label: None,
124-
inside_text_anchor: None,
125-
inside_text_font: None,
126-
outside_text_font: None,
127-
x_calendar: None,
128-
y_calendar: None,
97+
..Default::default()
12998
})
13099
}
131100

@@ -327,8 +296,8 @@ where
327296

328297
impl<X, Y> Trace for Bar<X, Y>
329298
where
330-
X: Serialize,
331-
Y: num::Num + Serialize,
299+
X: Serialize + Default,
300+
Y: num::Num + Serialize + Default,
332301
{
333302
fn serialize(&self) -> String {
334303
serde_json::to_string(&self).unwrap()

plotly/src/box_plot.rs

Lines changed: 11 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ pub enum QuartileMethod {
3838
Inclusive,
3939
}
4040

41-
#[derive(Serialize, Debug)]
41+
#[derive(Serialize, Debug, Default)]
4242
pub struct BoxPlot<Y, X>
4343
where
44-
Y: Serialize,
45-
X: Serialize,
44+
Y: Serialize + Default,
45+
X: Serialize + Default,
4646
{
4747
r#type: PlotType,
4848
#[serde(skip_serializing_if = "Option::is_none")]
@@ -129,103 +129,29 @@ where
129129

130130
impl<Y> BoxPlot<Y, f64>
131131
where
132-
Y: Serialize,
132+
Y: Serialize + Default,
133133
{
134134
pub fn new(y: Vec<Y>) -> Box<BoxPlot<Y, f64>> {
135135
Box::new(BoxPlot {
136136
r#type: PlotType::Box,
137137
x: None,
138138
y: Some(y),
139-
name: None,
140-
visible: None,
141-
show_legend: None,
142-
legend_group: None,
143-
opacity: None,
144-
ids: None,
145-
width: None,
146-
text: None,
147-
hover_text: None,
148-
hover_info: None,
149-
hover_template: None,
150-
x_axis: None,
151-
y_axis: None,
152-
orientation: None,
153-
alignment_group: None,
154-
offset_group: None,
155-
marker: None,
156-
line: None,
157-
box_mean: None,
158-
box_points: None,
159-
notched: None,
160-
notch_width: None,
161-
whisker_width: None,
162-
q1: None,
163-
median: None,
164-
q3: None,
165-
lower_fence: None,
166-
notch_span: None,
167-
mean: None,
168-
standard_deviation: None,
169-
quartile_method: None,
170-
fill_color: None,
171-
hover_label: None,
172-
hover_on: None,
173-
point_pos: None,
174-
jitter: None,
175-
x_calendar: None,
176-
y_calendar: None,
139+
..Default::default()
177140
})
178141
}
179142
}
180143

181144
impl<Y, X> BoxPlot<Y, X>
182145
where
183-
Y: Serialize,
184-
X: Serialize,
146+
Y: Serialize + Default,
147+
X: Serialize + Default,
185148
{
186149
pub fn new_xy(x: Vec<X>, y: Vec<Y>) -> Box<BoxPlot<Y, X>> {
187150
Box::new(BoxPlot {
188151
r#type: PlotType::Box,
189152
x: Some(x),
190153
y: Some(y),
191-
name: None,
192-
visible: None,
193-
show_legend: None,
194-
legend_group: None,
195-
opacity: None,
196-
ids: None,
197-
width: None,
198-
text: None,
199-
hover_text: None,
200-
hover_info: None,
201-
hover_template: None,
202-
x_axis: None,
203-
y_axis: None,
204-
orientation: None,
205-
alignment_group: None,
206-
offset_group: None,
207-
marker: None,
208-
line: None,
209-
box_mean: None,
210-
box_points: None,
211-
notched: None,
212-
notch_width: None,
213-
whisker_width: None,
214-
q1: None,
215-
median: None,
216-
q3: None,
217-
lower_fence: None,
218-
notch_span: None,
219-
mean: None,
220-
standard_deviation: None,
221-
quartile_method: None,
222-
fill_color: None,
223-
hover_label: None,
224-
hover_on: None,
225-
point_pos: None,
226-
jitter: None,
227-
x_calendar: None,
228-
y_calendar: None,
154+
..Default::default()
229155
})
230156
}
231157

@@ -234,44 +160,7 @@ where
234160
r#type: PlotType::Box,
235161
x: Some(x),
236162
y: None,
237-
name: None,
238-
visible: None,
239-
show_legend: None,
240-
legend_group: None,
241-
opacity: None,
242-
ids: None,
243-
width: None,
244-
text: None,
245-
hover_text: None,
246-
hover_info: None,
247-
hover_template: None,
248-
x_axis: None,
249-
y_axis: None,
250-
orientation: None,
251-
alignment_group: None,
252-
offset_group: None,
253-
marker: None,
254-
line: None,
255-
box_mean: None,
256-
box_points: None,
257-
notched: None,
258-
notch_width: None,
259-
whisker_width: None,
260-
q1: None,
261-
median: None,
262-
q3: None,
263-
lower_fence: None,
264-
notch_span: None,
265-
mean: None,
266-
standard_deviation: None,
267-
quartile_method: None,
268-
fill_color: None,
269-
hover_label: None,
270-
hover_on: None,
271-
point_pos: None,
272-
jitter: None,
273-
x_calendar: None,
274-
y_calendar: None,
163+
..Default::default()
275164
})
276165
}
277166

@@ -490,8 +379,8 @@ where
490379

491380
impl<X, Y> Trace for BoxPlot<X, Y>
492381
where
493-
X: Serialize,
494-
Y: Serialize,
382+
X: Serialize + Default,
383+
Y: Serialize + Default,
495384
{
496385
fn serialize(&self) -> String {
497386
serde_json::to_string(&self).unwrap()

0 commit comments

Comments
 (0)