Change an Axis's label font-size
See original GitHub issueHow can you change an Axis’s label font-size?
According to the docs (https://github.com/hshoff/vx/tree/master/packages/vx-axis), the “label” attribute is a string value.
When the label is rendered, the <text>
element has several attributes that I haven’t specified:
Code to produce the Axis:
<AxisBottom
left={50}
scale={xAxisScale}
top={yMax + margin.top}
stroke='gray'
tickStroke='gray'
label="My Amazing Customized Label!"
tickLabelComponent={(
<text
fill='gray'
fontSize={11}
textAnchor="middle"
/>
)}
/>
(as an aside, tickLabelComponent isn’t mentioned in Axis’s docs either, I just saw it in an example)
Rendered label SVG:
<text
text-anchor="middle"
font-family="Arial"
font-size="10"
fill="black"
x="575"
y="37">
My Amazing Customized Label!
</text>
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How do I set the figure title and axes labels font size?
I want to specify font sizes for the figure title and the axis labels. I need all three to be different font sizes,...
Read more >How to change chart axis labels' font color and size in Excel?
Just click to select the axis you will change all labels' font color and size in the chart, and then type a font...
Read more >Changing font size of all axes labels - MATLAB Answers
Changing font size of all axes labels. ... I wonder what's not working for the label font size when axis font size is...
Read more >Change Font Size of ggplot2 Plot in R | Axis Text, Main Title ...
How to modify font sizes of ggplot2 graphics in R - 5 programming examples - Change font size of axes, main title &...
Read more >How to change the size of axis labels in Matplotlib?
If we want to change the font size of the axis labels, we can use the parameter “fontsize” and set it your desired...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thanks 😃 If in doing so you have thoughts / comments on the api let us know. I’ve thought about:
keep it as is with different behavior for a string vs a component.
we could make this more clear by adopting the
labelComponent
prop name of the lower-levelAxis
component thatAxisTop/Right/Bottom/Left
wrap. that means if you pass a string we render is as-is and makes it harder to simply pass in a string and get some styles like you do now.you could make this two props:
label
that is only a string andlabelComponent
which specifies the component to use to wrap it.none of these let you easily tweak a single value like
font-size
without specifying all of the other styles on the component. I’d probably vote for 2 and fix this issue with a betterLabel
orText
component that would add default styles for you and let you override one or all of them easily 🤔Thanks!
Trying now, will post updated code (to serve as a reference until docs are updated) then will close.