Open nathanrboyer opened 8 months ago
My use case is to add footnotes to a table:
julia> ASME_Materials.tableKM620_options()
╭──── Table KM-620 Material Categories ───────────────────────────────────╮
│ ╭────────────┬──────────────────────────────────────────────────────╮ │
│ │ Category │ Material │ │
│ ├────────────┼──────────────────────────────────────────────────────┤ │
│ │ 1 │ Ferritic steel │ │
│ ├────────────┼──────────────────────────────────────────────────────┤ │
│ │ 2 │ Austenitic stainless steel and nickel-based alloys │ │
│ ├────────────┼──────────────────────────────────────────────────────┤ │
│ │ 3 │ Duplex stainless steel │ │
│ ├────────────┼──────────────────────────────────────────────────────┤ │
│ │ 4 │ Precipitation hardening, nickel based │ │
│ ├────────────┼──────────────────────────────────────────────────────┤ │
│ │ 5 │ Aluminum │ │
│ ├────────────┼──────────────────────────────────────────────────────┤ │
│ │ 6 │ Copper │ │
│ ├────────────┼──────────────────────────────────────────────────────┤ │
│ │ 7 │ Titanium and zirconium │ │
│ ╰────────────┴──────────────────────────────────────────────────────╯ │
│ ╭──── Note: ────────────────────────────────────────────────────────╮ │
│ │ (1) Ferritic steel includes carbon, low alloy, and alloy │ │
│ │ steels, and ferritic, martensitic, and iron-based age-hardenin │ │
│ │ g stainless steels. │ │
│ ╰───────────────────────────────────────────────────────────────────╯ │
╰─────────────────────────────────────────────────────────────────────────╯
function tableKM620_options()
table = select(KM620.coefficients_table, "Material")
notes = join(values(metadata(KM620.coefficients_table)), "\n")
panel = @nested_panels Panel(
Term.Table(
hcat(1:nrow(table), table."Material"),
header = ["Category", "Material"],
header_style = "cyan",
columns_justify = [:center, :left],
columns_style = "default",
box = :ROUNDED,
style = "cyan",
),
Panel(
@style(notes, "cyan dim"),
style = "cyan dim",
title = "Note:",
title_style = "cyan dim",
),
title = "Table KM-620 Material Categories",
title_style = "cyan",
style = "cyan",
)
return panel
end
I cannot get it to look nice without the Panel
:
julia> ASME_Materials.tableKM620_options2()
╭──── Table KM-620 Material Categories ───────────────────────────────────╮
│ ╭────────────┬────────────────────────────────────────────────────── │
│ ╮ │
│ │ Category │ Material │
│ │ │
│ ├────────────┼────────────────────────────────────────────────────── │
│ ┤ │
│ │ 1 │ Ferritic steel │
│ │ │
│ ├────────────┼────────────────────────────────────────────────────── │
│ ┤ │
│ │ 2 │ Austenitic stainless steel and nickel-based alloys │
│ │ │
│ ├────────────┼────────────────────────────────────────────────────── │
│ ┤ │
│ │ 3 │ Duplex stainless steel │
│ │ │
│ ├────────────┼────────────────────────────────────────────────────── │
│ ┤ │
│ │ 4 │ Precipitation hardening, nickel based │
│ │ │
│ ├────────────┼────────────────────────────────────────────────────── │
│ ┤ │
│ │ 5 │ Aluminum │
│ │ │
│ ├────────────┼────────────────────────────────────────────────────── │
│ ┤ │
│ │ 6 │ Copper │
│ │ │
│ ├────────────┼────────────────────────────────────────────────────── │
│ ┤ │
│ │ 7 │ Titanium and zirconium │
│ │ │
│ ╰────────────┴────────────────────────────────────────────────────── │
│ ╯ │
│ │
│ │
│ Notes: │
│ │
│ (1) Ferritic steel includes carbon, low alloy, and alloy steels, │
│ │
│ and ferritic, martensitic, and iron-based age-hardening stainless │
│ │
│ steels. │
│ │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────╯
function tableKM620_options2()
table = select(KM620.coefficients_table, "Material")
notes = "Notes:\n" * join(values(metadata(KM620.coefficients_table)), "\n")
panel = @nested_panels Panel(
Term.Table(
hcat(1:nrow(table), table."Material"),
header = ["Category", "Material"],
header_style = "cyan",
columns_justify = [:center, :left],
columns_style = "default",
box = :ROUNDED,
style = "cyan",
),
TextBox(
@style(notes, "cyan dim"),
),
title = "Table KM-620 Material Categories",
title_style = "cyan",
style = "cyan",
)
return panel
end
(Also in the last example, the styling is only applied to the first line of the TextBox
.)
Hi,
Thanks for reaching out. Unfortunately at the moment I don’t have the bandwidth to keep development work for Term.jl though. I’d you’d like to send a PR though I can review and approve that. I hope this helps.
Sent from Proton Mail for iOS
On Thu, Feb 15, 2024 at 15:39, Nathan Boyer @.***(mailto:On Thu, Feb 15, 2024 at 15:39, Nathan Boyer < wrote:
My use case is to add footnotes to a table:
julia
ASME_Materials
.
tableKM620_options
() ╭──── Table KM
-
620
Material Categories ───────────────────────────────────╮ │ ╭────────────┬──────────────────────────────────────────────────────╮ │ │ │ Category │ Material │ │ │ ├────────────┼──────────────────────────────────────────────────────┤ │ │ │
1
│ Ferritic steel │ │ │ ├────────────┼──────────────────────────────────────────────────────┤ │ │ │
2
│ Austenitic stainless steel and nickel
-
based alloys │ │ │ ├────────────┼──────────────────────────────────────────────────────┤ │ │ │
3
│ Duplex stainless steel │ │ │ ├────────────┼──────────────────────────────────────────────────────┤ │ │ │
4
│ Precipitation hardening, nickel based │ │ │ ├────────────┼──────────────────────────────────────────────────────┤ │ │ │
5
│ Aluminum │ │ │ ├────────────┼──────────────────────────────────────────────────────┤ │ │ │
6
│ Copper │ │ │ ├────────────┼──────────────────────────────────────────────────────┤ │ │ │
7
│ Titanium and zirconium │ │ │ ╰────────────┴──────────────────────────────────────────────────────╯ │ │ ╭──── Note
:
────────────────────────────────────────────────────────╮ │ │ │ (
1
) Ferritic steel includes carbon, low alloy, and alloy │ │ │ │ steels, and ferritic, martensitic, and iron
-
based age
-
hardenin │ │ │ │ g stainless steels. │ │ │ ╰───────────────────────────────────────────────────────────────────╯ │ ╰─────────────────────────────────────────────────────────────────────────╯
function
tableKM620_options
() table
=
select
(KM620
.
coefficients_table,
"
Material
"
) notes
=
join
(
values
(
metadata
(KM620
.
coefficients_table)),
"
\n
"
) panel
=
@nested_panels
Panel
( Term
.
Table
(
hcat
(
1
:
nrow
(table), table.
"
Material
"
), header
=
[
"
Category
"
,
"
Material
"
], header_style
=
"
cyan
"
, columns_justify
=
[
:center
,
:left
], columns_style
=
"
default
"
, box
=
:ROUNDED
, style
=
"
cyan
"
, ),
Panel
(
@style
(notes,
"
cyan dim
"
), style
=
"
cyan dim
"
, title
=
"
Note:
"
, title_style
=
"
cyan dim
"
, ), title
=
"
Table KM-620 Material Categories
"
, title_style
=
"
cyan
"
, style
=
"
cyan
"
, )
return
panel
end
I cannot get it to look nice without the Panel:
julia
ASME_Materials
.
tableKM620_options2
() ╭──── Table KM
-
620
Material Categories ───────────────────────────────────╮ │ ╭────────────┬────────────────────────────────────────────────────── │ │ ╮ │ │ │ Category │ Material │ │ │ │ │ ├────────────┼────────────────────────────────────────────────────── │ │ ┤ │ │ │
1
│ Ferritic steel │ │ │ │ │ ├────────────┼────────────────────────────────────────────────────── │ │ ┤ │ │ │
2
│ Austenitic stainless steel and nickel
-
based alloys │ │ │ │ │ ├────────────┼────────────────────────────────────────────────────── │ │ ┤ │ │ │
3
│ Duplex stainless steel │ │ │ │ │ ├────────────┼────────────────────────────────────────────────────── │ │ ┤ │ │ │
4
│ Precipitation hardening, nickel based │ │ │ │ │ ├────────────┼────────────────────────────────────────────────────── │ │ ┤ │ │ │
5
│ Aluminum │ │ │ │ │ ├────────────┼────────────────────────────────────────────────────── │ │ ┤ │ │ │
6
│ Copper │ │ │ │ │ ├────────────┼────────────────────────────────────────────────────── │ │ ┤ │ │ │
7
│ Titanium and zirconium │ │ │ │ │ ╰────────────┴────────────────────────────────────────────────────── │ │ ╯ │ │ │ │ │ │ Notes
:
│ │ │ │ (
1
) Ferritic steel includes carbon, low alloy, and alloy steels, │ │ │ │ and ferritic, martensitic, and iron
-
based age
-
hardening stainless │ │ │ │ steels. │ │ │ │ │ │ │ ╰─────────────────────────────────────────────────────────────────────────╯
function
tableKM620_options2
() table
=
select
(KM620
.
coefficients_table,
"
Material
"
) notes
=
"
Notes:
\n
"
*
join
(
values
(
metadata
(KM620
.
coefficients_table)),
"
\n
"
) panel
=
@nested_panels
Panel
( Term
.
Table
(
hcat
(
1
:
nrow
(table), table.
"
Material
"
), header
=
[
"
Category
"
,
"
Material
"
], header_style
=
"
cyan
"
, columns_justify
=
[
:center
,
:left
], columns_style
=
"
default
"
, box
=
:ROUNDED
, style
=
"
cyan
"
, ),
TextBox
(
@style
(notes,
"
cyan dim
"
), ), title
=
"
Table KM-620 Material Categories
"
, title_style
=
"
cyan
"
, style
=
"
cyan
"
, )
return
panel
end
(Also in the last example, the styling is only applied to the first line of the TextBox.)
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
@nested_panel
works well with panels:But it does not work well with other text renderables: