|
show xlabel in tips but not in the x axis |
Posted by Stephen on Jan-07-2011 11:22 |
|
Hi Peter,
I have a lie chart with a lot of data point, more than 600
x axis is the date.
I would like to show this date in the tip when user moves the mouse over the line but don't want to show these 600+ date on the xaxis, this makes the xaxis a mess.
1) How can i show some date, e.g. 20 dates out of 600 in the xaxis only?
2) if not, how to disable showing the xlabel completely?
appreciated with your help
Stephen
|
Re: show xlabel in tips but not in the x axis |
Posted by Peter Kwan on Jan-08-2011 01:55 |
|
Hi Stephen,
If your code pass "labels" to the x-axis (using Axis.setLabels or Axis.setLabels), you may use Axis.setLabelStep to ask ChartDirector to display only 1 out of 20 labels. For example, suppose you want to display no more than 10 labels on the x-axis, you may use (in Java):
if (myLabels.length > 10)
c.xAxis().setLabelStep((myLabels.length - 1)/ 10 + 1);
If your x-coordinates are really dates as according to the syntax of the programming language, you may also use a true date/time x-axis. In this case, the x-axis will be automatically scaled and labels similar to the y-axis. The code is like:
LineLayer myLayer = c.addLineLayer(myYData, ...);
//The x-axis will be auto-scaled - no need to use Axis.setLabels or Axis.setLabels2
myLayer.setXData(myXData);
//The date format can be configured using Axis.setLabelFormat
c.xAxis().setLabelFormat("{value|yyyy-mm}");
Note: a date in a human language such as English or Japanese is not necessarily a date according to the programming language - look for "Date Represenation" from the ChartDirector documentation index for more details.
Hope this can help.
Regards
Peter Kwan |
|