I am using Infragistics 11.1 with Visual Studio 2010.
I have a problem in XamChart where chart type is Area.
I have 800 points in my collection, which I have bound to the DataSource property of the XamChart, the points start from 0 and increase with very small change and reach to almost 0.4 or 0.5 and then again start decreasing
and reach to 0. So it creates a smoothes curve. As shown in the below chart.
Now what I want is to show some custom labels on the X-Axes in place of default labels and those labels are -10, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10. It means there is an interval of -10 to 10 and there is a gap of 2.5.
For achieving this what I did is here below in xaml.
<igCA:XamChart>
<igCA:XamChart.Axes>
<igCA:Axis AxisType="PrimaryX"
AutoRange="False"
Minimum="-10"
Maximum="10"
Unit="2.5"
>
</igCA:Axis>
</igCA:XamChart.Axes>
<igCA:XamChart.Series>
<igCA:Series ChartType="Area" DataSource="{Binding Path=Points}" DataMapping="points">
</igCA:Series>
</igCA:XamChart.Series>
</igCA:XamChart>
But it generates an error and the error is.
“XamChart Warning: Index was out of range, must be non negative and less than the size of collection.
Parameter name: Index”.
But if I set Minimum to 0 and Maximum t0 800 and Unit to 100 then it generates the result with labels 100,200,300....800.
But I need the above result.
Thanks.
Hi,
Is there anything further that I can help you with regarding your question?
If so, please feel free to contact me.
Looking at your chart image it appears that all of the data values are between 0 and .6 and I would recommend that you use either RangeFromZero set to False on the PrimaryY axis so that the chart will calculate the necessary min and max values or set the AutoRange to False and set the Minimum, Maximum and Unit values for yourself.
For the PrimaryX axis I would suggest that you use the following:
<igCA:Axis AxisType="PrimaryX" RangeFromZero="False"
AutoRange="False" Minimum="0" Maximum="50" Unit="5" >
Then you can show customized labels along the Y axis by providing labels with each data point in your data.
This link may help you in Modify the Axis Range
http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=xamChart_Modify_the_Axis_Range.html
Here’s some code to generate the labels with the data points and the xaml.
private void FillChartPoints()
{
chartPoints.Add(new ChartPoint(0.0, "0"));
chartPoints.Add(new ChartPoint(0.018, ".018"));
chartPoints.Add(new ChartPoint(0.02, ".02"));
chartPoints.Add(new ChartPoint(0.031, ".031"));
chartPoints.Add(new ChartPoint(0.05, ".05"));
…….
chartPoints.Add(new ChartPoint(0.383, ".383"));
chartPoints.Add(new ChartPoint(0, "0"));
xamChartArea.DataContext = chartPoints;
}
private List<ChartPoint> chartPoints = new List<ChartPoint>();
public List<ChartPoint> ChartPoints
get { return chartPoints; }
public class ChartPoint
public ChartPoint(double value, string description)
Value = value;
Description = description;
public double Value { get; set; }
public string Description { get; set; }
<igCA:XamChart x:Name="xamChartArea" >
<igCA:XamChart.Legend>
<igCA:Legend Visible="False"/>
</igCA:XamChart.Legend>
<igCA:XamChart.Series >
<igCA:Series x:Name="chartSeries"
DataSource="{Binding Path=ChartPoints}"
DataMapping="Value = Value; Label = Description"
ChartType="Area">
AutoRange="False" Minimum="0" Maximum="50" Unit="5" />
<igCA:Axis AxisType="PrimaryY" RangeFromZero="False" />
Let me know if you have any questions.