Skip to content

Commit b659c90

Browse files
committed
Added a copy of scatter_mapbox.rs and repurposed for scatter_geo, working on making it actually work
1 parent d6326fc commit b659c90

File tree

5 files changed

+438
-1
lines changed

5 files changed

+438
-1
lines changed

plotly/src/common/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ pub enum PlotType {
215215
ScatterGL,
216216
Scatter3D,
217217
ScatterMapbox,
218+
ScatterGeo,
218219
ScatterPolar,
219220
ScatterPolarGL,
220221
Bar,
@@ -1750,6 +1751,7 @@ mod tests {
17501751
assert_eq!(to_value(PlotType::Scatter).unwrap(), json!("scatter"));
17511752
assert_eq!(to_value(PlotType::ScatterGL).unwrap(), json!("scattergl"));
17521753
assert_eq!(to_value(PlotType::Scatter3D).unwrap(), json!("scatter3d"));
1754+
assert_eq!(to_value(PlotType::ScatterGeo).unwrap(), json!("scattergeo"));
17531755
assert_eq!(to_value(PlotType::ScatterPolar).unwrap(), json!("scatterpolar"));
17541756
assert_eq!(to_value(PlotType::ScatterPolarGL).unwrap(), json!("scatterpolargl"));
17551757
assert_eq!(to_value(PlotType::Bar).unwrap(), json!("bar"));

plotly/src/layout/mod.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,57 @@ impl Mapbox {
14531453
}
14541454
}
14551455

1456+
#[derive(Serialize, Clone, Debug)]
1457+
#[serde(rename_all = "kebab-case")]
1458+
pub enum MapboxStyle {
1459+
#[serde(rename = "carto-darkmatter")]
1460+
CartoDarkMatter,
1461+
CartoPositron,
1462+
OpenStreetMap,
1463+
StamenTerrain,
1464+
StamenToner,
1465+
StamenWatercolor,
1466+
WhiteBg,
1467+
Basic,
1468+
Streets,
1469+
Outdoors,
1470+
Light,
1471+
Dark,
1472+
Satellite,
1473+
SatelliteStreets,
1474+
}
1475+
1476+
#[derive(Serialize, Clone, Debug, FieldSetter)]
1477+
pub struct Geo {
1478+
/// Sets the geo access token to be used for this geo map. Note that
1479+
/// `access_token`s are only required when `style` (e.g with values: basic,
1480+
/// streets, outdoors, light, dark, satellite, satellite-streets)
1481+
/// and/or a layout layer references the Mapbox server.
1482+
#[serde(rename = "accesstoken")]
1483+
access_token: Option<String>,
1484+
/// Sets the bearing angle of the map in degrees counter-clockwise from
1485+
/// North.
1486+
bearing: Option<f64>,
1487+
/// Sets the latitude and longitude of the center of the map.
1488+
center: Option<Center>,
1489+
/// Sets the domain within which the mapbox will be drawn.
1490+
domain: Option<Domain>,
1491+
/// Sets the pitch angle of the map in degrees, where `0` means
1492+
/// perpendicular to the surface of the map.
1493+
pitch: Option<f64>,
1494+
/// Sets the style of the map.
1495+
style: Option<MapboxStyle>,
1496+
/// Sets the zoom level of the map.
1497+
zoom: Option<u8>,
1498+
}
1499+
1500+
impl Geo {
1501+
pub fn new() -> Self {
1502+
Default::default()
1503+
}
1504+
}
1505+
1506+
14561507
#[derive(Serialize, Debug, Clone)]
14571508
/// If "cube", this scene's axes are drawn as a cube, regardless of the axes'
14581509
/// ranges. If "data", this scene's axes are drawn in proportion with the axes'

plotly/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub use traces::{
4040
// Bring the different trace types into the top-level scope
4141
pub use traces::{
4242
Bar, BoxPlot, Candlestick, Contour, DensityMapbox, HeatMap, Histogram, Image, Mesh3D, Ohlc,
43-
Pie, Sankey, Scatter, Scatter3D, ScatterMapbox, ScatterPolar, Surface, Table,
43+
Pie, Sankey, Scatter, Scatter3D, ScatterMapbox, ScatterGeo, ScatterPolar, Surface, Table,
4444
};
4545

4646
pub trait Restyle: serde::Serialize {}

plotly/src/traces/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub mod sankey;
1515
pub mod scatter;
1616
pub mod scatter3d;
1717
pub mod scatter_mapbox;
18+
pub mod scatter_geo;
1819
mod scatter_polar;
1920
pub mod surface;
2021
pub mod table;
@@ -33,6 +34,7 @@ pub use sankey::Sankey;
3334
pub use scatter::Scatter;
3435
pub use scatter3d::Scatter3D;
3536
pub use scatter_mapbox::ScatterMapbox;
37+
pub use scatter_geo::ScatterGeo;
3638
pub use scatter_polar::ScatterPolar;
3739
pub use surface::Surface;
3840
pub use table::Table;

0 commit comments

Comments
 (0)