Skip to content

Commit

Permalink
feat(widgets/chart): add option to set the position of legend
Browse files Browse the repository at this point in the history
- update rendering algorithm to avoid collisiion with axis titles.
- add unit tests.
  • Loading branch information
lyuha committed Dec 13, 2023
1 parent aaeba27 commit d2b36ac
Show file tree
Hide file tree
Showing 3 changed files with 473 additions and 40 deletions.
3 changes: 2 additions & 1 deletion examples/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ fn ui(f: &mut Frame, app: &App) {
.style(Style::default().fg(Color::Gray))
.bounds([0.0, 5.0])
.labels(vec!["0".bold(), "2.5".into(), "5".bold()]),
);
)
.legend_position(Some(LegendPosition::TopLeft));
f.render_widget(chart, chunks[2]);
}
2 changes: 1 addition & 1 deletion src/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use bitflags::bitflags;
pub use self::{
barchart::{Bar, BarChart, BarGroup},
block::{Block, BorderType, Padding},
chart::{Axis, Chart, Dataset, GraphType},
chart::{Axis, Chart, Dataset, GraphType, LegendPosition},
clear::Clear,
gauge::{Gauge, LineGauge},
list::{List, ListDirection, ListItem, ListState},
Expand Down

0 comments on commit d2b36ac

Please sign in to comment.