Пример #1
0
        /// <summary>
        ///   Forces a update of the scatter plot.
        /// </summary>
        ///
        public void UpdateGraph()
        {
            zedGraphControl.GraphPane.Title.Text       = scatterplot.Title;
            zedGraphControl.GraphPane.XAxis.Title.Text = Scatterplot.XAxisTitle;
            zedGraphControl.GraphPane.YAxis.Title.Text = Scatterplot.YAxisTitle;

            classes.Clear();

            if (scatterplot.Classes != null)
            {
                if (scatterplot.Classes.Count == 0)
                {
                    zedGraphControl.GraphPane.Legend.IsVisible = false;

                    // Create space for unlabelled data
                    PointPairList list = new PointPairList(scatterplot.XAxis, scatterplot.YAxis);

                    LineItem item = new LineItem(String.Empty, list, Color.Black, SymbolType.Default);

                    item.Line.IsVisible          = false;
                    item.Symbol.Border.IsVisible = false;
                    item.Symbol.Fill             = new Fill(Color.Black);

                    classes.Add(item);
                }
                else
                {
                    zedGraphControl.GraphPane.Legend.IsVisible = true;
                    var colors = new ColorSequenceCollection(scatterplot.Classes.Count);

                    // Create a curve item for each of the labels
                    for (int i = 0; i < scatterplot.Classes.Count; i++)
                    {
                        // retrieve the x,y pairs for the label
                        double[]      x    = scatterplot.Classes[i].XAxis;
                        double[]      y    = scatterplot.Classes[i].YAxis;
                        PointPairList list = new PointPairList(x, y);

                        LineItem item = new LineItem(scatterplot.Classes[i].Label.ToString(),
                                                     list, colors[i], SymbolType.Default);

                        item.Line.IsVisible          = false;
                        item.Symbol.Border.IsVisible = false;
                        item.Symbol.Fill             = new Fill(colors[i]);

                        classes.Add(item);
                    }
                }

                zedGraphControl.AxisChange();
                zedGraphControl.Invalidate();

                zedGraphControl.ZoomPane(zedGraphControl.GraphPane, 1.1, PointF.Empty, false);
            }
        }
Пример #2
0
        private static DataBarBox show(string title, string[] labels, double[][] series)
        {
            DataBarBox form       = null;
            Thread     formThread = null;

            if (title == null)
            {
                title = "Bar chart";
            }

            double[] x = Matrix.Indices(0, labels.Length).ToDouble();

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

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

                // Show control in a form
                form            = new DataBarBox();
                form.Text       = title;
                form.formThread = formThread;

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    form.series.Add(new BarItem(i.ToString(), x,
                                                series[i], sequence.GetColor(i)));
                }

                form.zedGraphControl.GraphPane.Title.Text             = title;
                form.zedGraphControl.GraphPane.XAxis.Type             = AxisType.Text;
                form.zedGraphControl.GraphPane.XAxis.Scale.TextLabels = labels;
                form.zedGraphControl.GraphPane.XAxis.Scale.MajorStep  = 1;
                form.zedGraphControl.GraphPane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            return(form);
        }
Пример #3
0
        private static DataSeriesBox show(String title, double[][] series, bool hold)
        {
            DataSeriesBox 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 DataSeriesBox();
                form.Text       = title;
                form.formThread = formThread;

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    form.series.Add(new LineItem(i.ToString(), Matrix.Indices(0, series[i].Length).ToDouble(),
                                                 series[i], sequence.GetColor(i), SymbolType.None));
                }

                form.zedGraphControl.GraphPane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            if (!hold)
            {
                formThread.Join();
            }

            return(form);
        }
Пример #4
0
        /// <summary>
        ///   Forces a update of the scatter plot.
        /// </summary>
        ///
        public void UpdateGraph()
        {
            classes.Clear();

            if (scatterplot.LabelAxis == null)
            {
                // Create space for unlabelled data
                PointPairList unlabelled = new PointPairList(scatterplot.XAxis, scatterplot.YAxis);

                LineItem item = new LineItem(String.Empty, unlabelled, Color.Black, SymbolType.Diamond);

                item.Line.IsVisible          = false;
                item.Symbol.Border.IsVisible = false;
                item.Symbol.Fill             = new Fill(Color.Black);

                classes.Add(item);
            }
            else
            {
                ColorSequenceCollection colors = new ColorSequenceCollection(scatterplot.Classes.Count);

                // Create a curve item for each of the labels
                for (int i = 0; i < scatterplot.Classes.Count; i++)
                {
                    // retrieve the x,y pairs for the label
                    double[]      x    = scatterplot.Classes[i].XAxis;
                    double[]      y    = scatterplot.Classes[i].YAxis;
                    PointPairList list = new PointPairList(x, y);

                    LineItem item = new LineItem(String.Empty, list, colors[i], SymbolType.Diamond);

                    item.Line.IsVisible          = false;
                    item.Symbol.Border.IsVisible = false;
                    item.Symbol.Fill             = new Fill(colors[i]);

                    classes.Add(item);
                }

                zedGraphControl.AxisChange();
                zedGraphControl.Invalidate();
            }
        }
Пример #5
0
        /// <summary>
        ///   Constructs a new instance of the ScatterplotView.
        /// </summary>
        ///
        public ComponentView()
        {
            InitializeComponent();

            zedGraphControl.GraphPane.Title.Text            = "Components";
            zedGraphControl.GraphPane.Title.FontSpec.Size   = 24f;
            zedGraphControl.GraphPane.Title.FontSpec.Family = "Tahoma";

            zedGraphControl.GraphPane.XAxis.Title.Text = "Components";
            zedGraphControl.GraphPane.YAxis.Title.Text = "Percentage";

            zedGraphControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
            zedGraphControl.GraphPane.Border.IsVisible = false;
            zedGraphControl.GraphPane.Border.Color     = Color.White;
            zedGraphControl.GraphPane.Border.Width     = 0;
            zedGraphControl.GraphPane.Fill             = new Fill(Color.White);
            zedGraphControl.GraphPane.Chart.Fill       = new Fill(Color.GhostWhite);

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

            zedGraphControl.GraphPane.XAxis.Scale.MinAuto = true;
            zedGraphControl.GraphPane.XAxis.Scale.MaxAuto = true;
            zedGraphControl.GraphPane.YAxis.Scale.MinAuto = true;
            zedGraphControl.GraphPane.YAxis.Scale.MaxAuto = true;
            zedGraphControl.GraphPane.XAxis.Scale.MagAuto = true;
            zedGraphControl.GraphPane.YAxis.Scale.MagAuto = true;


            zedGraphControl.GraphPane.Chart.Fill.Type  = FillType.None;
            zedGraphControl.GraphPane.Legend.IsVisible = false;

            zedGraphControl.GraphPane.Title.FontSpec.Size   = 24f;
            zedGraphControl.GraphPane.Title.FontSpec.Family = "Tahoma";

            colors = new ColorSequenceCollection();
        }
Пример #6
0
        private static DataSeriesBox show(String title, double[] x, double[][] series,
                                          bool time = false)
        {
            DataSeriesBox form       = null;
            Thread        formThread = null;

            if (title == null)
            {
                title = "Time series";
            }

            x = (double[])x.Clone();
            var idx = Vector.Range(0, x.Length);

            Array.Sort(x, idx);

            for (int i = 0; i < series.Length; i++)
            {
                series[i] = series[i].Get(idx);
            }

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

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

                // Show control in a form
                form            = new DataSeriesBox();
                form.Text       = title;
                form.formThread = formThread;

                var pane = form.zedGraphControl.GraphPane;

                if (time)
                {
                    pane.XAxis.Type            = AxisType.Date;
                    pane.XAxis.Scale.MajorUnit = DateUnit.Hour;
                    pane.XAxis.Scale.Format    = "T";
                }

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    if (x == null)
                    {
                        x = Vector.Range(0, series[i].Length).ToDouble();
                    }

                    var lineItem = new LineItem(i.ToString(), x,
                                                series[i], sequence.GetColor(i), SymbolType.None);

                    form.series.Add(lineItem);
                }

                pane.Title.Text = title;
                pane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            return(form);
        }
Пример #7
0
        private static WavechartBox show(String title, bool hold, params Tuple <Signal, int>[] series)
        {
            WavechartBox 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 WavechartBox();
                form.Text       = title;
                form.formThread = formThread;

                if (!String.IsNullOrEmpty(title))
                {
                    form.zedGraphControl.GraphPane.Title.IsVisible = true;
                    form.zedGraphControl.GraphPane.Title.Text      = title;
                }

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    var signal  = series[i].Item1;
                    int channel = series[i].Item2;

                    ComplexSignal complex = signal as ComplexSignal;

                    if (complex != null && complex.Status != ComplexSignalStatus.Normal)
                    {
                        double[] spectrum    = Accord.Audio.Tools.GetPowerSpectrum(complex.GetChannel(channel));
                        double[] frequencies = Accord.Audio.Tools.GetFrequencyVector(signal.Length, signal.SampleRate);

                        form.series.Add(new LineItem(i.ToString(), frequencies,
                                                     spectrum, sequence.GetColor(i), SymbolType.None));

                        form.zedGraphControl.GraphPane.XAxis.Title.Text = "Frequency";
                        form.zedGraphControl.GraphPane.YAxis.Title.Text = "Power";
                    }
                    else
                    {
                        double[] values;
                        if (signal.Channels == 1)
                        {
                            values = signal.ToDouble();
                        }
                        else
                        {
                            ExtractChannel extract = new ExtractChannel(channel);
                            values = extract.Apply(signal).ToDouble();
                        }

                        form.series.Add(new LineItem(i.ToString(), Matrix.Indices(0, signal.Length).ToDouble(),
                                                     values, sequence.GetColor(i), SymbolType.None));

                        form.zedGraphControl.GraphPane.XAxis.Title.Text = "Time";
                        form.zedGraphControl.GraphPane.YAxis.Title.Text = "Amplitude";
                    }
                }

                form.zedGraphControl.GraphPane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            if (!hold)
            {
                formThread.Join();
            }

            return(form);
        }