Gip-Gip / Gip-Gip/egui-plotter
AreaChart renderer bug
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 70
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
The area chart renderer creates unnecessary and wrong triangles.
use egui_plotter::Chart;
use eframe::egui::{self};
use plotters::prelude::*;
fn main() {
test_chart();
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(320.0, 240.0)),
..Default::default()
};
let _ = eframe::run_native("Test", options, Box::new(|_cc| Box::<App>::new(App::default())));
}
struct App {
chart: Chart
}
impl Default for App {
fn default() -> Self {
Self {
chart: create_chart()}
}
}
impl eframe::App for App {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
ctx.request_repaint();
egui::CentralPanel::default().show(ctx, |ui| {
self.chart.draw(ui);
});
}
}
fn create_chart() -> Chart {
Chart::new()
.builder_cb(Box::new(|area, _t, _| {
let mut chart = ChartBuilder::on(area)
.set_label_area_size(LabelAreaPosition::Left, 40)
.set_label_area_size(LabelAreaPosition::Bottom, 40)
.margin(5)
.build_cartesian_2d(0..10, 0..50)
.unwrap();
chart.configure_mesh().draw().unwrap();
let data = [25, 37, 15, 32, 45, 33, 32, 10, 29, 0, 21];
chart
.draw_series(
AreaSeries::new((0..).zip(data.iter().enumerate().map(|x| (*x.1 as i32))),
0, &RED.mix(0.2)).border_style(&RED)
)
.unwrap();
}))
}
pub fn test_chart() {
let root_area = BitMapBackend::new("image.png", (600, 400))
.into_drawing_area();
root_area.fill(&WHITE).unwrap();
let mut chart = ChartBuilder::on(&root_area)
.set_label_area_size(LabelAreaPosition::Left, 40)
.set_label_area_size(LabelAreaPosition::Bottom, 40)
.margin(5)
.build_cartesian_2d(0..10, 0..50)
.unwrap();
chart.configure_mesh().draw().unwrap();
let data = [25, 37, 15, 32, 45, 33, 32, 10, 29, 0, 21];
chart
.draw_series(
AreaSeries::new((0..).zip(data.iter().enumerate().map(|x| (*x.1 as i32))),
0, &RED.mix(0.2)).border_style(&RED)
)
.unwrap();
}
The output of egui-plotter is:
The output of plotters with the BitmapBackend is:
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Rust reproduction in the issue and compare the egui-plotter AreaSeries output with the BitmapBackend output from plotters. Trace the AreaChart renderer used by Chart::draw and verify that the rendered triangles match the reference image without the extra or incorrect shapes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100