ShinobiChart clips annotation views


#1

Dear all,

I’m experimenting a little bit with the Trial Version and I succeded to insert annotations in a custom way (see the image). The problem is that some annotations are clipped due to the bounds of the chart. Is there a way to provide an inset in order to visualize annotation in the top right corner?

In my  ShinobiChart subclass, I set up the following:

ClipsToBounds = false;
Canvas.ClipsToBounds = false;

Thanks in advance.


#2

Hi Lorenz,

The canvas is actually your whole chart’s drawing area (including the axis labels). What you want to do is change the clipping on the canvas’ glView, this is your ‘plot area’. Try the following:

myChart.canvas.glView.clipsToBounds = NO;

You will need to import the canvas’ header (which it looks like you might already be doing :laughing:):

#import <ShinobiCharts/SChartCanvas.h>

#3

Thank you very much!!! It works like a charm!!!


#4

Lorenz, how are you aligning the annotations correctly above the columns? I can’t find a nice way to do this…


#5

Hi Tony,

I can post my code if you want. I’m using MonoTouch but the same logic can be set in ObjC. Let me know.


#6

I’m settings clipsToBounds to NO on the chart, the canvas and the glView but my annotation still gets clipped. Any idea why?

Pascal


#7

Is there an equivalent in Android yet?


#8

Hello.

Currently ShinobiCharts for Android does not directly support clipping options for Annotations. It should be possible to achieve this, but we will need to do a little more work :slight_smile:

Firstly, you would need to implement the following listener interface:

http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.5.1/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/ShinobiChart.OnInternalLayoutListener.html

Once informed that the chart has been laid out, you would need to use the data values of where you wish to place the non-clipped annotation, and covert them to pixel values. The pixel values you need are those which are relative to the chart, rather than the plot area. The axis class offers just such a method:

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

This method will give you the appropriate pixel values which as I say are relative to the chart. With this information you should be able to add your own Android view, in place of the ShinobiChart annotation. You will also of course be at liberty to place it in front or behind the chart plot area.

I hope that you find this information useful.

Thanks and kind regards,

Kai.


#9

Hello.

Currently ShinobiCharts for Android does not directly support clipping options for Annotations. It should be possible to achieve this, but we will need to do a little more work :slight_smile:

Firstly, you would need to implement the following listener interface:

http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.5.1/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/ShinobiChart.OnInternalLayoutListener.html

Once informed that the chart has been laid out, you would need to use the data values of where you wish to place the non-clipped annotation, and covert them to pixel values. The pixel values you need are those which are relative to the chart, rather than the plot area. The axis class offers just such a method:

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

This method will give you the appropriate pixel values which as I say are relative to the chart. With this information you should be able to add your own Android view, in place of the ShinobiChart annotation. You will also of course be at liberty to place it in front or behind the chart plot area.

I hope that you find this information useful.

Thanks and kind regards,

Kai.


#10

HI,

How would you go exactly about it on Android? I’m using the method addViewAnnotation to use my own, but it still goes behind the chart.

Should I wrap the chart in a FrameLayout and manage manually the positioning of a view on top of the chart, perhaps?

Thanks


#11

Hi stepbeta,

Yes exactly. The method described by Kai is for when the annotation behaviour is not suited to what you’re trying to achieve i.e. in this case, for it not to be clipped by the plot area. As such it involves positioning your own View above or below the chart. And placing the chart inside a FrameLayout and adding your own View to that FrameLayout (so it appears on top) should do the trick!

Hope that helps but do let us know if you’re still having problems with this.

Kind regards,

Patrick