Axis titles
See original GitHub issueOccasionally, it’s not apparent what a given axis/labels is/are referring to. Axis titles help to bring context.
I was hoping to handle axis titles myself outside the chartist.js by using absolutely positioned psuedo elements. For example:
HTML:
<div class="ct-chart" data-x-axis="My x-axis title" data-y-axis="My y-axis-title"></div>
CSS:
.ct-chart { position: relative; }
[data-x-axis]::before {
content: attr(data-x-axis);
position: absolute;
top: 0;
left: 0;
right: 0;
text-align: center;
}
[data-y-axis]::after {
content: attr(data-y-axis);
position: absolute;
/* vertical text rotation stuff */
}
But that produces a few problems:
- Takes axis title elements out of normal flow. In my example, axis titles are absolutely positioned. I could add a margin to the chart element, but that gets especially harry if the axis title needs to wrap to a second line
- Titles are never truly centered in relation to axis lines. The labels add extra padding to the chart pane.
- Reliably positioning y-axis rotated text is a huge pain… if not impossible. I can’t seem to find a way to position the title reliably. Especially if the y-axis title needs to wrap to a second line.
My SVG text positioning knowledge is quite limited, but I would think this problem would be better handled in SVG over HTML/CSS.
Issue Analytics
- State:
- Created 9 years ago
- Comments:15 (2 by maintainers)
Top Results From Across the Web
Change axis labels in a chart - Microsoft Support
Right-click the value axis labels you want to format. · Click Format Axis. · In the Format Axis pane, click Number. · Choose...
Read more >How to Add Axis Titles in a Microsoft Excel Chart - How-To Geek
Add Axis Titles to a Chart in Excel. Select your chart and then head to the Chart Design tab that displays. Click the...
Read more >How to Add Axis Titles in Excel - YouTube
Now, we'll carry on improving this line graph and we'll have a look at how to add axis titles in the graph area....
Read more >How to Add Axis Labels in Excel Charts - Step-by-Step (2022)
How to add axis titles ... 1. Left-click the Excel chart. 2. Click the plus button in the upper right corner of the...
Read more >About Axis Titles - MIT
An axis title is a word or phrase that describes an entire axis. Titles generally define what kind of data is being shown...
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
I must disagree with you @gionkunz, this is an extremely essential function for any charting library, no matter what it’s built on. In fact, I loved your library and started using it until I found this issue. Doing it in HTML is a pain because the browsers handle rotation differently, and if we’re using your library we obviously don’t have time to learn all of SVG, or we’d just make the graphs in SVG ourselves! That’s why we use libraries: to save time by not needing to reinvent the wheel.
Long story short: this is the reason my team and I decided to not use your software. In part this specific function but also because you obviously don’t listen your own user base who tells you it’s needed. Nobody wants to use a library where you have to write your own plugin just to get basic functionality.
Hi. I’m also looking for labels, but just labelling the axis doesn’t help when you have multiple series lines on one graph?
I could just add separate labels myself underneath, but is there a better way to get the right colours used for the lines, except just hardcoding them?
Update: Sorry I think I am over-complicating it. I can either just use the colours Chartist chooses, or override them using CSS. No problems. Thanks!