Removing fractions from an axis


#1

Hello,

I’m new to ShinobiControls so apologies in advance if the question is too basic / silly. 

I’m using shinobi for Android. Say I have an x-axis for a chart series and I set the range such that min is 1 and max is 7 i.e. xAxis.setDefaultRange(new NumberRange(1.0, 7.0));

When it renders, it actually creates 14 points on the x-axis. That is, it creates 1, 1.5, 2, 2.5, 3, 3.5 and so forth. How can I prevent it from including the 1/2 points? I only need seven points on my x-axis.

Thanks

Abrar


#2

Hi Abrar,

Thanks for getting in touch.

In order to not show the 1/2 points you need to set the major tick frequency on your axes to 1.0. You can do this by using this method:

http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.5.1/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/Axis.html#setMajorTickFrequency(U)

I hope that you find this helpful.

Thanks,

Kai.


#3

Thanks Kai - that worked! I think the javadoc were a bit unclear to me when I originally read them.

While I have you there, I’m struggling with another issue. No matter what I do, I feel like the axis label on my xAxis (and sometimes on my Y axis) gets chopped of. I can’t put padding in a fragment but other than that I’ve tried putting in margins etc. I’ve tried different things on the fragment and on the parent layout but no luck - my labels are still getting chopped off. Note that 30 is chopped of in the xAxis in the screenshot. Anyone else having this problem? Any idea how to fix it? Thanks!


#4

Hi Abrar,

The tickmark labels will be clipped by the ChartCanvas area - this is the area of the Chart that includes the Plot Area (where the series are drawn) and the axes. The way in which each axis clips the tick marks is determined by its Clipping Mode.

There are three different modes:

  • NEITHER_PERSIST - if the label would be clipped in any way, both the label and the tick line are not displayed
  • TICKS_AND_LABELS_PERSIST - the label and tick line are shown regardless of whether the label is clipped at all (this is what you’re currently seeing)
  • TICKS_PERSIST - if the label would be clipped in any way, the label is not displayed but the tick line still is

The clipping mode is set on an Axis using the setTickMarkClippingModeHigh() and setTickMarkClippingModeLow() methods - you can set the mode independently at either end of the axis.

I hope that helps!

Patrick