example graphique

This commit is contained in:
thatscringebro
2026-03-18 13:12:06 -04:00
parent 91f43092c3
commit a162118fce

View File

@@ -3,10 +3,11 @@ use ratatui::{
Frame, Frame,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style, palette::tailwind::SLATE}, style::{Color, Modifier, Style, palette::tailwind::SLATE},
symbols::Marker,
text::{Line, Span, Text}, text::{Line, Span, Text},
widgets::{ widgets::{
Block, Borders, Clear, HighlightSpacing, List, ListItem, Paragraph, Row, StatefulWidget, Axis, Block, Borders, Chart, Clear, Dataset, GraphType, HighlightSpacing, List, ListItem,
Table, Wrap, Paragraph, Row, StatefulWidget, Table, Wrap,
}, },
}; };
@@ -105,6 +106,44 @@ pub fn ui(frame: &mut Frame, app: &mut App) {
&mut app.trx_table.state, &mut app.trx_table.state,
); );
} else if app.selected_tab == 1 { } else if app.selected_tab == 1 {
let dataset = Dataset::default()
.name("Stonks")
.marker(Marker::Braille)
.graph_type(GraphType::Line)
.style(Color::Blue)
.data(&[
(0.0, 1.0),
(1.0, 3.0),
(2.0, 0.5),
(3.0, 2.0),
(4.0, 0.8),
(5.0, 4.0),
(6.0, 1.0),
(7.0, 6.0),
(8.0, 3.0),
(10.0, 10.0),
]);
let x_axis = Axis::default()
.title("Hustle")
.bounds([0.0, 10.0])
.labels(["0%", "50%", "100%"]);
let y_axis = Axis::default()
.title("Profit")
.bounds([0.0, 10.0])
.labels(["0", "5", "10"]);
let chart = Chart::new(vec![dataset])
.block(trx_block)
.x_axis(x_axis)
.y_axis(y_axis);
frame.render_widget(chart, right_layout[1]);
} else {
let p = Paragraph::new("Tab not implemented")
.block(trx_block)
.style(Style::default());
frame.render_widget(p, right_layout[1]);
} }
if let CurrentScreen::NewAccount = app.current_screen { if let CurrentScreen::NewAccount = app.current_screen {