Skip to content

Commit

Permalink
removed the constant factor of panel relation to remove text when seg…
Browse files Browse the repository at this point in the history
…ment gets too small
  • Loading branch information
Joelle Hohwiller authored and CallMeElle committed Apr 18, 2024
1 parent 4ac787f commit 02cd3e8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tools/twix/src/panels/enum_plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,8 @@ impl EnumPlotPanel {
fn plot_segment(plot_ui: &mut PlotUi, segment: &Segment, plot_bounds: &PlotBounds) {
const VERTICAL_MARGIN: f64 = 0.05;
const BORDER_WIDTH: f32 = 2.0;
const MIN_SEGMENT_RELATION_FOR_TEXT: f64 = 1.0 / 18.0;

let viewport_left_edge = plot_bounds.min()[0];
let viewport_right_edge = plot_bounds.max()[0];
let min_boxsize_text = viewport_right_edge - viewport_left_edge;

let name = segment.name();
let color = color_hash(&name);
Expand All @@ -153,12 +150,11 @@ impl EnumPlotPanel {
.stroke(Stroke::new(BORDER_WIDTH, color)),
);

let mut text_x = start + 0.05;
if viewport_left_edge > text_x
&& end > (viewport_left_edge + (min_boxsize_text * MIN_SEGMENT_RELATION_FOR_TEXT))
{
text_x = viewport_left_edge + 0.05;
}
let text_x = if start < viewport_left_edge && viewport_left_edge < end {
viewport_left_edge + 0.05
} else {
start + 0.05
};

plot_ui.text(
Text::new(PlotPoint { x: text_x, y: 0.9 }, name)
Expand Down

0 comments on commit 02cd3e8

Please sign in to comment.