20
Overlap column series
posted
Hi all,
I would build a chart with two AreaSeries and some multiple overlap ColumnSeries.
In order to receive a continuous representation of my data, I convert X-values to DateTime elements (a sort of "ScatterAreaSeries").
So, my DataModel is:
public class DataPoint
{
public double X { get; set; }
public double Y { get; set; }
public DateTime DateTime_X
{
get
{
DateTime date = DateTime.Today.AddDays(X);
return date;
}
}
}
AreaSeries are ok but I'm not able to plot multiple column series that use the same x-values and different y-values.
Datasource is an array list like this:
List<DataPoint>[ ] data;
so I have
data[1]
x = 5010 Y= 1,18
x = 5660 Y= 0,3
X = 12800 Y = 0,2
...
data[2]
x = 5010 Y= 0,4
x = 5660 Y= 0.5
X = 12800 Y = 1,4
...
etc...
NumericYAxis is set on XAML file. The follow method in code-behind doesn't work. 
private void AddOverlapColumnSeries(List<DataPoint>[] data)
{
for (int i = 0; i < data.Lenght; i++)
{
var categoryDateTimeXAxis = new CategoryDateTimeXAxis();
CenterProfileChart.Axes.Add(categoryDateTimeXAxis);
categoryDateTimeXAxis.ItemsSource = data[i];
categoryDateTimeXAxis.DateTimeMemberPath = "DateTime_X";
var series = new ColumnSeries
{
ValueMemberPath = "Y",
ItemsSource = data[i],
XAxis = categoryDateTimeXAxis,
YAxis = numericYAxis
};
CenterProfileChart.Series.Add(series);
}
}
To have an idea of the chart I would build, please see the attached file.
Could be it build with Infragistics? What wrong with my code? 
Thanks in advance.
Parents
  • 26880
    Offline posted

    Hello John,

    From the screenshot that you have provided and the code that you have provided, I am a little unsure exactly of the visualization that you are looking to achieve with the Infragistics XamDataChart in Xamarin.Forms.

    Looking at your screenshot, I imagine the Grey and Orange areas are your two AreaSeries instances, but then it almost looks like you are looking to have a sort of "stacked" column series at occasional intervals in your data?

    From your code, it looks like you are trying to use a separate CategoryDateTimeXAxis per ColumnSeries as well, which I wouldn't really recommend. Is there a particular reason you are unable to use the one that you are using for your two AreaSeries in this case? I don't really see a reason why the CategoryDateTimeXAxis shouldn't let you plot ColumnSeries with the same X-Values but different Y's, because as long as the X-values are the same, I would expect that they should show up, and the NumericYAxis will interpret the ValueMemberPath accordingly. For example, if you placed a numeric property on the same data item that you are using for your AreaSeries elements, I would imagine you could just use that as a ValueMemberPath for your ColumnSeries and fill it out with double.NaN if you don't want a column plotted or use numeric values if you do.

    It is also worth mentioning that if you use multiple CategoryDateTimeXAxes, you may wind up with a skewed view unless you set the MinimumValue and MaximumValue properties to consistent values.

    One issue that you will likely have in this case is the fact that the ColumnSeries was really only designed to be used with the CategoryXAxis, and not the CategoryDateTimeXAxis. The width of the columns in a ColumnSeries really depends on how many columns will actually be plotted, and as such, if you only have a few, the columns might be very large. If they happen close to each other, they also may overlap in an undesired way. You can read further about this at the WPF thread (the XamDataChart works the same in WPF and Xamarin.Forms), here: https://www.infragistics.com/community/forums/f/ultimate-ui-for-wpf/107504/item-width-is-not-expected-in-columnseries-with-categorydatetimexaxis-on-xamdatachart.

    It is also certainly possible that I am not really understanding your requirement very well in this case. If this is the case, would it be possible for you to perhaps attach a sample isolated project that may demonstrate where you are at with this issue? Again, though, using the CategoryDateTimeXAxis with the ColumnSeries in the XamDataChart is not really recommended, and so achieving a visualization like the one you have provided may prove rather difficult.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

  • 20
    Offline posted in reply to Andrew Goldenbaum
    Hi Andrew,
    thank you for your response and I'm sorry I wasn't clear.
    From the screenshot, the Gray and the Orange areas are two AreaSeries instances. I used a CategoryDateTimeXAxis for the same reason that you write here:
    For the "stacked" ColumnSeries, I use a different CategoryDateTimeXAxis because it has a different ItemSource (or is it wrong?) 
    Also, If I use a Category Axis instead of a CategoryDateTime Axis, I think that the string value 4200 (for example) is not placed at the same point in the chart as the double value 4200 of the AreaSeries does. So AreaSeries and ColumnSeries are not "synced".
     
    In the link below you can download a part of my project. 
    I appreciate your patience to solve my problem and I hope you can help me.
    Best regards,
    John
Reply Children
No Data