LineSeries Dependent/Independent Axis swap

Feb 17, 2010 at 2:29 AM

Hi All,

I'm attempting to plot some sound velocity profiles. These are a measure of the speed of sound in a water column with respect to depth. Traditionally these are plotted with depth on the y-Axis and speed of sound on the x-axis.

For testing purposes I have a Point3DCollection containing my data points in the format of <depth, soundspeed, temperature>as the <X,Y,Z> of the Point3D.

The points are plotting in the expected locations, however the line that connects each of the points is not connecting in the same order as the points are defined in the Collection, instead it appears the points are sorted ascendingly on the IndependentValue field (which is sound speed).

See for a visual comparison of what I wanted vs what I got.

The XAML is here:

<Window x:Class="BathyChart.Window1"
    Title="Window1" Height="300" Width="300">
        <chartingToolkit:Chart x:Name="BathyChart" Grid.Row="0">
                <chartingToolkit:LineSeries x:Name="MySeries1"
                                                IndependentValueBinding="{Binding Y}"
                                                DependentValueBinding="{Binding X}"
                            <Point3D X="0.000000" Y="1502.490000" Z="20.752624"/>
                            <Point3D X="-1.290000" Y="1511.940000" Z="20.883149"/>
                            <Point3D X="-2.590000" Y="1519.270000" Z="20.984392"/>
                            <Point3D X="-3.880000" Y="1521.250000" Z="21.011740"/>
                            <Point3D X="-5.180000" Y="1522.100000" Z="21.023481"/>
                            <Point3D X="-6.470000" Y="1522.120000" Z="21.023757"/>
                            <Point3D X="-7.760000" Y="1522.140000" Z="21.024033"/>
                            <Point3D X="-9.060000" Y="1522.170000" Z="21.024448"/>
                            <Point3D X="-10.350000" Y="1522.190000" Z="21.024724"/>
                            <Point3D X="-11.640000" Y="1522.210000" Z="21.025000"/>
                            <Point3D X="-12.940000" Y="1522.230000" Z="21.025276"/>
                            <Point3D X="-14.230000" Y="1522.530000" Z="21.029420"/>
                            <Point3D X="-16.520000" Y="1522.000000" Z="21.025829"/>
                            <Point3D X="-18.520000" Y="1521.270000" Z="21.025829"/>
                            <Point3D X="-20.520000" Y="1520.270000" Z="21.025829"/>
                            <Point3D X="-22.520000" Y="1519.270000" Z="21.025829"/>
                            <Point3D X="-24.520000" Y="1518.270000" Z="21.025829"/>
                <chartingToolkit:LinearAxis Orientation="X" Location="Bottom"/>
                <chartingToolkit:LinearAxis Orientation="Y" Location="Left"/>

The thing of main importance is the layout of the sound speed profile. So I thought I would make sound speed the Dependent value. This connects the lines in the expected manner (as depth is already sorted in the list) - See the 3rd plot in the above screen shot.

So now all I need to do is swap the X and Y Axis.

It appeared that I could set the LineSeries.IndependentAxis Orientation field as follows:

<chartingToolkit:LineSeries x:Name="MySeries1"
                            IndependentValueBinding="{Binding X}"
                            DependentValueBinding="{Binding Y}"
        <chartingToolkit:LinearAxis Orientation="Y"/>
        <chartingToolkit:LinearAxis Orientation="X"/>

Unfortunately, when I run the sample an InvalidOperationException is thrown with additional information of: "Assigned independent axis cannot be used".

Has anyone else had any experience in having Independent data on the Y axis? Or changing the point line connection order of a LineSeries?

I've realised I can do a RotateTransform on the chart (whilst also rotating all of my labels, titles and legend in the opposite direction) to acheive the behaviour I want, but it seems very messy.