diff --git a/examples/maps/src/main.rs b/examples/maps/src/main.rs index 73428b9c..5ab7e8ba 100644 --- a/examples/maps/src/main.rs +++ b/examples/maps/src/main.rs @@ -3,10 +3,8 @@ use plotly::{ color::Rgb, common::{Line, Marker, Mode}, - layout::{ - Axis, Center, DragMode, LayoutGeo, Mapbox, MapboxStyle, Margin, Projection, Rotation, - }, - DensityMapbox, Layout, Plot, ScatterGeo, ScatterMapbox, + layout::{Axis, Center, DragMode, LayoutGeo, Mapbox, MapboxStyle, Projection, Rotation}, + Configuration, DensityMapbox, Layout, Plot, ScatterGeo, ScatterMapbox, }; use plotly_utils::write_example_to_html; @@ -14,19 +12,17 @@ fn scatter_mapbox(show: bool, file_name: &str) { let trace = ScatterMapbox::new(vec![45.5017], vec![-73.5673]) .marker(Marker::new().size(25).opacity(0.9)); - let layout = Layout::new() - .drag_mode(DragMode::Zoom) - .margin(Margin::new().top(0).left(0).bottom(0).right(0)) - .mapbox( - Mapbox::new() - .style(MapboxStyle::OpenStreetMap) - .center(Center::new(45.5017, -73.5673)) - .zoom(5), - ); + let layout = Layout::new().drag_mode(DragMode::Zoom).mapbox( + Mapbox::new() + .style(MapboxStyle::OpenStreetMap) + .center(Center::new(45.5017, -73.5673)) + .zoom(5), + ); let mut plot = Plot::new(); plot.add_trace(trace); plot.set_layout(layout); + plot.set_configuration(Configuration::default().responsive(true).fill_frame(true)); let path = write_example_to_html(&plot, file_name); if show { @@ -100,35 +96,33 @@ fn scatter_geo(show: bool, file_name: &str) { plot.add_trace(trace); } - let layout = Layout::new() - .drag_mode(DragMode::Zoom) - .margin(Margin::new().top(0).left(0).bottom(0).right(0)) - .geo( - LayoutGeo::new() - .showocean(true) - .showlakes(true) - .showcountries(true) - .showland(true) - .oceancolor(Rgb::new(0, 255, 255)) - .lakecolor(Rgb::new(0, 255, 255)) - .landcolor(Rgb::new(230, 145, 56)) - .lataxis( - Axis::new() - .show_grid(true) - .grid_color(Rgb::new(102, 102, 102)), - ) - .lonaxis( - Axis::new() - .show_grid(true) - .grid_color(Rgb::new(102, 102, 102)), - ) - .projection( - Projection::new() - .projection_type(plotly::layout::ProjectionType::Orthographic) - .rotation(Rotation::new().lon(-100.0).lat(40.0)), - ), - ); - + let layout = Layout::new().drag_mode(DragMode::Zoom).geo( + LayoutGeo::new() + .showocean(true) + .showlakes(true) + .showcountries(true) + .showland(true) + .oceancolor(Rgb::new(0, 255, 255)) + .lakecolor(Rgb::new(0, 255, 255)) + .landcolor(Rgb::new(230, 145, 56)) + .lataxis( + Axis::new() + .show_grid(true) + .grid_color(Rgb::new(102, 102, 102)), + ) + .lonaxis( + Axis::new() + .show_grid(true) + .grid_color(Rgb::new(102, 102, 102)), + ) + .projection( + Projection::new() + .projection_type(plotly::layout::ProjectionType::Orthographic) + .rotation(Rotation::new().lon(-100.0).lat(40.0)), + ), + ); + + plot.set_configuration(Configuration::default().responsive(true).fill_frame(true)); plot.set_layout(layout); let path = write_example_to_html(&plot, file_name); @@ -140,19 +134,17 @@ fn scatter_geo(show: bool, file_name: &str) { fn density_mapbox(show: bool, file_name: &str) { let trace = DensityMapbox::new(vec![45.5017], vec![-73.5673], vec![0.75]).zauto(true); - let layout = Layout::new() - .drag_mode(DragMode::Zoom) - .margin(Margin::new().top(0).left(0).bottom(0).right(0)) - .mapbox( - Mapbox::new() - .style(MapboxStyle::OpenStreetMap) - .center(Center::new(45.5017, -73.5673)) - .zoom(5), - ); + let layout = Layout::new().drag_mode(DragMode::Zoom).mapbox( + Mapbox::new() + .style(MapboxStyle::OpenStreetMap) + .center(Center::new(45.5017, -73.5673)) + .zoom(5), + ); let mut plot = Plot::new(); plot.add_trace(trace); plot.set_layout(layout); + plot.set_configuration(Configuration::default().responsive(true).fill_frame(true)); let path = write_example_to_html(&plot, file_name); if show {