views:

1564

answers:

2

Hi, i have problem to correctly bind data to WPF Chart. When i'm setting ItemsSource i get error:

Assigned dependent axis cannot be used. The data may not be able to be rendered on the provided axis or the series may require that they axis has an origin.

oc = new ObservableCollection<Pair>();
heartBeats.ItemsSource = oc;

to Pair i'm saving int and long

XAML:

...
xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" >
<charting:Chart x:Name="ApplicatioChart">
            <charting:Chart.Series>
                <charting:ColumnSeries x:Name="heartBeats" Title="Working Set" 
                 DependentValueBinding="{Binding First}" IndependentValueBinding="{Binding Second}" >

                    <charting:ColumnSeries.IndependentAxis>
                        <charting:CategoryAxis Orientation="X" />
                    </charting:ColumnSeries.IndependentAxis>                    
                    <charting:ColumnSeries.DependentRangeAxis>
                        <charting:LinearAxis  Orientation="Y"  />
                    </charting:ColumnSeries.DependentRangeAxis>

                </charting:ColumnSeries>
            </charting:Chart.Series>
        </charting:Chart>

Please help.. :(

A: 

Can't see anything wrong with the mark up (apart from the same Property being bound as both the dependent and independent value).

It seems to work fine in the Silverlight version, I don't have the WPF version to play with.

Try removing the definition for the DependentRangeAxis, to see whether it works with the default one.

AnthonyWJones
+1  A: 

i resolved it this way:

<charting:Chart Title="Engine Performance" x:Name="ApplicationChart">
    <!-- Power curve -->
    <charting:LineSeries x:Name="heartBeats" 
                    Title="ManagedHeapSize"       
                    IndependentValueBinding="{Binding EventTime}"
                    DependentValueBinding="{Binding ManagedHeapSize}">

        <!-- Vertical axis -->
        <charting:LineSeries.DependentRangeAxis>
            <charting:LinearAxis
                            Orientation="Y"
                            Title="ManagedHeapSize"                                   
                            Interval="10000000" Focusable="True"
                            ShowGridLines="True"/>
        </charting:LineSeries.DependentRangeAxis>
    </charting:LineSeries>                      

    <charting:Chart.Axes>
        <!-- Shared horizontal axis -->
        <charting:LinearAxis
                        Orientation="X"
                        Title="EventTime"
                        Interval="100"
                        ShowGridLines="True"/>
    </charting:Chart.Axes>
</charting:Chart>
Jan Remunda