Example #1
0
        /// <summary>
        ///   Constructs a new instance of the ScatterplotView.
        /// </summary>
        /// 
        public DataChartView(Scatterplot scatterplot)
        {
            InitializeComponent();

            series = new CurveList();
            seriesDataMember = new Collection<DataChartViewSeries>();

            zedGraphControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
            zedGraphControl.GraphPane.Border.IsVisible = false;
            zedGraphControl.GraphPane.Border.Color = Color.White;
            zedGraphControl.GraphPane.Border.Width = 0;

            // zedGraphControl.IsAntiAlias = true;
            zedGraphControl.GraphPane.Fill = new Fill(Color.White);
            zedGraphControl.GraphPane.Chart.Fill = new Fill(Color.GhostWhite);
            zedGraphControl.GraphPane.CurveList = series;

            zedGraphControl.GraphPane.Legend.IsVisible = true;
            zedGraphControl.GraphPane.Legend.Position = LegendPos.Right;
            zedGraphControl.GraphPane.Legend.IsShowLegendSymbols = false;

            zedGraphControl.GraphPane.XAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.XAxis.MinorGrid.IsVisible = false;
            zedGraphControl.GraphPane.XAxis.MajorGrid.Color = Color.LightGray;
            zedGraphControl.GraphPane.XAxis.MajorGrid.IsZeroLine = false;
            zedGraphControl.GraphPane.XAxis.Scale.MaxGrace = 0;
            zedGraphControl.GraphPane.XAxis.Scale.MinGrace = 0;

            zedGraphControl.GraphPane.YAxis.MinorGrid.IsVisible = false;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.YAxis.MajorGrid.Color = Color.LightGray;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsZeroLine = false;
            zedGraphControl.GraphPane.YAxis.Scale.MaxGrace = 0;
            zedGraphControl.GraphPane.YAxis.Scale.MinGrace = 0;
        }
Example #2
0
        /// <summary>
        ///   Constructs a new instance of the ScatterplotView.
        /// </summary>
        public ScatterplotView()
        {
            InitializeComponent();

            scatterplot = new Scatterplot();

            classes = new CurveList();

            zedGraphControl.GraphPane.Title.Text = "Scatter Plot";
            zedGraphControl.GraphPane.XAxis.Title.Text = "X";
            zedGraphControl.GraphPane.YAxis.Title.Text = "Y";
            zedGraphControl.GraphPane.Fill = new Fill(Color.WhiteSmoke);
            zedGraphControl.GraphPane.CurveList = classes;
        }
        public void ComputeTest2()
        {
            ScatterplotView target = new ScatterplotView();

            Scatterplot histogram = new Scatterplot();
            histogram.Compute(new double[] { 200.0, 200.0, 200.0 });

            target.DataSource = null;

            target.DataSource = histogram;

            target.DataSource = null;

            // ScatterplotBox.Show(histogram);
        }
        /// <summary>
        ///   Constructs a new instance of the ScatterplotView.
        /// </summary>
        /// 
        public ScatterplotView(Scatterplot scatterplot)
        {
            InitializeComponent();

            classes = new CurveList();

            zedGraphControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
            zedGraphControl.GraphPane.Border.IsVisible = false;
            zedGraphControl.GraphPane.Border.Color = Color.White;
            zedGraphControl.GraphPane.Border.Width = 0;

            // zedGraphControl.IsAntiAlias = true;
            zedGraphControl.GraphPane.Fill = new Fill(Color.White);
            zedGraphControl.GraphPane.Chart.Fill = new Fill(Color.GhostWhite);
            zedGraphControl.GraphPane.CurveList = classes;

            zedGraphControl.GraphPane.Legend.IsVisible = true;
            zedGraphControl.GraphPane.Legend.Position = LegendPos.Right;
            zedGraphControl.GraphPane.Legend.IsShowLegendSymbols = false;

            zedGraphControl.GraphPane.XAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.XAxis.MinorGrid.IsVisible = false;
            zedGraphControl.GraphPane.XAxis.MajorGrid.Color = Color.LightGray;
            zedGraphControl.GraphPane.XAxis.MajorGrid.IsZeroLine = false;
            zedGraphControl.GraphPane.XAxis.Scale.MaxGrace = 0;
            zedGraphControl.GraphPane.XAxis.Scale.MinGrace = 0;

            zedGraphControl.GraphPane.YAxis.MinorGrid.IsVisible = false;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.YAxis.MajorGrid.Color = Color.LightGray;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsZeroLine = false;
            zedGraphControl.GraphPane.YAxis.Scale.MaxGrace = 0;
            zedGraphControl.GraphPane.YAxis.Scale.MinGrace = 0;

            ScaleTight = false;
            SymbolSize = 7;
            LinesVisible = false;

            this.scatterplot = scatterplot;
        }
Example #5
0
 internal ScatterplotClassValueCollection(Scatterplot parent, int index)
 {
     this.parent = parent;
     this.index  = index;
 }
        private void OnDataBind()
        {
            if (dataSource == null)
                return;

            if (scatterplot == null)
                scatterplot = new Scatterplot();

            double[] values = dataSource as double[];
            if (values == null)
            {
                double[] x = null;
                double[] y = null;
                int[] z = null;

                if (dataSource is DataTable)
                {
                    DataTable table = dataSource as DataTable;

                    if (String.IsNullOrEmpty(xAxisDataMember) &&
                        table.Columns.Contains(xAxisDataMember))
                        x = table.Columns[xAxisDataMember].ToArray();

                    if (String.IsNullOrEmpty(yAxisDataMember) &&
                        table.Columns.Contains(yAxisDataMember))
                        y = table.Columns[yAxisDataMember].ToArray();

                    if (String.IsNullOrEmpty(labelDataMember) &&
                        table.Columns.Contains(labelDataMember))
                        z = table.Columns[labelDataMember].ToArray().ToInt32();
                }
                else if (dataSource is double[][])
                {
                    double[][] source = dataSource as double[][];

                    if (source.Length > 0)
                    {
                        if (source[0].Length > 0)
                            x = source.GetColumn(0);

                        if (source[0].Length > 1)
                            y = source.GetColumn(1);

                        if (source[0].Length > 2)
                            z = source.GetColumn(2).ToInt32();
                    }
                }
                else if (dataSource is double[,])
                {
                    double[,] source = dataSource as double[,];

                    if (source.Length > 0)
                    {
                        int cols = source.GetLength(1);

                        if (cols > 0)
                            x = source.GetColumn(0);

                        if (cols > 1)
                            y = source.GetColumn(1);

                        if (cols > 2)
                            z = source.GetColumn(2).ToInt32();
                    }
                }
                else
                {
                    return; // invalid data source
                }

                if (x != null && y == null)
                    y = new double[x.Length];

                else if (y != null && x == null)
                    x = new double[y.Length];

                this.scatterplot.Compute(x, y, z);
            }
            else
            {
                double[] idx = Matrix.Interval(0.0, values.Length - 1, 1.0);
                this.scatterplot.Compute(idx, values);
            }

            this.UpdateGraph();
        }
Example #7
0
        private static ScatterplotBox show(Scatterplot scatterplot, bool hold)
        {
            ScatterplotBox form = null;
            Thread formThread = null;

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

            formThread = new Thread(() =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Show control in a form
                form = new ScatterplotBox();
                form.Text = scatterplot.Title;
                form.formThread = formThread;
                form.scatterplotView1.Scatterplot = scatterplot;

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            if (!hold)
                formThread.Join();

            return form;
        }
Example #8
0
 /// <summary>
 ///   Displays a scatter plot.
 /// </summary>
 /// 
 /// <param name="scatterplot">The scatter plot to show.</param>
 /// <param name="nonBlocking">If set to <c>true</c>, the caller will continue
 /// executing while the form is shown on screen. If set to <c>false</c>,
 /// the caller will be blocked until the user closes the form. Default
 /// is <c>false</c>.</param>
 /// 
 public static ScatterplotBox Show(Scatterplot scatterplot, bool nonBlocking = false)
 {
     return show(scatterplot, nonBlocking);
 }
Example #9
0
        /// <summary>
        ///   Displays a scatter plot with the specified data.
        /// </summary>
        /// 
        /// <param name="title">The title for the plot window.</param>
        /// <param name="x">A two column matrix containing the (x,y) data pairs as rows.</param>
        /// <param name="z">The corresponding labels for the (x,y) pairs.</param>
        /// <param name="nonBlocking">If set to <c>true</c>, the caller will continue
        /// executing while the form is shown on screen. If set to <c>false</c>,
        /// the caller will be blocked until the user closes the form. Default
        /// is <c>false</c>.</param>
        /// 
        public static ScatterplotBox Show(string title, double[][] x, int[] z = null, bool nonBlocking = false)
        {
            Scatterplot scatterplot = new Scatterplot(title);

            scatterplot.Compute(x, z);

            return show(scatterplot, nonBlocking);
        }
Example #10
0
        private static ScatterplotBox show(Scatterplot scatterplot)
        {
            ScatterplotBox form = null;
            Thread formThread = null;

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

            formThread = new Thread(() =>
            {
                Accord.Controls.Tools.ConfigureWindowsFormsApplication();

                // Show control in a form
                form = new ScatterplotBox();
                form.Text = scatterplot.Title;
                form.formThread = formThread;
                form.scatterplotView1.Scatterplot = scatterplot;

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            return form;
        }
Example #11
0
        private static ScatterplotBox show(String title, Func<double, double> function,
            double? min, double? max, double? step, int? npoints = null)
        {
            if (min == null || max == null)
            {
                DoubleRange range;
                if (GetRange(function, out range))
                {
                    min = range.Min;
                    max = range.Max;
                }
                else
                {
                    min = 0;
                    max = 1;
                }
            }

            if (npoints == null)
                npoints = 1000;

            if (step == null)
                step = (max - min) / npoints;

            double[] input = Vector.Interval(min.Value, max.Value, step.Value);
            double[] output = Matrix.Apply(input, function);

            Scatterplot scatterplot = new Scatterplot(title ?? "Scatter plot");

            scatterplot.Compute(input, output);

            return show(scatterplot);
        }
Example #12
0
 /// <summary>
 ///   Displays a scatter plot.
 /// </summary>
 /// 
 /// <param name="scatterplot">The scatter plot to show.</param>
 /// 
 public static ScatterplotBox Show(Scatterplot scatterplot)
 {
     return show(scatterplot);
 }
Example #13
0
        /// <summary>
        ///   Displays a scatter plot with the specified data.
        /// </summary>
        /// 
        /// <param name="title">The title for the plot window.</param>
        /// <param name="x">A two column matrix containing the (x,y) data pairs as rows.</param>
        /// <param name="z">The corresponding labels for the (x,y) pairs.</param>
        /// 
        public static ScatterplotBox Show(string title, double[][] x, int[] z)
        {
            Scatterplot scatterplot = new Scatterplot(title);

            scatterplot.Compute(x, z);

            return show(scatterplot);
        }
Example #14
0
        /// <summary>
        ///   Displays a scatter plot with the specified data.
        /// </summary>
        /// 
        /// <param name="title">The title for the plot window.</param>
        /// <param name="x">A two column matrix containing the (x,y) data pairs as rows.</param>
        /// 
        public static ScatterplotBox Show(string title, double[,] x)
        {
            Scatterplot scatterplot = new Scatterplot(title);

            scatterplot.Compute(x);

            return show(scatterplot);
        }