Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

xaxis unreadable when too many items

Open Zeus64 opened this issue 11 years ago • 5 comments

Hello,

on Line Chart i want to show history (month to month) from past 10 years. however their is too much label to write them all on the xaxis :( how to hide some label to show only few label who can be draw on the xaxis without overflowding their neighbor label ?

screenshoot: https://docs.google.com/file/d/0BwX45JL_Li5FWHRjRnVmblFkX00/edit?usp=drivesdk

Zeus64 avatar Mar 05 '15 09:03 Zeus64

and the scale numbers are cut off on the left side. I've also noticed that on a few charts.

HaraldWalker avatar Mar 10 '15 10:03 HaraldWalker

@HaraldWalker You can see how I resolved this problem at #715

ghost avatar Mar 10 '15 10:03 ghost

One possible solution is to print blank spaces for some of the labels. For instance, let's say you want to only have 10 X labels:

//assuming labelData is your current array of labels var labels = []; var labelsToShow = Math.floor(labelData .length / 10); for (var f = 0; f < chartData.length; f++) { if (f % labelsToShow == 0) { labels .push(f); } else { labels .push(""); } }

JamesWilsonProjects avatar Mar 16 '15 05:03 JamesWilsonProjects

This is a use case for the chart type I'm proposing in https://github.com/nnnick/Chart.js/issues/1059. Maybe you are interested in helping developing this?

arnoutaertgeerts avatar Apr 12 '15 12:04 arnoutaertgeerts

Huzzah! The first alpha of Chart.js 2.0 has landed and should fix this issue. Check out the release and try it out! We've got a lot of momentum right now, so please help us test so we can launch 2.0 Gold by the end of the month. https://github.com/nnnick/Chart.js/releases/tag/v2.0-alpha

I'm closing this issue for now, but if you have implementation questions or find bugs, please create a jsfiddle and post the link here and we'll reopen this issue and get it fixed.

derekperkins avatar Jun 04 '15 05:06 derekperkins