-
Notifications
You must be signed in to change notification settings - Fork 835
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 move axis label to the middle of the axis? #542
Comments
That functionality doesn't really exist right now! It certainly can and should be part of the Annotation as first class citizens (#494), but i think you could probably get something working today by adding some custom SVG like so: import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
class CustomAxisLabel extends PureComponent {
render() {
return (
<g transform={`translate(${width / 2}, ${height / 2}`}> <text>LABEL NAME </label></g>
);
}
}
CustomAxisLabel.displayName = 'CustomAxisLabel';
CustomAxisLabel.requiresSVG = true;
export default CustomAxisLabel; Then embed that into XYPlot as child, like so: <XYPlot>
<XAxis />
<LineSeries />
<CustomAxisLabel />
</XYPlot> (There may so typos in there, i didn't run this code) |
@mcnuttandrew thanks for the solution. I can try the workaround.
titlePosition can be selected from the pre-defined positions. |
I totally agree and would welcome a PR to that effect! Maybe a more robust api would be like <XAxis title="X Axis Title" titlePositionX="50%" titlePositionY="-15px" style={{
title: {fontSize: '16px}
}}/> or something to that effect so that we dont support a bunch of individual keywords? |
for those seeking a for-now solution, here's what I came up w/
|
@brandonmp I'm using your "for now" code but running up against crummy looking rotated text in Chrome especially. See: https://stackoverflow.com/questions/50257924/svg-transform-text-aliased-in-chrome-how-can-i-fix-it Any ideas? |
How to change the text color on this ? |
There's a solution now available in ChartLabel (see #1038 for more details) |
Is it only me who cannot find the info - but here is EXACT link how to make this possible |
The default position of the axis label is at the end of the axis as shown in the screenshot. Is there anyway to set the label to be in a different position, e.g., at where the arrows point to?
Another question about the axis labels... how to change style (font, size etc.) of the axis labels? I tried search the documentation here but couldn't find how to do it.
The text was updated successfully, but these errors were encountered: