[BUG] Stretched Area in Histogram
Describe the bug I have a simple histogram which plots some data in the wasm backend
fn draw(root_area: DrawingArea<CanvasBackend, Shift>, users: Vec<User>) -> Result<()> {
let max_subs = users
.iter()
.map(|u| u.quantity)
.fold(std::i64::MIN, |a, b| a.max(b));
let emails = users.iter().map(|x| x.email.to_owned()).collect::<Vec<_>>();
let mut ctx = ChartBuilder::on(&root_area)
// .set_label_area_size(LabelAreaPosition::Left, 40)
// .set_label_area_size(LabelAreaPosition::Bottom, 40)
.build_cartesian_2d(emails.into_segmented(), 0..max_subs)
.unwrap();
ctx.configure_mesh().draw().unwrap();
ctx.draw_series(
Histogram::vertical(&ctx)
.margin(100)
.data(users.iter().map(|x| (&x.email, x.quantity))),
)
.unwrap();
Ok(())
}
When this renders there is an area in the middle of the canvas that is stretched and warped. This appears to be a rendering bug
To Reproduce See code above
Version Information plotters = "0.3.5" plotters-canvas = "0.3.0"
I have found this only occurs when there are >20 bars to plot. It also occurs in the opposite way in Histogram::vertical
Could it be because you are using a very high value for margin (.margin(100))? 100 pixels seems too large to me. Maybe there should be some check for when the total margin in each direction is bigger than the rectangle size in that direction.