ShinobiCharts: always show labels on axis limits


#1

Hi,

i’m using ShinobiGrids to show some data on the chart.

I need, in the xAxis, to always show a begginning and an ending value on my xAxis. Even if i zoom in or out.

Is there a property to set on my axis to make this work?

Thanks.

Cesare


#2

Hi isis,

This feature isn’t directly supported by shinobicharts, but there are a couple of ways you may be able to achieve this.

  1. Manually add a min UILabel at the left side of your chart and a max UILabel at the right side of your chart. You can then use the SChartDelegate method sChartRenderFinished: to detect when the chart re-renders because of a range change - you can use this notification to update your min and max labels. This introduces the problem that the chart’s tick labels might overlap with your manually added labels - you could possibly work around this using the sChart:alterTickMark:beforeAddingToAxis: delegate method to test if each tick label intersects with yours and if it does, hide it.

  2. Another solution is to use the SCHartDatasource method sChart:majorTickValuesForAxis:. This allows you to completely control what tick marks will be shown. So the first and last tick marks you return could be the min and max of the current range - this would cause a tick mark to always be shown at the min and max of the axis. The downside to this approach is that you are completely overriding the tick mark calculations, so you would need to do your own calculations to figure out what tick marks to show in between. Depending on your use case this could be very easy, or extremely difficult to do.

I hope the above suggestions give you something to work with. Please don’t hesitate to post another comment if you have further queries on any of this. :slight_smile: