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
335
Using NumericXAxis
posted

Hi,

I would like to use the NumericXAxis in my application. Hence it should be a very simple chart with double values at X and Y axes. I try to modifiy an infragisticy example which use CategoryXAxis and I want to change this in a NumericXAxis. Here is my xaml code:

<Window x:Class="IgSimpleChart.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ig="http://schemas.infragistics.com/xaml"
        xmlns:local="clr-namespace:IgSimpleChart"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        
        <Grid.DataContext>
            <local:DataPointCollection />
        </Grid.DataContext>
        
        <ig:XamDataChart x:Name="xmPreviewDataChart" DefaultInteraction="None" IsDragCrosshairEnabled="True">
            <ig:XamDataChart.Axes>
                <!--<ig:CategoryXAxis x:Name="xmPreviewXAxis" ItemsSource="{Binding}"  Label="{}{X}">
                    <ig:CategoryXAxis.LabelSettings >
                        <ig:AxisLabelSettings Location="OutsideBottom" Extent="35" />
                    </ig:CategoryXAxis.LabelSettings>
                </ig:CategoryXAxis>-->
                <ig:NumericXAxis x:Name="xmPreviewXAxis" >
                            <ig:NumericXAxis.LabelSettings >
                                <ig:AxisLabelSettings Location="OutsideBottom" Extent="25" />
                            </ig:NumericXAxis.LabelSettings>
                        </ig:NumericXAxis>
                <ig:NumericYAxis x:Name="xmPreviewYAxis">
                    <ig:NumericYAxis.LabelSettings >
                        <ig:AxisLabelSettings Location="OutsideLeft" Extent="25" />
                    </ig:NumericYAxis.LabelSettings>
                </ig:NumericYAxis>
            </ig:XamDataChart.Axes>
            <ig:XamDataChart.Series>
                <ig:LineSeries  MarkerType="None"
                                        Thickness="2"
                                        ValueMemberPath="Y"
                                        ItemsSource="{Binding}"
                                        XAxis="{Binding ElementName=xmPreviewXAxis}"
                                        YAxis="{Binding ElementName=xmPreviewYAxis}">
                </ig:LineSeries>
            </ig:XamDataChart.Series>
        </ig:XamDataChart >
    </Grid>
</Window>

You see that CategoryXAxis is inactive (marked as a comment). How can I "bind" the NumericXAxis to the real data (= DataPointCollection)?

The DataPointCollection looks as follow:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IgSimpleChart
{
    public class DataPointCollection : ObservableCollection<DataPoint>
    {
        public DataPointCollection()
        {
            int cnt = 4000;

            var rnd = new Random(0);

            for (int x = 0; x < cnt; x++)
            {
                double f = (double)rnd.Next(0, 10) / (double)100.0;

                double y = Math.Sin(x / (0.25 * cnt) + f);

                this.Add(new DataPoint() { X = x, Y = y });
            }
        }
    }

    public class DataPoint
    {
        public double X { get; set; }
        public double Y { get; set; }
    }
}

Kind Regards,

Thomas

Parents
No Data
Reply
  • 22015
    posted

    Hello Thomas,

     Thank you for your post. I have been looking into it. The NumericXAxis is used in Scatter Series, since the data in NumericXAxis is treated as continuously varying numeric labels. Here is a link where you can find more information about the NumericXAxis: http://help.infragistics.com/Help/NetAdvantage/WPF/2012.1/CLR4.0/html/xamDataChart_Axes.html. If you want to use the NumericXAxis I can suggest to change the Line Series to ScatterLineSeries. Using this type of series you would be able to use both NumericXAxis and NumericYAxis. If you want to use the LineSeries I can suggest to use the CategoryXAxis.

    I have created and attached a small sample for you, named NumericXAxis. In the sample I use the ScatterSeries to visualize the data. Please find the attached sample and do not hesitate to let me know if you require any further assistance on the mater.

    NumericXAxis.zip
Children