Skip to content

Commit

Permalink
refactor(chart): replace deprecated apply (#812)
Browse files Browse the repository at this point in the history
Fixes #793
  • Loading branch information
Valentin271 authored Jan 14, 2024
1 parent 1746a61 commit e0aa6c5
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/widgets/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use unicode_width::UnicodeWidthStr;

use crate::{
buffer::Buffer,
layout::{Alignment, Constraint, Rect},
style::{Color, Style, Styled},
layout::Flex,
prelude::*,
symbols,
text::{Line, Span},
widgets::{
canvas::{Canvas, Line as CanvasLine, Points},
Block, Borders, Widget,
Expand Down Expand Up @@ -745,19 +744,17 @@ impl<'a> Chart<'a> {
if let Some(inner_width) = legends.clone().max() {
let legend_width = inner_width + 2;
let legend_height = legends.count() as u16 + 2;
#[allow(deprecated)]
let max_legend_width = self
.hidden_legend_constraints
.0
.apply(layout.graph_area.width);
#[allow(deprecated)]
let max_legend_height = self
.hidden_legend_constraints
.1
.apply(layout.graph_area.height);

let [max_legend_width] = layout.graph_area.split(
&Layout::horizontal([self.hidden_legend_constraints.0]).flex(Flex::Start),
);
let [max_legend_height] = layout
.graph_area
.split(&Layout::vertical([self.hidden_legend_constraints.1]).flex(Flex::Start));

if inner_width > 0
&& legend_width <= max_legend_width
&& legend_height <= max_legend_height
&& legend_width <= max_legend_width.width
&& legend_height <= max_legend_height.height
{
layout.legend_area = legend_position.layout(
layout.graph_area,
Expand Down

0 comments on commit e0aa6c5

Please sign in to comment.