-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Show x labels #897
Show x labels #897
Conversation
@adrianandreias No it doesn't do that. I tried once though, but couldn't figure out the code which handles label rotation. Maybe I would try it again and update here in a while. |
@hay-wire can you remove |
+1 :D |
+1 def need this |
+1 |
@etimberg I'm not sure how to do that in the current branch as the current PR already contains built files (Chart.js and Chart.min.js)! Can you please guide me a bit? |
okay I'm making changes in showXLabels with a cleaner history, latest pull from nnick's repo and no changes to Chart.js or Chart.min.js. Apologies for this mess. I'm not very acquainted with PRs. This is my first time. |
It enables controlling how many labels should be shown on x axis. Really helpful in case there are huge number of labels. Chart.Core.js has been edited so, showXLabels option is available to any other chart as well if anybody wants to extend this feature.
Until now all ticks have been painted which does not makes sense if you have thousands of values and only want to show 10. the svg path for the tick mark is now only painted if the corresponding value is also painted. thanks for your fork! --- This commit is on behalf of @gerbsen <https://github.com/gerbsen> who had submitted this patch for an older branch (which I had messed up). Thanks gerbsen.
@etimberg : I force updated showXLabels branch with cleaner history. Chart.js and Chart.min.js have not been affected. Hope this one works. Let me know if I need to resubmit a fresh PR. |
@adrianandreias I tried fixing label rotation again yesterday. However, as of now, it is tightly coupled with all available xLabels. Even if I do it, then label rotation would become dependent on showXLabels, which is more of a hack than a good solution as @nnnick pointed out earlier. So leaving it for now. I'll try if I can take showXLabels more closer to what nnnick had proposed. That might take care of label rotation as well. |
There is discussion going on as to whether this is the best approach to the problem. Tagging Potential |
+1 for merge, this looks like a good solution, but I agree that there may be a better one |
how's the discussion going with this? |
I dont see any progress in this regard. All the PRs are pending.. https://github.com/nnnick/Chart.js/labels/Potential Maybe the team is working on a cleaner solution. |
+1! |
+1 |
Has feature been finally merged or is it still pending ? |
I think we can merge... any objections? |
Objection. Can we please merge this to a feature or dev branch? We have been discussing several fixes to axis labeling and settling on one prevents us from trying another. |
@jakesyl : I second @fulldecent . |
So it has been finally merged then ? |
@hay-wire Is-it possible to add your fork on bower and merge regularly with the master ? Because I'm not sure this feature will be available one day in the master... |
+1 |
@harscoet: I haven't ever done that. Let me give it a try and come back to you. Any links in this regard would be appreciated. |
@hay-wire Fist step you should update the Chart.js and Chart.min.js with gulp npm install;gulp For bower you have some info in this post http://stackoverflow.com/questions/25104623/how-to-properly-register-a-github-fork-with-bower |
+1 for merging. |
👍 |
+1. This is needed! |
+1 |
+1! Definitely needed. |
+1 |
4 similar comments
+1 |
+1 |
👍 |
+1 |
Hi, is there any progress on getting this feature merged? or if there is another (undocumented) feature which does this? Looks like this has been stalled since January, and unless there are actual hard objections to this I see no reason why it is not already in. |
There is now an auto-magic feature for x-label spacing, rotation, and skipping in v2.0-dev (alpha). It's very young, but in line with the way we are handling scales in the next version. Take a look at the v2.0-dev branch examples to test! We plan to add plenty of customization features in this area very soon, but for now having a solution that will be responsive, and automatic for most use cases is our goal. |
We've recently announced a feature complete status for v1.x and will only be accepting bug fixes for v1.x. Be sure to take a look at v2.0-dev and it's new features that are either finished or currently under development. If you see your feature is still not implemented, feel free to submit another PR to the v2.0-dev (or later) branch for your feature. |
Any update which branch to use now to get this feature? |
Didn't merged yet? |
+1 Hi ! Are there any updates on this? |
Is this merged in yet? |
Any updates? |
Any updates on this matter? |
It looks like ChartJS does this now |
Applicable to bar chart and line chart.
User can now pass a { showXLabels: 10 } to display only 10 labels (actual displayed labels count might be a bit different depending on the number of total labels present on x axis, but it will still remain close to 10 however)
Helps a lot when there is a very large amount of data. Earlier, the graph used to look devastated due to x axis labels drawn over each other in the cramped space. With showXLabels, user now has the control to reduce the number of labels to whatever number of labels fit good into the space available to him.
Please see the attached images for a comparison. the second graph has been passed { showXLabels: 10 } into option.
Without showXLabels:
With showXLabels = 10:
Usage: Just pass showXLabels: 10 along with other options in the constructor.
Example:
myLine = new Chart(ctx).Line(lineChartData, {
responsive: true,
showXLabels: 10
});