Candlestick chart with custom gridlines for X axis


#1

Hello!

I am currently using a candlestick chart that looks as follows:

But I would like xAxis gridlines to “separate” each bar, instead of cut it in the middle. This is what it shoud look like:

Is this something the sdk currently supports? I was looking at annotations maybe but wasn’t sure how to employ them for this purpose.

Thanks!


#2

Hello Macarran,

Is your question in relation to our iOS or Android product?

Thanks.


#3

Hi Kai, sorry for not providing that information, it was late on Friday :).

This is using your Android sdk. Is my question/problem clear?

Thanks!


#4

Hello macarran,

The simplest way to reposition the grid lines would be to provide a custom set of major tick mark values to your x axis which will override the standard ones. This will move the grid lines as they are drawn at the same horizontal position (for the x axis) as the major tick marks. The method you need to achieve this is:

https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/Axis.html#setMajorTickMarkValues(java.util.List<T>)

I hope this helps,

Thanks,

Kai.


#5

Hi Kai,

Thanks for reaching out. What if the axis is a CategoryAxis? We are basically showing a set of strings on the xAxis. The API you provided states:

“Custom major tick mark values cannot be set on a CategoryAxis. Any attempt to do so will be ignored. Also note that enabling grid stripes with custom tick mark values is not supported and may lead to some undesired visual effects.”

Is there any way around that?

Thanks,
Marcos.


#6

Hi macarran,

Unfortunately, as you have spotted, the technique which I describe is not currently compatible with a CategoryAxis. One possible workaround for you could be to use a NumberAxis for your x axis, rather than a CategoryAxis, which will allow you to use the technique which I described earlier. To restore your tick mark labels to Strings, you could then implement the OnTickMarkDrawListener interface in your code, to replace the number based label for the desired String. I must stress that I have not tried this approach myself but I believe it should be possible.

https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/ShinobiChart.OnTickMarkDrawListener.html

I hope that this helps,

thanks,

Kai.