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
260
Help with ScatterLine chart
posted
I am trying to create a very simple ScatterLine chart, but just can't seem to get it to work.  Since I've just started learning wpf yesterday, I feel as if I am missing some important piece here. 
 
It breaks on start with error message "The scatter chart needs ValueX and ValueY. The values have to be set for every data point using ChartParameters collection."  I've defined a DataMapping (DataMapping="ValueX=X; ValueY=Y"), so in theory I should not be getting this message.

XAML:

<Window x:Class="DeltaOne.HFClient.HFClient"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DeltaOne.HFClient"
    xmlns:igChart="clr-namespace:Infragistics.Windows.Chart;assembly=Infragistics3.Wpf.Chart.v10.1"
    Title="HFClient" Height="400" Width="855">

    <Grid AllowDrop="True">
        <Button Height="23" HorizontalAlignment="Left" Margin="146,12,0,0" Name="btnAdd" VerticalAlignment="Top" Width="94" Click="btnAdd_Click">Add</Button>
        <TextBox Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="textBox1" VerticalAlignment="Top" Width="56" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="75,12,0,0" Name="textBox2" VerticalAlignment="Top" Width="56" />
       
        <igChart:XamChart Name="xamChart1" Height="272" VerticalAlignment="Bottom" Margin="46,0,56,27" DrawException="False">
            <igChart:XamChart.Series>
                <igChart:Series ChartType="ScatterLine"
                           Name="DataSeries"
                           DataContext="Binding Source={StaticResource dataSeries}"
                           DataMapping="ValueX=PropertyX; ValueY=PropertyY" />
            </igChart:XamChart.Series>
        </igChart:XamChart>
       
    </Grid>
</Window>

CodeBehind:

namespace DeltaOne.HFClient
{
    public partial class HFClient : Window
    {
        protected ObservableCollection<HFPoint> dataSeries = new ObservableCollection<HFPoint>();

        public HFClient()
        {
            InitializeComponent();
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            double x = Double.Parse(textBox1.Text);
            double y = Double.Parse(textBox2.Text);

            addDataPoint(x, y);
        }

        private void addDataPoint(double x, double y)
        {
            HFPoint p = new HFPoint();
            p.PropertyX = x;
            p.PropertyY = y;
            dataSeries.Add(p);
        }

    }

    public class HFPoint
    {
        public Double PropertyX { get; set; }
        public Double PropertyY { get; set; }
    }

}

Parents Reply Children
No Data