default_x_bounds does not set "reset" bounds
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- rust
調査の方向性
まず Plot.default_x_bounds と Plot.default_y_bounds の実装とドキュメントを読み、次にプロットが初期境界とダブルクリックによるリセット動作をどのように処理しているかを追跡します。提供されている円の例を egui_plot 0.32.1 で再現し、インタラクティブな移動とリセット動作を比較します。ユーザーが指定した境界を引き続き使用でき、ダブルクリックで復元されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
egui_plot 0.32.1
I'm trying to accomplish the following behavior:
- Set my own X/Y bounds for a plot. Ignore contained data for bounds.
- Allow user to move/zoom/... the plot
- On double-click, make the plot go back to my own X/Y bounds
This seems like a reasonable behavior to me.
Judging by the comment, Plot.default_x_bounds seem to do exactly that, as the comment states that it /// Overwrite the starting and reset bounds used for the x axis. However, in practice,
1. If I do a simple
Plot::new("circle_plot")
.default_x_bounds(-0.5, 0.5)
.default_y_bounds(-0.3, 0.3)
.show(ui, |plot_ui| {
plot_ui.line(Line::new("circle", PlotPoints::Owned(points)));
});
the user can't control the plot, the bounds always come back to the defaults
2. If I set bounds only once on start
it works better, but double-clicking does NOT reset the plot to my bounds (as suggested by the comment "Overwrite the starting and reset bounds used for the x axis"), but in such a way as to contain all the data.
let plot = Plot::new("circle_plot");
let plot = if self.first_time {
plot.default_x_bounds(-0.5, 0.5).default_y_bounds(-0.3, 0.3)
} else {
plot
};
plot.show(ui, |plot_ui| {
plot_ui.line(Line::new("circle", PlotPoints::Owned(points)).width(3.));
});
I want double-click to reset to my bounds. How can I achieve my objective?
The whole example:
use eframe::egui;
use egui_plot::{Line, Plot, PlotPoint, PlotPoints};
struct MyApp {
first_time: bool,
}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
let points: Vec<PlotPoint> = (0..100).map(|i| {
let angle = (i as f64) * std::f64::consts::TAU / 100.0;
PlotPoint { x: angle.cos(), y: angle.sin() }
}).collect();
let plot = Plot::new("circle_plot");
let plot = if self.first_time {
plot.default_x_bounds(-0.5, 0.5).default_y_bounds(-0.3, 0.3)
} else {
plot
};
plot.show(ui, |plot_ui| {
plot_ui.line(Line::new("circle", PlotPoints::Owned(points)).width(3.));
});
});
self.first_time = false;
}
}
fn main() {
let native_options = eframe::NativeOptions::default();
let _ = eframe::run_native(
"My XY Circle Plot",
native_options,
Box::new(|_cc| Ok(Box::new(MyApp { first_time: true }))),
);
}
- 主要言語
- Rust
- スター
- 494
- フォーク
- 110
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
emilk/egui_plot のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 66/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
emilk/egui_plot の issue をすべて見る
似ている issue
-
chat compiler P1
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
HerringtonDarkholme/hd-lang#2793 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
security-advisory
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MinBZK/regelrecht#2173 ·
-
ci
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
jonathanong/no-mistakes#5804 ·
-
triage: failed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
oxc-project/tsrs#1277 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信