-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Span::column() with the Style::modern() causes virtual artifact on the intersection in the table #399
Comments
Hi @fbonin That's actually by design. Try to use Let me know if it helped. Yes I've just noticed it's not stated in Take care |
Thank you ! |
Just a heads up, use tabled::{
settings::{
style::{BorderSpanCorrection, Style},
Modify, Span,
},
Table,
};
fn main() {
let data = vec![("09", "June", "2022"), ("10", "July", "2022")];
let mut table = Table::new(&data);
table
.with(Modify::new((0, 0)).with("date").with(Span::column(3)))
.with(BorderSpanCorrection);
println!("{}", table.to_string());
table.with(Style::modern());
println!("{}", table.to_string());
}
|
Hi @mkatychev Good observation, So essentially you could call it one more time to fix it. Yesssssssssss, You can help to update the doc yourself if you want to. Let me know if that helps, and use tabled::{
settings::{
style::{BorderSpanCorrection, Style},
Modify, Span,
},
Table,
};
fn main() {
let data = vec![("09", "June", "2022"), ("10", "July", "2022")];
let mut table = Table::new(data);
table
.with(Modify::new((0, 0)).with("date").with(Span::column(3)))
.with(Style::modern());
println!("{table}");
table.with(BorderSpanCorrection);
println!("{table}");
}
PS: Once again a good observation. |
Note Could be done with use tabled::{
settings::{
object::Rows,
style::{BorderSpanCorrection, Style},
Disable, Panel,
},
Table,
};
fn main() {
let data = vec![("09", "June", "2022"), ("10", "July", "2022")];
let mut table = Table::new(data);
table
.with(Disable::row(Rows::first()))
.with(Panel::header("date"))
.with(Style::modern());
println!("{table}");
table.with(BorderSpanCorrection);
println!("{table}");
} |
Or like this without use std::iter::FromIterator;
use tabled::{
settings::{
style::{BorderSpanCorrection, Style},
Panel,
},
Table,
};
fn main() {
let data = vec![["09", "June", "2022"], ["10", "July", "2022"]];
let mut table = Table::from_iter(data);
table.with(Panel::header("date")).with(Style::modern());
println!("{table}");
table.with(BorderSpanCorrection);
println!("{table}");
} |
I can confirm the first approach worked flawlessly with 3 or more columns, thanks @zhiburt. |
@zhiburt , it seems that I found a similar issue with use tabled::{
builder::Builder,
settings::{
object::Cell,
style::{BorderSpanCorrection, HorizontalLine},
Alignment, Modify, Span, Style, Theme,
},
};
type TableRecord<'s> = [&'s str; 7];
const LABEL: &str = "label";
const TRAINING: &str = "training data";
const TESTING: &str = "test data";
const CORRECT: &str = "✓";
const TOTAL: &str = "#";
const PERCENT: &str = "%";
const HEADERS: TableRecord<'static> = ["", CORRECT, TOTAL, PERCENT, CORRECT, TOTAL, PERCENT];
fn main() {
let mut builder = Builder::default();
builder.push_record([""]);
builder.push_record(HEADERS);
builder.push_record(["Hufflepuff", "346", "348", "99.43%", "179", "181", "98.90%"]);
builder.push_record(["Gryffindor", "210", "215", "97.67%", "108", "112", "96.43%"]);
builder.push_record(["Ravenclaw", "304", "308", "98.70%", "131", "135", "97.04%"]);
builder.push_record(["Slytherin", "190", "194", "97.94%", "103", "107", "96.26%"]);
let mut table = builder.build();
let mut theme = Theme::from_style(Style::rounded());
theme.remove_horizontal_lines();
theme.insert_horizontal_line(1, HorizontalLine::inherit(Style::modern()));
theme.insert_horizontal_line(2, HorizontalLine::inherit(Style::modern()));
table
.with(
Modify::new(Cell::new(0, 0))
.with(Span::row(2))
.with(Alignment::center_vertical())
.with(LABEL),
)
.with(
Modify::new(Cell::new(0, 1))
.with(Span::column(3))
.with(TRAINING),
)
.with(
Modify::new(Cell::new(0, 4))
.with(Span::column(3))
.with(TESTING),
)
.with(theme)
.with(Alignment::center_vertical())
.with(Alignment::center())
.with(BorderSpanCorrection);
println!("{table}");
} gives:
expected:
fyi,
also, if I add color on example: .with(BorderColor::filled(Color::new("\u{1b}[2;35m", "\u{1b}[0m")))
if it's not a bug, would love to know where I made mistakes and don't hesitate to point out other elements that I did not do optimally |
Using Span::column() with the Style::modern() causes virtual artifact on the intersection in the table
To reproduce :
Artifacts on the header at the intersection :
Expected :
The text was updated successfully, but these errors were encountered: