Columnchart - Unable to change font of text in Axis #506
-
Okay so, by my understanding the default way the text in the axis gets rendeered is:
Now, by specifying a custom format function for the axis I should be able to get it to render as normal text, and thus have the same font as the rest of my document. The problem comes in when we look at the implementation of bar/column charts. These define the axis themselves:
From my understanding, since I can't edit these function calls to supply my own format function to them, I can't actually make it so the font renders as normal content. In this case, this leads to a weird looking chart: If ther eis a way to fix this and I've missed it, my apologies. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
You have to wait for |
Beta Was this translation helpful? Give feedback.
-
Hey @johannes-wolf, with the push of 0.2.0 to latest, I'm still struggling to get this working. You mention x-format, but in this case it would have to be something like y-format? I would love some help on this cause I can't seem to resolve the original issue using options mentioned in the manual. |
Beta Was this translation helpful? Give feedback.
-
You can give your data labels as content. let data = (
([Item A], 1),
([*Bold Text*], 4)
)
cetz.chart.columnchart(size: (8, 6),
data,
label-key: 0,
value-key: 1,
) The |
Beta Was this translation helpful? Give feedback.
-
Can you give example code and what you want to achieve? |
Beta Was this translation helpful? Give feedback.
-
Sure! This is the output: Here is the code used to generate it: #let password_lengths = (
"< 8" : 1,
"8" : 5,
"9" : 10,
"10" : 55,
"11" : 1337,
"12" : 100,
"13" : 43,
"> 13": 12,
)
#align(center, canvas({
import draw: *
let colors = palette.new(colors: (color_palette.at("main").lighten(30%), black))
// Remove background grid
set-style(
grid: (
stroke: none,
),
)
chart.columnchart(
size: (auto, password_lengths.keys().len()),
mode: "stacked",
value-key: (1,),
bar-style: colors,
{
let result_data = ()
for key in password_lengths.keys() {
result_data.push((key, password_lengths.at(key)))
}
//panic(result_data)
result_data
},
)
})) Since the y-tick is auto-generated, I'd like it to be |
Beta Was this translation helpful? Give feedback.
-
Set |
Beta Was this translation helpful? Give feedback.
-
That worked perfectly, thank you very much :) |
Beta Was this translation helpful? Give feedback.
Set
y-format: v => [#calc.round(v)],