Skip to content
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

How to change the font-size for the x- and y-axes? #238

Closed
matthewvolny opened this issue Apr 28, 2022 · 3 comments
Closed

How to change the font-size for the x- and y-axes? #238

matthewvolny opened this issue Apr 28, 2022 · 3 comments
Labels

Comments

@matthewvolny
Copy link

I have been combing the docs looking for a way to change the font-size of the x- and y-axes for a barchart, but don't see an easy answer. I am able to enable labels at the ends of the bars (enableLabels) and resize the font for these (labelsSize), but as I said, no info that I can tell on changing font-size for the axes. Perhaps I am missing something obvious. See this forked codepen for an example of the problem. https://codepen.io/mvolny/pen/XWZrmXR. Code is simple and below Any help is appreciated. Thank you.

const {Bar} = window['britecharts-react'];
const barData = [
{
name: 'Radiating',
value: 2,
},
{
name: 'Opalescent',
value: 4,
},
{
name: 'Shining',
value: 3,
},
{
name: 'Vibrant',
value: 6,
},
{
name: 'Vivid',
value: 6,
},
{
name: 'Brilliant',
value: 1,
},
];
const marginObject = {
left: 100,
right: 40,
top: 40,
bottom: 40,
};

ReactDOM.render(
<Bar
data={barData}
width={400}
isHorizontal={true}
margin={marginObject}
enableLabels={true} //change labels but not x and y
labelsSize={15} //change labels but not x and y
/>,
document.getElementById('app')
);

@Golodhros
Copy link
Collaborator

Hi @matthewvolny, thanks for using Britecharts and asking this question!

You mean to update the font size of the category labels on the axes, right? I would advise to use CSS for that, try something like this:

.tick text {
  font-size: 16px !important;
}

@matthewvolny
Copy link
Author

@Golodhros Thanks! Worked like a charm. I see now that taking this approach I can change other aspects of the charts styling (see below). I did try targeting the chart elements with css before but somehow missed the "text" element inside of the "tick" class. Yes, cool charting package. And I like the react wrapper. Take care.
(i.e.
.vertical-grid-line {
display: none !important;
}
)

@Golodhros
Copy link
Collaborator

Awesome!

Keep an eye on the project, we are adding cool stuff for version 3!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants