use charts::{Chart, HorizontalBarView, ScaleBand, ScaleLinear};
fn main() {
let width = 800;
let height = 600;
let (top, right, bottom, left) = (90, 40, 50, 60);
let x = ScaleLinear::new()
.set_domain(vec![0_f32, 100_f32])
.set_range(vec![0, width - left - right]);
let y = ScaleBand::new()
.set_domain(vec![String::from("A"), String::from("B"), String::from("C")])
.set_range(vec![0, height - top - bottom]);
let data = vec![("A", 90), ("B", 10), ("C", 30)];
let view = HorizontalBarView::new()
.set_x_scale(&x)
.set_y_scale(&y)
.load_data(&data).unwrap();
Chart::new()
.set_width(width)
.set_height(height)
.set_margins(top, right, bottom, left)
.add_title(String::from("Horizontal Bar Chart"))
.add_view(&view)
.add_axis_bottom(&x)
.add_axis_top(&x)
.add_axis_left(&y)
.add_left_axis_label("Y Axis Custom Label")
.add_bottom_axis_label("X Axis Custom Label")
.save("horizontal-bar-chart.svg").unwrap();
}