refactor(chart): replace deprecated apply (#812)

Fixes #793
This commit is contained in:
Valentin271 2024-01-14 15:37:34 +01:00 committed by GitHub
parent 1746a61659
commit e0aa6c5e1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,
@ -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,