GithubHelp home page GithubHelp logo

egui-plotter's People

Contributors

bananaturtlesandwich avatar gip-gip avatar tomtuamnuq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

egui-plotter's Issues

Push axis label fix (#6) to crates.io

Hi, I'm running into an issue that looks a lot like the one shown in #5, where the value labels get placed incorrectly next to the axis ticks.

2023-08-15-174746

It seems to have been fixed here on Github, though (and indeed things look right if I use the code pulled directly from this repo), but the version up on crates.io appears not to have been updated yet.

Would you mind publishing the updated version?

Feathering

Does turning off the feathering turn it off for the entire GUI or just the plot ?

Embedding a plot inside a Window and trying to expand it produces the application to panic

I have the following piece of code:

egui::Window::new("Plot Window").open(&mut true).show(ctx, |ui| {
            let root = EguiBackend::new(ui).into_drawing_area();
            root.fill(&WHITE).unwrap();
            let mut chart = ChartBuilder::on(&root)
                .caption("y=x^2", ("sans-serif", 50).into_font())
                .margin(5)
                .x_label_area_size(30)
                .y_label_area_size(30)
                .build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)
                .unwrap();

            chart.configure_mesh().draw().unwrap();

            chart
                .draw_series(LineSeries::new(
                    (-50..=50).map(|x| x as f32 / 50.0).map(|x| (x, x * x)),
                    &RED,
                ))
                .unwrap()
                .label("y = x^2")
                .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &RED));

            chart
                .configure_series_labels()
                .background_style(&WHITE.mix(0.8))
                .border_style(&BLACK)
                .draw()
                .unwrap();

            root.present().unwrap();
        });

And the first issue is that the plot expands the size of the window as you can see here:

image

The second issue is that, when you try to expand the window the application panics with the following message:

thread 'main' panicked at /Users/jimenj13/.cargo/registry/src/index.crates.io-6f17d22bba15001f/epaint-0.27.2/src/text/font.rs:92:9:
assertion failed: scale_in_pixels > 0.0
stack backtrace:
   0:        0x10177336c - std::backtrace_rs::backtrace::libunwind::trace::hdc7d2d82dacc83e6
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:        0x10177336c - std::backtrace_rs::backtrace::trace_unsynchronized::h11fcbf27db856d40
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x10177336c - std::sys_common::backtrace::_print_fmt::h117e5fb45bd92414
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/sys_common/backtrace.rs:68:5
   3:        0x10177336c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd4e6df6dd376d525
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x101792dc8 - core::fmt::rt::Argument::fmt::h4f724c1ed2e34985
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/fmt/rt.rs:142:9
   5:        0x101792dc8 - core::fmt::write::h5a442bf928ef18fb
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/fmt/mod.rs:1120:17
   6:        0x101770620 - std::io::Write::write_fmt::h01fe6f9cc882fac7
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/io/mod.rs:1846:15
   7:        0x1017731a0 - std::sys_common::backtrace::_print::h15d065176d59d5e1
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x1017731a0 - std::sys_common::backtrace::print::h249c7fd853efd630
                               at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/sys_common/backtrace.rs:34:9

Am I doing something wrong (or forgetting something)? Or is this an open issue?

Allow disabling transformations mid callback

Currently the basic dragging/zooming works ok for graphs, but in order to make it actually useful it would be nice to allow users to toggle during the callback what is and isn't transformed by dragging and zooming, allowing people to disable transforming for the grid/tic marks and enable it for the plot points.

This will likely result in some breaking changes.

Pre-built charts as feature flag

Pre-built charts likely won't be used by everyone and not all currently work with WASM due to dependence on std::time.

Charts should be their own feature and also allow for compatibility with WASM.

Dependency mismatch between example and Cargo.toml

Description

The code in the examples/ directory is unable to compile due to a mismatch between the dependencies specified in the Cargo.toml file and the versions of the dependencies used in the example code.

Steps to Reproduce

  1. Review the Cargo.toml file, which shows the following dependency versions:
[dependencies]
egui = "0.25.0"
eframe = "0.25.0"
plotters-backend = "0.3"
plotters = "0.3"
egui-plotter = "0.3.0"
  1. Run the example code located in the examples/ directory.
  2. Observe the following error message:
    (This is the case for examples/simple.rs)
error[E0308]: mismatched types
   --> src/main.rs:36:41
    |
36  |             let root = EguiBackend::new(ui).into_drawing_area();
    |                        ---------------- ^^ expected `&Ui`, found `&mut Ui`
    |                        |
    |                        arguments to this function are incorrect
    |
    = note: `Ui` and `egui::ui::Ui` have similar names, but are actually distinct types
note: `Ui` is defined in crate `egui`
   --> /home/<user>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.25.0/src/ui.rs:31:1
    |
31  | pub struct Ui {
    | ^^^^^^^^^^^^^
note: `egui::ui::Ui` is defined in crate `egui`
   --> /home/<user>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.22.0/src/ui.rs:31:1
    |
31  | pub struct Ui {
    | ^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `egui` are being used?
note: associated function defined here
   --> /home/<user>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-plotter-0.3.0/src/backend.rs:200:12
    |
200 |     pub fn new(ui: &'a Ui) -> Self {
    |            ^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `metaheuristics` (bin "metaheuristics") due to 1 previous error

Expected Behavior

The example code should compile and run without any issues, using the dependency versions specified in the Cargo.toml file.

Actual Behavior

The example code fails to compile due to a mismatch between the dependency versions used in the code and the versions specified in the Cargo.toml file.

Proposed Solution

  1. Update the Cargo.toml file to use the same versions of the egui and eframe dependencies as the example code:
[dependencies]
egui = "0.22.0"  # <-- "0.25.0"
eframe = "0.22.0"  # <-- "0.25.0"
plotters-backend = "0.3"
plotters = "0.3"
egui-plotter = "0.3.0"
  1. Rebuild the project and run the example code again.

This should resolve the compilation issue and allow the example code to run successfully.

AreaChart renderer bug

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:
screenshot
The output of plotters with the BitmapBackend is:
image

axis labels don't display properly

Hello! Thank you for the crate, it came around at a great time and is wonderful to work with
Unfortunately though I did find an issue with axis labels in that the y-axis label is not rotated and the x isn't there (?)
I'll try to have a look myself but I'll put this here if I don't know

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.