According to the Series Requirements in the IG XamDataChart 2010.3 documentation, the StepAreaSeries does not support numerical values on the x-axis.
Example of what I want to achieve:
I have a dataset with the following values:
{x=0.0 y=0.12}
{x=125 y=0.3}
{x=250 y=0.05}
{x=375 y=0.2} and so on... The distance between the x-values are the same between all points. In the end, I want my plot to look like this:
I have managed to draw the vertical lines by using ScatterLineSeries and using MarkerType.None.
Is there any way of adding step area series with numerical x-values??
Edit: I have the same issue with StepLineSeries.
The step line and area series support numerical values on the x axis, but they will treat all values as if they were evenly spaced. For example X = 1, x = 2, x = 2000000, will plot one after another with the same amount of interstitial spacing. This is because the numbers are being treated as string catagories rather than true numbers, which is appropriate if your data values are evenly spaced. But not as appropriate if they are not (e.g. 1, 2, 2000000).
Are you saying your data values are evenly spaced, or that they are being shown evenly spaced, and this isn't what you want?
If you are fine with them being shown evenly spaced, but are trying to overlay some dividers using a scatter line series, then this will be frustrating, as it can be hard to get the values to align between a category x axis and a numeric x axis, but not impossible.
You could emulate a steplineseries that takes true numeric x data, but inserting extra points into the data used for a scatter line series to give it the stepped effect. You would then just need a way to hide the markers you did not want to see.
Let me know more about what you are trying to do, and I'll see if I can help out.
Hope this helps!
-Graham
Yes, I am trying to overlay some dividers using scatter line series, so the issue will be with aligning category x-axis and numerical x-axis as you say.
I can emulate a steplineseries that takes true numeric x-data by adapting the scatter line series, but is there a way to emulate the step area series? i.e. fill the area between the x-axis and my line with a specific colour?
Thank you for your suggestions, but the solution will not work for me.
I'll look into other alternatives.
Produces this:
You are correct, by the way, that you wouldnt be able to use a scatter line to emulate a scatter area chart. We don't provide a scatter line currently that will produce a filled area. If you have more questions about aligning the axes, let me know.
Its hard to match up to the category axis for the stepareachart because it gets offset labeled (where the label appears in the middle of the step).To get the numeric axis to match up to the category axis, subtract half the interval between two points on your category axis from the minimum valueand add half the interval between the two points to the maximum value.In this case, the numbers on the category axis run from 0 to 140 with a 20 interval. So the range of the numeric x axis is set to:Min = (0 - (20 / 2)) = -10Max = (140 + (20 / 2)) = 150Note that this will only work if your category series data items are equidistant (the interval is constant).Here's the xaml:
<Grid x:Name="LayoutRoot" Background="White"> <igChart:XamDataChart x:Name="theChart" VerticalZoomable="True" HorizontalZoomable="True" VerticalZoombarVisibility="Visible" HorizontalZoombarVisibility="Visible"> <igChart:XamDataChart.Axes> <igChart:NumericYAxis x:Name="yAxis" MinimumValue="0" MaximumValue="100"/> <igChart:NumericXAxis x:Name="xAxis" MinimumValue="-10" MaximumValue="150"> <igChart:NumericXAxis.LabelSettings> <igChart:AxisLabelSettings Visibility="Collapsed" /> </igChart:NumericXAxis.LabelSettings> </igChart:NumericXAxis> <igChart:CategoryXAxis x:Name="catAxis" Label="{}{Label}" ItemsSource="{StaticResource stepData}" /> </igChart:XamDataChart.Axes> <igChart:XamDataChart.Series> <igChart:ScatterLineSeries XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" ItemsSource="{StaticResource line1}" MarkerType="None" Thickness="3" Brush="Blue" XMemberPath="XValue" YMemberPath="YValue"/> <igChart:StepAreaSeries XAxis="{Binding ElementName=catAxis}" YAxis="{Binding ElementName=yAxis}" x:Name="stepSeries" ItemsSource="{StaticResource stepData}" ValueMemberPath="Value"/> </igChart:XamDataChart.Series> </igChart:XamDataChart> </Grid>
And code behind:
public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } } public class Line1Data : ObservableCollection<LineDataItem> { public Line1Data() { Add(new LineDataItem() { XValue = 100, YValue = 0 }); Add(new LineDataItem() { XValue = 100, YValue = 100 }); } } public class LineDataItem { public double XValue { get; set; } public double YValue { get; set; } } public class StepDataItem { public string Label { get; set; } public double Value { get; set; } } public class StepData : ObservableCollection<StepDataItem> { public StepData() { Add(new StepDataItem() { Label = "0", Value = 10 }); Add(new StepDataItem() { Label = "20", Value = 20 }); Add(new StepDataItem() { Label = "40", Value = 30 }); Add(new StepDataItem() { Label = "60", Value = 40 }); Add(new StepDataItem() { Label = "80", Value = 50 }); Add(new StepDataItem() { Label = "100", Value = 60 }); Add(new StepDataItem() { Label = "120", Value = 70 }); Add(new StepDataItem() { Label = "140", Value = 80 }); } }
Does this help?-Graham
Any idea on this?