You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to get one of the basic chart examples to work with the BitmapBackend::with_buffer function. The exact same code works well when I am exporting a file (an unaltered example from this repo). But if I change it to output to a buffer, I can't seem to find the data. The buffer is just an empty array of zero values. How can I access and manipulate the buffer? I have also tried the following with root_area and it also doesn't have any data.
fn main() {
let mut buffer_ = vec![0; 300 * 200 * 3];
let a = || {
root_area = BitMapBackend::with_buffer(&mut buffer_, (600, 400))
.into_drawing_area();
root_area.fill(&WHITE).unwrap();
let mut ctx = ChartBuilder::on(&root_area)
.set_label_area_size(LabelAreaPosition::Left, 40)
.set_label_area_size(LabelAreaPosition::Bottom, 40)
.caption("Bar Demo", ("sans-serif", 40))
.build_cartesian_2d(0..50, (0..10).into_segmented())
.unwrap();
ctx.configure_mesh().draw().unwrap();
let data = [25, 37, 15, 32, 45, 33, 32, 10, 0, 21, 5];
ctx.draw_series((0..).zip(data.iter()).map(|(y, x)| {
let mut bar = Rectangle::new([
(0, SegmentValue::Exact(y)),
(*x, SegmentValue::Exact(y + 1))
], BLUE.filled());
bar.set_margin(5, 5, 0, 0);
bar
})).unwrap();
};
println!("{:?}", &buffer_);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am attempting to get one of the basic chart examples to work with the BitmapBackend::with_buffer function. The exact same code works well when I am exporting a file (an unaltered example from this repo). But if I change it to output to a buffer, I can't seem to find the data. The buffer is just an empty array of zero values. How can I access and manipulate the buffer? I have also tried the following with root_area and it also doesn't have any data.
fn main() {
Beta Was this translation helpful? Give feedback.
All reactions