Centering axis (1)


#1

I followed the Quick Start tutorial https://www.shinobicontrols.com/ios/shinobicharts/quickstartguide/drawing-a-simple-chart, and I’m wondering how to get a centered graph like this one http://image.noelshack.com/fichiers/2016/25/1466968639-img-8081.png.

I managed to center the x axis, and I have this http://image.noelshack.com/fichiers/2016/25/1466968619-trig.jpg

How can I manage to center the y axis as well? Here is the code I used to center the x axis. Thanks in advance!

chart.xAxis.axisPositionValue = @0

#2

Hi Ximensi,

Thanks for getting in touch!

The “axisPositionValue” is in data terms on the other axis.

For example, if you had a X-axis with the data range 0 - 10 and a Y-axis with the data range 0 - 100. To get both axes to be in the centre of the chart set the X-axis’ “axisPositionValue” & the Y-axis’ “axisPositionValue” to 5 like so:

    chart.xAxis.axisPositionValue = @50;

    chart.yAxis.axisPositionValue = @5;

Let me know if you have any questions.

Kind regards,
Andrew Polkinghorn.


#3

Hi 

I have the same requirement but in Android.
I am trying to achieve it by xAxis.setPosition() but it only take two enum params. Is there any way to achieve this in android?


#4

I also need to center xAxis on Android. Can’t find a way to do this. smiley confuse


#5

Hello.

  • Vivek, as you know we have since discussed this via info@shinobicontrols.com. If you need any further help, please do get back in touch.

  • Alin, Thanks for the contact and thanks for your interest in shinobicharts.

Currently, shinobicharts for Android does not natively offer the facility to reposition an Axis to the centre of the plot area. This feature is on our backlog but currently is not a feature that has been heavily requested by our users. That said, we do base our future development road map on our user requests and as such I have registered your interest in it. 

We do have a work around which makes repositioning the Axis achievable. I recently modified one of our sample apps to demonstrate this workaround. If you would like access to this code, please get in touch at info@shinobicontrols.com. This workaround may not of course be suitable for every use case, but seeing this code may help you to decide if it is right for you. The basic principle of this workaround is that we lay an additional View over the top of our chart, and use the ChartUtils class to draw our offset axis tick marks and labels to the Canvas of this view instead. Similarly, for our axis lines we simply draw lines, again offset, using the Android framework.

I hope that this helps you.

Thanks,

Kai.