Creating ColumnSeries for Xamarin.Android


#1

I have a problem with the ColumnSeries
I have a chart with date on the X-Axis and double on the Y-Axis. So I have List of IData like:
(“2010/1/1|”, 10.4)
(“2010/2/1|”, 20.4)
(“2010/3/1|”, 140.5)
(“2010/4/1|”, 34.9)
(“2010/5/1|”, 13.8)
(“2010/6/1|”, 10.4)
(“2010/7/1|”, 104.5)
(“2010/8/1|”, 130.4)
(“2010/9/1|”, 10.4)
(“2010/10/1|”, 50.4)
(“2010/11/1|”, 40.6)
(“2010/12/1|”, 10.4)

The problem is when I want to draw that in the ColumnSeries Chart, it draws tinny columns which don’t cover the whole month.
But the list above shows the revenue of each month, so I want that each column covers one month, so that the next column ( of the next month) is set just next to it(with no space or gap between them).
How can I do that?


#2

Hi ProgLover,

You can control the width of the columns in a ColumnSeries (and bars in a BarSeries) with the InterSeriesPadding and the InterSeriesSetPadding properties on the X Axis’ AxisStyle object. The values they are given are proportions of the available space rather than explicit pixel values, and should be between 0 and 1. In your case, to have no space between the columns, set both properties to 0.

Hope that helps! Let us know if you have any further questions.

Kind regards,

Patrick


#3

Thanks Patrick, now it works, although there is still a very smal gap between them.


#4

Hi ProgLover,

Ah yes, I see the problem here. From the data you provided above it looks like you’re plotting a column for each month. The problem is, is that not all months are the same length. The DateTimeAxis is a continuous axis and will show gaps in this situation as a result of this. If you were at the day level this wouldn’t happen because each column would be spaced out evenly.

In this situation a CategoryAxis would probably be more appropriate. Your data is discrete in the sense that you have 12 pieces of information you want to show. Each ‘category’ would be a String representing the month the column is showing the value for. (To clarify, your data doesn’t necessarily need to be a String as we will call the toString() method on it but, especially for Dates, you will probably want to do some form of formatting)

Our CategoryAxes will show each tick label, overlapping if necessary, and won’t allow a tick frequency to be set. However, if you did want to hide some but not all labels you can make use of the ShinobiChart.OnTickMarkUpdateListener (and/or ShinobiChart.OnTickMarkDrawListener) callback interface. This gives you access to each tick mark allowing you to hide the label and tick line as well as various other things.

Hopefully that all makes sense and allows you to get your desired result!

Kind regards,

Patrick