Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
50
xamdatachart Multiple series in one chart
posted

Everyone,

I'm working on a xamdatachart that would need to chart two series (common x axis but two y axes). I'm using the following xaml code but I can't seem to figure out the background code to accomplish this.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<

 

 

 

ig:XamDataChart Grid.Row="1" HorizontalAlignment="Stretch" Name="backtestChart" VerticalAlignment="Stretch" VerticalZoomable="True" VerticalContentAlignment="Stretch" HorizontalZoomable

="True">

 

 

 

 

<ig:XamDataChart.Axes

>

 

 

 

 

<ig:NumericYAxis x:Name

="yAxis" />

 

 

 

 

<ig:NumericYAxis x:Name

="xmYAxis">

 

 

 

 

<!--MinimumValue="100"

MaximumValue="10000">-->

 

 

 

 

<ig:NumericYAxis.LabelSettings

>

 

 

 

 

<ig:AxisLabelSettings Foreground

="#FF69177C"

 

 

 

FontSize

="12"

 

 

 

HorizontalAlignment

="Center"

 

 

 

VerticalAlignment

="Center"

 

 

 

Location

="OutsideRight"

 

 

 

Angle="{Binding ElementName=sldYAxisAngle, Path

=Value}"

 

 

 

Extent="{Binding ElementName=sldYAxisExtend, Path

=Value}" />

 

 

 

 

</ig:NumericYAxis.LabelSettings

>

 

 

 

 

</ig:NumericYAxis

>

 

 

 

 

<ig:CategoryXAxis

 

 

 

x:Name="xAxis"

 

 

 

ItemsSource="{Binding}"

 

 

 

Label

="{}{Label}"/>

 

 

 

 

</ig:XamDataChart.Axes

>

 

 

 

 

<ig:XamDataChart.Series

>

 

 

 

 

<ig:LineSeries

 

 

 

x:Name="PL"

 

 

 

ItemsSource="{Binding}"

 

 

 

XAxis="{Binding ElementName=xAxis}"

 

 

 

YAxis="{Binding ElementName=yAxis}"

 

 

 

ValueMemberPath="Value" Thickness

="2" />

 

 

 

 

<ig:LineSeries

 

 

 

x:Name="Test"

 

 

 

ItemsSource="{Binding}"

 

 

 

XAxis="{Binding ElementName=xAxis}"

 

 

 

YAxis="{Binding ElementName=yAxis}"

 

 

 

ValueMemberPath="Value" Thickness

="2" />

 

 

 

 

<ig:FinancialPriceSeries x:Name

="PriceSeries"

 

 

 

DisplayType

="Candlestick"

 

 

 

TrendLineThickness

="12"

 

 

 

TrendLineType

="ModifiedAverage"

 

 

 

ItemsSource="{Binding

}"

 

 

 

OpenMemberPath

="Open"

 

 

 

CloseMemberPath

="Close"

 

 

 

HighMemberPath

="High"

 

 

 

LowMemberPath

="Low"

 

 

 

VolumeMemberPath

="Volume"

 

 

 

XAxis="{Binding ElementName

=commonXAxis}"

 

 

 

YAxis="{Binding ElementName

=priceYAxis}">

 

 

 

 

</ig:FinancialPriceSeries

>

 

 

 

</ig:XamDataChart.Series>

So, I've got two NumericYaxes which I'm guessing would let me chart two series but I can't seem to figure out how to accomplish it. When I try to add the second series, the chart only charts the second and ignores the second series. This is the code behind:

 

 

var data = from row in backtestTable

.Rows.OfType<

 

DataRow>()

 

 

select new DataItem()

{

Label = (

 

string)row["Date"].ToString(),

Value =

 

double.Parse(row["Price"].ToString())

};

backtestChart.DataContext = data;

data =

 

from row in backtestTable

.Rows.OfType<

 

DataRow>()

 

 

select new DataItem()

{

Label = (

 

string)row["Date"].ToString(),

Value =

 

double.Parse(row["Sales"].ToString())

};

backtestChart.Series[

 

"Test"].DataContext = data;

 

I would really appreciate any help.

Thanks,

K

Parents
  • 465
    posted

    It would be very useful if "series of all equal length and interval" was not a requirement.  XY charts tend to be technical data and you may have a different sampling interval, points get thrown out, or points are not collected.  To make the chart work you then have to massage your data to try to meet this requirement.

    I experienced the very same thing when I first tried to use the chart and it took a while to figure out what was going on.

Reply Children