15 Jun 2012 11:48 AM #1
X-axis spacing for plots
So I noticed that the charts are rendered evenly for the X-axis. However, is there a way for this not to happen? For instance, if there are 3 x-axis values (ex. 5, 10, 100), the chart will render the points evenly spaced 1/3. Is there a way to relatively display the plot so that 5 and 10 is spaced more together and point 100 would be further down to the right? I just want to show the user that there is a huge gap between 10 and 100 compared to 5 and 10 (instead of it being evenly spaced).
I was trying to hunt down any settings the Chart or CategoryAxis might have, but no such luck.
18 Jun 2012 10:35 AM #2
The first thing that comes to mind is that you could set the dash size of the axis to 0 and then using a custom label provider blank all labels except 5, 10 and 100.
18 Jun 2012 10:38 AM #3
Oh wait just realized you mentioned category axis. If you want to have scaling based on value you should use numeric axis on the x-axis.
18 Jun 2012 12:44 PM #4
CategoryAxis<DataTimeStamp, String> catAxis = new CategoryAxis<DataTimeStamp, String>();
I should make it to (same as the Y-axis)?:
NumericAxis<DataTimeStamp> numAxis = new NumericAxis<DataTimeStamp>();
This will change for setting the field right, since for NumericAxis I am adding a field whereas CategoryAxis I am setting only one dataAccess.name() onto the field? Sorry, just a little confused...
*Update: Even if I change the X-axis to NumericAxis, I noticed the chart still plots, but I just see "NaN" on the 0 value for the X-axis and nothing else labeled on the right side of the x-axis. I am assuming I am labeling it incorrectly on the X-axis...*
18 Jun 2012 6:22 PM #5
Yes you would set up x-axis the same way you setup the y-axis. If add the field for the 5, 10 and 100 values it should render correctly. Also you will need to tell the series to use the correct x axis and x field just like with the y.
20 Jun 2012 6:40 AM #6
Since I am changing the x-axis to be y-axis, I can't use the setField (ex.catAxis.setField(dataAccess.name())).
Instead, I need to use the addField (which would explain why I am getting the y-axis values for the x-axis). I have something like this for the Y-axis and one of the series:
NumericAxis<DataTimeStamp> yAxis = new NumericAxis<DataTimeStamp>();
// not sure what to add here...
LineSeries<DataTimeStamp> series1 = new LineSeries<DataTimeStamp>();
When the chart is rendered though, it could have patches in the background where it is either gray or white. I attached image of what I see..
20 Jun 2012 4:46 PM #7
That is because the example axis you are using has a custom grid config. If you remove that the gray blocks will go away. Also looking at your image it would appear the lines are going off the chart. Do you still have minimum and maximum set?