Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f5a7957

Browse files
feat(layout): add LayoutPolar
1 parent 6a51920 commit f5a7957

File tree

3 files changed

+654
-1
lines changed

3 files changed

+654
-1
lines changed

‎examples/basic_charts/src/main.rs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,29 @@ fn polar_scatter_plot(show: bool, file_name: &str) {
119119
let mut plot = Plot::new();
120120
plot.add_trace(trace);
121121

122+
let ticks = PolarAxisTicks::new().tick_color("#222222");
123+
124+
let axis_attributes = PolarAxisAttributes::new()
125+
.grid_color("#888888")
126+
.ticks(ticks);
127+
128+
let radial_axis = RadialAxis::new()
129+
.title("My Title")
130+
.axis_attributes(axis_attributes.clone());
131+
132+
let angular_axis = AngularAxis::new()
133+
.direction(PolarDirection::Clockwise)
134+
.rotation(45.0)
135+
.axis_attributes(axis_attributes);
136+
137+
let layout_polar = LayoutPolar::new()
138+
.bg_color("#eeeeee")
139+
.radial_axis(radial_axis)
140+
.angular_axis(angular_axis);
141+
142+
let layout = Layout::new().polar(layout_polar);
143+
plot.set_layout(layout);
144+
122145
let path = write_example_to_html(&plot, file_name);
123146
if show {
124147
plot.show_html(path);

‎plotly/src/layout/mod.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod grid;
1919
mod legend;
2020
mod mapbox;
2121
mod modes;
22+
mod polar;
2223
mod rangebreaks;
2324
mod scene;
2425
mod shape;
@@ -42,6 +43,7 @@ pub use self::mapbox::{Center, Mapbox, MapboxStyle};
4243
pub use self::modes::{
4344
AspectMode, BarMode, BarNorm, BoxMode, ClickMode, UniformTextMode, ViolinMode, WaterfallMode,
4445
};
46+
pub use self::polar::LayoutPolar;
4547
pub use self::rangebreaks::RangeBreak;
4648
pub use self::scene::{
4749
AspectRatio, Camera, CameraCenter, DragMode, DragMode3D, Eye, HoverMode, LayoutScene,
@@ -330,7 +332,7 @@ pub struct LayoutFields {
330332
// ternary: Option<LayoutTernary>,
331333
scene: Option<LayoutScene>,
332334
geo: Option<LayoutGeo>,
333-
// polar: Option<LayoutPolar>,
335+
polar: Option<LayoutPolar>,
334336
annotations: Option<Vec<Annotation>>,
335337
shapes: Option<Vec<Shape>>,
336338
#[serde(rename = "newshape")]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /