Just getting started

Dec 21, 2009 at 12:54 AM

Hello,

              I'm primarily familiar with java and C++, and haven't done much with XML or C#. I was writing a simple graphing program in java, but I wasn't getting the functionality I needed, so I switched to C#. I'm using Visual Studio 2008, but WPF and .net are completely new to me. I found this library, which seems really awesome, but I'm having a hard time getting started. 

              Basically, right now I've got a simple 2D graph set up, but I'm trying to invert the y axis. My y axis is speed in minutes per mile, so lower #'s = faster. I've been able to modify the basic Hello World program to plot my data, and it looks great, but it's upside down. Is there a simple way to invert the y axis? I've read something about transforms, but I can't make sense of it. Thanks for the help. Here's what I have so far:

 

namespace RunManager2._1
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            Runs myRun = new Runs("2009-09-29 19;39;33.xml");
            
            InitializeComponent();
            BuildGraph(myRun);
        }
        void BuildGraph(Runs myRun)
        {
            // Prepare data in arrays
            int N = myRun.speedList.Count;
            double[] x = new double[N];
            double[] y = new double[N];
            for (int i = 0; i < N; i++)
            {
                x[i] = myRun.distList[i];
                y[i] = myRun.speedList[i];                
            }            
            // Create data sources:
            var xDataSource = x.AsXDataSource();
            var yDataSource = y.AsYDataSource();
            
            CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);
            
            // adding graph to plotter
            Plotter.AddLineGraph(compositeDataSource, Colors.CadetBlue, 3, myRun.name);
            
            // Force evertyhing plotted to be visible
            Plotter.FitToView();
                        
        }
    }
}

namespace RunManager2._1

public partial class Window1 : Window

    {

        public Window1()

        {

            Runs myRun = new Runs("2009-09-29 19;39;33.xml");

 

            InitializeComponent();

            BuildGraph(myRun);

        }

 

        void BuildGraph(Runs myRun)

        {

            // Prepare data in arrays

            int N = myRun.speedList.Count;

            double[] x = new double[N];

            double[] y = new double[N];

 

            for (int i = 0; i < N; i++)

            {

                x[i] = myRun.distList[i];

                y[i] = myRun.speedList[i];                

            }            

 

            // Create data sources:

            var xDataSource = x.AsXDataSource();

            var yDataSource = y.AsYDataSource();

 

            CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

 

            // adding graph to plotter

            Plotter.AddLineGraph(compositeDataSource, Colors.CadetBlue, 3, myRun.name);

 

 

            // Force evertyhing plotted to be visible

            Plotter.FitToView();

 

        }

    }

}