-
Notifications
You must be signed in to change notification settings - Fork 73
/
two_value_axes_in_polar.rs
35 lines (33 loc) · 1.14 KB
/
two_value_axes_in_polar.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use charming::{
component::{AngleAxis, Legend, PolarCoordinate, RadiusAxis, Title},
element::{AxisPointer, AxisPointerType, AxisType, CoordinateSystem, Tooltip, Trigger},
series::Line,
Chart,
};
pub fn chart() -> Chart {
let data = (0..=360)
.map(|i| {
let t = i as f64 / 180.0 * std::f64::consts::PI;
let r = (2.0 * t).sin() * (2.0 * t).cos();
vec![r, i as f64]
})
.collect::<Vec<_>>();
Chart::new()
.title(Title::new().text("Two Value-Axes in Polar"))
.legend(Legend::new().data(vec!["line"]))
.polar(PolarCoordinate::new().center(vec!["50%", "54%"]))
.tooltip(
Tooltip::new()
.trigger(Trigger::Axis)
.axis_pointer(AxisPointer::new().type_(AxisPointerType::Cross)),
)
.angle_axis(AngleAxis::new().type_(AxisType::Value).start_angle(0))
.radius_axis(RadiusAxis::new().min(0))
.series(
Line::new()
.name("line")
.coordinate_system(CoordinateSystem::Polar)
.show_symbol(false)
.data(data),
)
}