1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Break out plotting to own crate egui_plot (#3282)

This replaces `egui::plot` with the new crate `egui_plot`
This commit is contained in:
Emil Ernerfeldt
2023-08-27 17:22:49 +02:00
committed by GitHub
parent 87f12d782e
commit 7b169ec13d
30 changed files with 134 additions and 57 deletions

View File

@@ -23,8 +23,10 @@ all-features = true
default = []
chrono = ["egui_extras/datepicker", "dep:chrono"]
## Allow serialization using [`serde`](https://docs.rs/serde).
serde = ["egui/serde", "dep:serde"]
serde = ["egui/serde", "egui_plot/serde", "dep:serde"]
## Enable better syntax highlighting using [`syntect`](https://docs.rs/syntect).
syntax_highlighting = ["syntect"]
@@ -32,6 +34,7 @@ syntax_highlighting = ["syntect"]
[dependencies]
egui = { version = "0.22.0", path = "../egui", default-features = false }
egui_extras = { version = "0.22.0", path = "../egui_extras" }
egui_plot = { version = "0.22.0", path = "../egui_plot" }
enum-map = { version = "2", features = ["serde"] }
log = { version = "0.4", features = ["std"] }
unicode_names2 = { version = "0.6.0", default-features = false }

View File

@@ -122,7 +122,7 @@ impl super::View for ContextMenus {
impl ContextMenus {
fn example_plot(&self, ui: &mut egui::Ui) -> egui::Response {
use egui::plot::{Line, PlotPoints};
use egui_plot::{Line, PlotPoints};
let n = 128;
let line = Line::new(
(0..=n)
@@ -137,7 +137,7 @@ impl ContextMenus {
})
.collect::<PlotPoints>(),
);
egui::plot::Plot::new("example_plot")
egui_plot::Plot::new("example_plot")
.show_axes(self.show_axes)
.allow_drag(self.allow_drag)
.allow_zoom(self.allow_zoom)

View File

@@ -3,7 +3,7 @@ use std::ops::RangeInclusive;
use egui::*;
use egui::plot::{
use egui_plot::{
Arrows, AxisBools, AxisHints, Bar, BarChart, BoxElem, BoxPlot, BoxSpread, CoordinatesFormatter,
Corner, GridInput, GridMark, HLine, Legend, Line, LineStyle, MarkerShape, Plot, PlotImage,
PlotPoint, PlotPoints, PlotResponse, Points, Polygon, Text, VLine,
@@ -575,7 +575,7 @@ impl CustomAxesDemo {
.max_digits(4),
AxisHints::default()
.label("Absolute")
.placement(plot::HPlacement::Right),
.placement(egui_plot::HPlacement::Right),
];
Plot::new("custom_axes")
.data_aspect(2.0 * MINS_PER_DAY as f32)
@@ -636,7 +636,7 @@ impl LinkedAxesDemo {
))
}
fn configure_plot(plot_ui: &mut plot::PlotUi) {
fn configure_plot(plot_ui: &mut egui_plot::PlotUi) {
plot_ui.line(LinkedAxesDemo::line_with_slope(0.5));
plot_ui.line(LinkedAxesDemo::line_with_slope(1.0));
plot_ui.line(LinkedAxesDemo::line_with_slope(2.0));
@@ -671,7 +671,7 @@ impl LinkedAxesDemo {
.height(250.0)
.y_axis_width(3)
.y_axis_label("y")
.y_axis_position(plot::HPlacement::Right)
.y_axis_position(egui_plot::HPlacement::Right)
.link_axis(link_group_id, self.link_x, self.link_y)
.link_cursor(link_group_id, self.link_cursor_x, self.link_cursor_y)
.show(ui, LinkedAxesDemo::configure_plot);

View File

@@ -259,7 +259,7 @@ impl WidgetGallery {
}
fn example_plot(ui: &mut egui::Ui) -> egui::Response {
use egui::plot::{Line, PlotPoints};
use egui_plot::{Line, PlotPoints};
let n = 128;
let line_points: PlotPoints = (0..=n)
.map(|i| {
@@ -269,7 +269,7 @@ fn example_plot(ui: &mut egui::Ui) -> egui::Response {
})
.collect();
let line = Line::new(line_points);
egui::plot::Plot::new("example_plot")
egui_plot::Plot::new("example_plot")
.height(32.0)
.show_axes(false)
.data_aspect(1.0)