Impossible to apply styles to XAxis/YAxis component 'ticks'.
Hello! First off, let me say: nice work with React Vis. It is an excellent library and have served me well.
There is just one teeny, tiny problem:
Currently, the Axis component, as well as the XAxis and YAxis components both accept a style object as a prop.
The style object is comprised of several objects that are applied to different elements within the axis. It currently accepts root styles, line, title and ticks.
The problem lies with the ticks object. The name implies that it will style the ticks element - i.e. the container of all the ticks that the axis contains.
Unfortunately, however, the 'ticks' style object is applied to every tick within the container, and not the container itself.
Looking further into the code, I noticed that no prop styles are applied to the container:
Path: react-vis/src/plot/axis/axis-ticks.js:
return (
<g
transform={`translate(${x}, ${y})`}
className="rv-xy-plot__axis__ticks"
>
{ticks}
</g>
);
As a result, the only way to style the above <g> element is via an external stylesheet. In cases where CSS-in-JS is exclusively used in a given project, this can be cumbersome to deal with.
I propose that the ability to pass an additional style object to the Axis component to style the ticks container is implemented.
I would have suggested that the style object be called ticks and what is currently ticks be renamed to tick, but I appreciate that would cause back-compatibility issues. Perhaps ticksContainer would be apt?
Thanks!
Styling <g> elements is not possible. Styles you apply to it will be appended to all child elements, so that would just get the same result as how it is now.
See an example here