Skip to content

Commit 3228ef1

Browse files
committed
Fix examples failing clippy
1 parent 8f23ae3 commit 3228ef1

File tree

8 files changed

+45
-56
lines changed

8 files changed

+45
-56
lines changed

examples/3d_charts/src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use ndarray::Array;
44
use plotly::{
55
color::Rgb,
6-
common::{ColorScale, ColorScalePalette, Font, Marker, MarkerSymbol, Mode, Title},
6+
common::{ColorScale, ColorScalePalette, Font, Marker, MarkerSymbol, Mode},
77
layout::{Axis, Camera, Layout, LayoutScene, Legend, Margin, ProjectionType},
88
Mesh3D, Plot, Scatter3D, Surface,
99
};
@@ -66,27 +66,27 @@ fn customized_scatter3d_plot() {
6666
let front_color: Rgb = Rgb::new(255, 255, 255);
6767

6868
let layout = Layout::new()
69-
.title("Helix".into())
69+
.title("Helix")
7070
.legend(Legend::new().x(0.9).y(0.9))
7171
.font(Font::new().color(front_color))
7272
.paper_background_color(background_color)
7373
.scene(
7474
LayoutScene::new()
7575
.x_axis(
7676
Axis::new()
77-
.title("x (A meaningful axis name goes here)".into())
77+
.title("x (A meaningful axis name goes here)")
7878
.tick_angle(0f64)
7979
.grid_color(front_color)
8080
.color(front_color),
8181
)
8282
.y_axis(
8383
Axis::new()
84-
.title(Title::new("This is the label of the Y axis"))
84+
.title("This is the label of the Y axis")
8585
.tick_format(".1f")
8686
.grid_color(front_color)
8787
.color(front_color),
8888
)
89-
.z_axis(Axis::new().title("".into()).tick_values(vec![]))
89+
.z_axis(Axis::new().title("").tick_values(vec![]))
9090
.aspect_mode(plotly::layout::AspectMode::Manual)
9191
.aspect_ratio((3.0, 1.0, 1.0).into())
9292
.camera(

examples/basic_charts/src/main.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use plotly::{
55
color::{NamedColor, Rgb, Rgba},
66
common::{
77
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode,
8-
Orientation, Title,
8+
Orientation,
99
},
1010
layout::{Axis, BarMode, Layout, Legend, TicksDirection, TraceOrder},
1111
sankey::{Line as SankeyLine, Link, Node},
@@ -117,9 +117,9 @@ fn data_labels_hover() {
117117
plot.add_trace(trace2);
118118

119119
let layout = Layout::new()
120-
.title("Data Labels Hover".into())
121-
.x_axis(Axis::new().title("x".into()).range(vec![0.75, 5.25]))
122-
.y_axis(Axis::new().title("y".into()).range(vec![0., 8.]));
120+
.title("Data Labels Hover")
121+
.x_axis(Axis::new().title("x").range(vec![0.75, 5.25]))
122+
.y_axis(Axis::new().title("y").range(vec![0., 8.]));
123123
plot.set_layout(layout);
124124

125125
plot.show();
@@ -142,7 +142,7 @@ fn data_labels_on_the_plot() {
142142
plot.add_trace(trace2);
143143

144144
let layout = Layout::new()
145-
.title("Data Labels on the Plot".into())
145+
.title("Data Labels on the Plot")
146146
.x_axis(Axis::new().range(vec![0.75, 5.25]))
147147
.y_axis(Axis::new().range(vec![0., 8.]));
148148
plot.set_layout(layout);
@@ -215,14 +215,14 @@ fn colored_and_styled_scatter_plot() {
215215
.marker(Marker::new().color(Rgb::new(142, 124, 195)).size(12));
216216

217217
let layout = Layout::new()
218-
.title(Title::new("Quarter 1 Growth"))
218+
.title("Quarter 1 Growth")
219219
.x_axis(
220220
Axis::new()
221-
.title(Title::new("GDP per Capita"))
221+
.title("GDP per Capita")
222222
.show_grid(false)
223223
.zero_line(false),
224224
)
225-
.y_axis(Axis::new().title(Title::new("Percent")).show_line(false));
225+
.y_axis(Axis::new().title("Percent").show_line(false));
226226
let mut plot = Plot::new();
227227
plot.add_trace(trace1);
228228
plot.add_trace(trace2);
@@ -279,7 +279,7 @@ fn adding_names_to_line_and_scatter_plot() {
279279
.mode(Mode::LinesMarkers)
280280
.name("Scatter + Lines");
281281

282-
let layout = Layout::new().title(Title::new("Adding Names to Line and Scatter Plot"));
282+
let layout = Layout::new().title("Adding Names to Line and Scatter Plot");
283283
let mut plot = Plot::new();
284284
plot.add_trace(trace1);
285285
plot.add_trace(trace2);
@@ -304,7 +304,7 @@ fn line_and_scatter_styling() {
304304
.marker(Marker::new().color(Rgb::new(128, 0, 128)).size(12))
305305
.line(Line::new().color(Rgb::new(128, 0, 128)).width(1.0));
306306

307-
let layout = Layout::new().title(Title::new("Line and Scatter Styling"));
307+
let layout = Layout::new().title("Line and Scatter Styling");
308308
let mut plot = Plot::new();
309309
plot.add_trace(trace1);
310310
plot.add_trace(trace2);
@@ -325,7 +325,7 @@ fn styling_line_plot() {
325325
.line(Line::new().color(Rgb::new(55, 128, 191)).width(1.0));
326326

327327
let layout = Layout::new()
328-
.title(Title::new("Styling Line Plot"))
328+
.title("Styling Line Plot")
329329
.width(500)
330330
.height(500);
331331
let mut plot = Plot::new();
@@ -594,7 +594,7 @@ fn basic_sankey_diagram() {
594594
);
595595

596596
let layout = Layout::new()
597-
.title("Basic Sankey".into())
597+
.title("Basic Sankey")
598598
.font(Font::new().size(10));
599599

600600
let mut plot = Plot::new();

examples/financial_charts/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::env;
44
use std::path::PathBuf;
55

6-
use plotly::common::{TickFormatStop, Title};
6+
use plotly::common::TickFormatStop;
77
use plotly::layout::{Axis, RangeSelector, RangeSlider, SelectorButton, SelectorStep, StepMode};
88
use plotly::{Candlestick, Layout, Ohlc, Plot, Scatter};
99
use serde::Deserialize;
@@ -50,7 +50,7 @@ fn time_series_plot_with_custom_date_range() {
5050

5151
let layout = Layout::new()
5252
.x_axis(Axis::new().range(vec!["2016-07-01", "2016-12-31"]))
53-
.title(Title::new("Manually Set Date Range"));
53+
.title("Manually Set Date Range");
5454
plot.set_layout(layout);
5555

5656
plot.show();
@@ -68,7 +68,7 @@ fn time_series_with_range_slider() {
6868

6969
let layout = Layout::new()
7070
.x_axis(Axis::new().range_slider(RangeSlider::new().visible(true)))
71-
.title(Title::new("Manually Set Date Range"));
71+
.title("Manually Set Date Range");
7272
plot.set_layout(layout);
7373

7474
plot.show();

examples/scientific_charts/src/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::f64::consts::PI;
44

5-
use plotly::common::{ColorScale, ColorScalePalette, Title};
5+
use plotly::common::{ColorScale, ColorScalePalette};
66
use plotly::contour::Contours;
77
use plotly::{Contour, HeatMap, Layout, Plot};
88

@@ -47,7 +47,7 @@ fn colorscale_for_contour_plot() {
4747
];
4848
let trace = Contour::new_z(z).color_scale(ColorScale::Palette(ColorScalePalette::Jet));
4949

50-
let layout = Layout::new().title(Title::new("Colorscale for Contour Plot"));
50+
let layout = Layout::new().title("Colorscale for Contour Plot");
5151
let mut plot = Plot::new();
5252
plot.set_layout(layout);
5353
plot.add_trace(trace);
@@ -68,7 +68,7 @@ fn customizing_size_and_range_of_a_contour_plots_contours() {
6868
.auto_contour(false)
6969
.contours(Contours::new().start(0.0).end(8.0).size(2));
7070

71-
let layout = Layout::new().title(Title::new("Customizing Size and Range of Contours"));
71+
let layout = Layout::new().title("Customizing Size and Range of Contours");
7272
let mut plot = Plot::new();
7373
plot.set_layout(layout);
7474
plot.add_trace(trace);
@@ -91,7 +91,7 @@ fn customizing_spacing_between_x_and_y_ticks() {
9191
.dy(10.0)
9292
.y0(10.0);
9393

94-
let layout = Layout::new().title(Title::new("Customizing Size and Range of Contours"));
94+
let layout = Layout::new().title("Customizing Size and Range of Contours");
9595
let mut plot = Plot::new();
9696
plot.set_layout(layout);
9797
plot.add_trace(trace);

examples/shapes/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn creating_tangent_lines_with_shapes() {
138138
plot.add_trace(trace);
139139

140140
let mut layout =
141-
Layout::new().title("$f(x)=x\\sin(x^2)+1\\\\ f\'(x)=\\sin(x^2)+2x^2\\cos(x^2)$".into());
141+
Layout::new().title("$f(x)=x\\sin(x^2)+1\\\\ f\'(x)=\\sin(x^2)+2x^2\\cos(x^2)$");
142142

143143
layout.add_shape(
144144
Shape::new()

examples/statistical_charts/src/main.rs

+10-20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use ndarray::Array;
44
use plotly::{
55
box_plot::{BoxMean, BoxPoints},
66
color::{NamedColor, Rgb, Rgba},
7-
common::{ErrorData, ErrorType, Line, Marker, Mode, Orientation, Title},
7+
common::{ErrorData, ErrorType, Line, Marker, Mode, Orientation},
88
histogram::{Bins, Cumulative, HistFunc, HistNorm},
99
layout::{Axis, BarMode, BoxMode, Layout, Margin},
1010
Bar, BoxPlot, Histogram, Plot, Scatter,
@@ -203,11 +203,7 @@ fn grouped_box_plot() {
203203
plot.add_trace(trace3);
204204

205205
let layout = Layout::new()
206-
.y_axis(
207-
Axis::new()
208-
.title(Title::new("normalized moisture"))
209-
.zero_line(false),
210-
)
206+
.y_axis(Axis::new().title("normalized moisture").zero_line(false))
211207
.box_mode(BoxMode::Group);
212208

213209
plot.set_layout(layout);
@@ -248,7 +244,7 @@ fn box_plot_styling_outliers() {
248244
.marker(Marker::new().color(Rgb::new(107, 174, 214)))
249245
.box_points(BoxPoints::Outliers);
250246

251-
let layout = Layout::new().title(Title::new("Box Plot Styling Outliers"));
247+
let layout = Layout::new().title("Box Plot Styling Outliers");
252248

253249
let mut plot = Plot::new();
254250
plot.set_layout(layout);
@@ -274,7 +270,7 @@ fn box_plot_styling_mean_and_standard_deviation() {
274270
.name("Mean and Standard Deviation")
275271
.marker(Marker::new().color(Rgb::new(8, 81, 156)))
276272
.box_mean(BoxMean::StandardDeviation);
277-
let layout = Layout::new().title(Title::new("Box Plot Styling Mean and Standard Deviation"));
273+
let layout = Layout::new().title("Box Plot Styling Mean and Standard Deviation");
278274

279275
let mut plot = Plot::new();
280276
plot.set_layout(layout);
@@ -321,12 +317,8 @@ fn grouped_horizontal_box_plot() {
321317
plot.add_trace(trace3);
322318

323319
let layout = Layout::new()
324-
.title(Title::new("Grouped Horizontal Box Plot"))
325-
.x_axis(
326-
Axis::new()
327-
.title(Title::new("normalized moisture"))
328-
.zero_line(false),
329-
)
320+
.title("Grouped Horizontal Box Plot")
321+
.x_axis(Axis::new().title("normalized moisture").zero_line(false))
330322
.box_mode(BoxMode::Group);
331323

332324
plot.set_layout(layout);
@@ -370,9 +362,7 @@ fn fully_styled_box_plot() {
370362

371363
let mut plot = Plot::new();
372364
let layout = Layout::new()
373-
.title(Title::new(
374-
"Points Scored by the Top 9 Scoring NBA Players in 2012",
375-
))
365+
.title("Points Scored by the Top 9 Scoring NBA Players in 2012")
376366
.y_axis(
377367
Axis::new()
378368
.auto_range(true)
@@ -522,9 +512,9 @@ fn colored_and_styled_histograms() {
522512
.auto_bin_x(false)
523513
.x_bins(Bins::new(-3.2, 4.0, 0.06));
524514
let layout = Layout::new()
525-
.title(Title::new("Colored and Styled Histograms"))
526-
.x_axis(Axis::new().title(Title::new("Value")))
527-
.y_axis(Axis::new().title(Title::new("Count")))
515+
.title("Colored and Styled Histograms")
516+
.x_axis(Axis::new().title("Value"))
517+
.y_axis(Axis::new().title("Count"))
528518
.bar_mode(BarMode::Overlay)
529519
.bar_gap(0.05)
530520
.bar_group_gap(0.2);

examples/subplots/src/main.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn multiple_custom_sized_subplots() {
148148
plot.add_trace(trace4);
149149

150150
let layout = Layout::new()
151-
.title(Title::new("Multiple Custom Sized Subplots"))
151+
.title("Multiple Custom Sized Subplots")
152152
.x_axis(Axis::new().domain(&[0., 0.45]).anchor("y1"))
153153
.y_axis(Axis::new().domain(&[0.5, 1.]).anchor("x1"))
154154
.x_axis2(Axis::new().domain(&[0.55, 1.]).anchor("y2"))
@@ -174,11 +174,11 @@ fn two_y_axes() {
174174
plot.add_trace(trace2);
175175

176176
let layout = Layout::new()
177-
.title(Title::new("Double Y Axis Example"))
178-
.y_axis(Axis::new().title(Title::new("yaxis title")))
177+
.title("Double Y Axis Example")
178+
.y_axis(Axis::new().title("yaxis title"))
179179
.y_axis2(
180180
Axis::new()
181-
.title(Title::new("yaxis2 title").font(Font::new().color(Rgb::new(148, 103, 189))))
181+
.title(Title::from("yaxis2 title").font(Font::new().color(Rgb::new(148, 103, 189))))
182182
.tick_font(Font::new().color(Rgb::new(148, 103, 189)))
183183
.overlaying("y")
184184
.side(AxisSide::Right),
@@ -203,17 +203,17 @@ fn multiple_axes() {
203203
plot.add_trace(trace4);
204204

205205
let layout = Layout::new()
206-
.title(Title::new("multiple y-axes example"))
206+
.title("multiple y-axes example")
207207
.width(800)
208208
.x_axis(Axis::new().domain(&[0.3, 0.7]))
209209
.y_axis(
210210
Axis::new()
211-
.title(Title::new("yaxis title").font(Font::new().color("#1f77b4")))
211+
.title(Title::from("yaxis title").font(Font::new().color("#1f77b4")))
212212
.tick_font(Font::new().color("#1f77b4")),
213213
)
214214
.y_axis2(
215215
Axis::new()
216-
.title(Title::new("yaxis2 title").font(Font::new().color("#ff7f0e")))
216+
.title(Title::from("yaxis2 title").font(Font::new().color("#ff7f0e")))
217217
.tick_font(Font::new().color("#ff7f0e"))
218218
.anchor("free")
219219
.overlaying("y")
@@ -222,15 +222,15 @@ fn multiple_axes() {
222222
)
223223
.y_axis3(
224224
Axis::new()
225-
.title(Title::new("yaxis3 title").font(Font::new().color("#d62728")))
225+
.title(Title::from("yaxis3 title").font(Font::new().color("#d62728")))
226226
.tick_font(Font::new().color("#d62728"))
227227
.anchor("x")
228228
.overlaying("y")
229229
.side(AxisSide::Right),
230230
)
231231
.y_axis4(
232232
Axis::new()
233-
.title(Title::new("yaxis4 title").font(Font::new().color("#9467bd")))
233+
.title(Title::from("yaxis4 title").font(Font::new().color("#9467bd")))
234234
.tick_font(Font::new().color("#9467bd"))
235235
.anchor("free")
236236
.overlaying("y")

examples/wasm-yew-minimal/src/main.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ pub fn plot_component() -> Html {
99
let trace = Scatter::new(vec![0, 1, 2], vec![2, 1, 0]);
1010
plot.add_trace(trace);
1111

12-
let layout =
13-
plotly::Layout::new().title(plotly::common::Title::new("Displaying a Chart in Yew"));
12+
let layout = plotly::Layout::new().title("Displaying a Chart in Yew");
1413
plot.set_layout(layout);
1514

1615
async move {

0 commit comments

Comments
 (0)