示例#1
0
        void CreataSampleData(int nser, int npts)
        {
            _chart.BeginUpdate();
            DataSeriesCollection sc = _chart.Data.Children;

            sc.Clear();

            for (int iser = 0; iser < nser; iser++)
            {
                double phase = 0.05 + 0.1 * _rnd.NextDouble();
                double amp   = 1 + 5 * _rnd.NextDouble();

                DataSeries ds   = new DataSeries();
                double[]   vals = new double[npts];
                for (int i = 0; i < npts; i++)
                {
                    vals[i] = amp * Math.Sin(i * phase);
                }

                ds.ValuesSource = vals;
                ds.Label        = "S " + iser.ToString();
                ds.ConnectionStrokeThickness = 2;

                sc.Add(ds);
            }
            _chart.EndUpdate();
        }
示例#2
0
        //static int labelCounter = 0;
        private void AddValuesToPlotData(PlotData[] plotData)
        {
            if (!_HoldOn)
            {
                ClearPlot();
            }

            var customLabel = CustomPlotLabel.Length > 0 ? "[" + CustomPlotLabel + "] " : "";

            foreach (var t in plotData)
            {
                var points = t.Points;
                var title  = customLabel + t.Title;

                Labels.Add(title + customLabel);
                DataSeriesCollection.Add(new DataPointCollection {
                    DataPoints = points, Title = title, ColorTag = "ColorTag"
                });
                //if (DataSeriesCollection.Count > 0 && points[0] is ComplexDataPoint)
                //{
                //    RealLabels.Add(title + "\r(real)" + customLabel);
                //    PhaseLabels.Add(title + "\r(phase)" + customLabel);
                //    ImagLabels.Add(title + "\r(imag)" + customLabel);
                //    AmplitudeLabels.Add(title + "\r(amp)" + customLabel);
                //}
                //else
                //{
                //    Labels.Add(title + customLabel); // has to happen before updating the bound collection
                //}
            }
            PlotTitles.Add(Title);

            UpdatePlotSeries();
        }
        public void ImportLineData(ArrayList values1, ArrayList values2)
        {
            dsc = new DataSeriesCollection();
            DataSeries ds1 = new DataSeries();
            ds1.RenderAs = RenderAs.Line;
            ds1.LegendText = "ObjValue";
            for (int i = 0; i < values1.Count; i = i + 4)
            {
                DataPoint dp = new DataPoint();
                dp.YValue = (double)values1[i];
                dp.XValue = i;
                ds1.DataPoints.Add(dp);
            }

            DataSeries ds2 = new DataSeries();
            ds2.RenderAs = RenderAs.Line;
            ds2.LegendText = "Variance";
            for (int i = 0; i < values2.Count; i = i + 4)
            {
                DataPoint dp = new DataPoint();
                dp.YValue = (double)values2[i];
                dp.XValue = i;
                ds2.DataPoints.Add(dp);
            }
            dsc.Add(ds1);
            dsc.Add(ds2);

        }
        /// <summary>
        /// Submits a matrix of x and y data points. Meaning each data series should process a single collection of x/y data points.
        /// </summary>
        /// <param name="xxxx">X matrix.</param>
        /// <param name="yyyy">Y matrix.</param>
        public void PushData(IEnumerable <IEnumerable <TXDataPoint> > xxxx, IEnumerable <IEnumerable <TYDataPoint> > yyyy)
        {
            if (DataSeriesCollection.Count == 0)
            {
                return;
            }

            IEnumerable <IEnumerable <GraphDataPoint> > xxxxI = xxxx.Select(x => x.ToList()).ToList();
            IEnumerable <IEnumerable <GraphDataPoint> > yyyyI = yyyy.Select(x => x.ToList()).ToList();

            List <List <GraphDataPoint> > xxxxList = xxxxI.Select(x => x.ToList()).ToList();
            List <List <GraphDataPoint> > yyyyList = yyyyI.Select(x => x.ToList()).ToList();

            int first_count_x = xxxxList[0].Count;
            int first_count_y = yyyyList[0].Count;


            bool is_data_valid = true;

            for (int i = 0; i < xxxxList.Count; i++)
            {
                if (xxxxList[0].Count != first_count_x)
                {
                    is_data_valid = false;
                    break;
                }

                if (xxxxList[0].Count != yyyyList[0].Count)
                {
                    is_data_valid = false;
                    break;
                }
            }

            if (!is_data_valid)
            {
                throw new ArgumentOutOfRangeException("When pushing data to a multi series renderer, each series must contain the same amount of data.");
            }

            var list = DataSeriesCollection.ToList();

            var pending_list = new List <PendingSeries>();

            for (int i = 0; i < list.Count; i++)
            {
                pending_list.Add(new PendingSeries()
                {
                    Series = list[i],
                    XX     = xxxxList[i].ToList(),
                    YY     = yyyyList[i].ToList(),
                });
            }

            _pending_series_collection.BlockEnqueue(pending_list);
        }
示例#5
0
 private void ClearPlotSingle()
 {
     if (DataSeriesCollection.Any())
     {
         DataSeriesCollection.RemoveAt(DataSeriesCollection.Count - 1);
         //Clear the PlotSeriesCollection, it will be recreated with the plot
         PlotSeriesCollection.Clear();
         Labels.RemoveAt(Labels.Count - 1);
         PlotTitles.RemoveAt(PlotTitles.Count - 1);
         PlotModel.Title = "";
     }
 }
示例#6
0
 private void ClearPlot()
 {
     DataSeriesCollection.Clear();
     PlotSeriesCollection.Clear();
     Labels.Clear();
     PlotTitles.Clear();
     PlotModel.Title = "";
     foreach (var axis in PlotModel.Axes)
     {
         axis.Reset();
     }
 }
        public void ImportLineData(ArrayList values1, ArrayList values2, ArrayList values4)
        {
            dsc = new DataSeriesCollection();
            DataSeries ds1 = new DataSeries();

            ds1.RenderAs   = RenderAs.Line;
            ds1.LegendText = "Sum";
            for (int i = 0; i < values1.Count; i = i + 4)
            {
                DataPoint dp = new DataPoint();
                dp.YValue = (double)values1[i];
                dp.XValue = i;
                ds1.DataPoints.Add(dp);
            }

            DataSeries ds2 = new DataSeries();

            ds2.RenderAs   = RenderAs.Line;
            ds2.LegendText = "Average";
            for (int i = 0; i < values2.Count; i = i + 4)
            {
                DataPoint dp = new DataPoint();
                dp.YValue = (double)values2[i];
                dp.XValue = i;
                ds2.DataPoints.Add(dp);
            }
            //DataSeries ds3 = new DataSeries();
            //ds3.RenderAs = RenderAs.Line;
            //ds3.LegendText = "Variance";
            //for (int i = 0; i < values3.Count; i = i + 4)
            //{
            //    DataPoint dp = new DataPoint();
            //    dp.YValue = (double)values3[i];
            //    dp.XValue = i;
            //    ds3.DataPoints.Add(dp);
            //}
            DataSeries ds4 = new DataSeries();

            ds4.RenderAs   = RenderAs.Line;
            ds4.LegendText = "ObjValue";
            for (int i = 0; i < values4.Count; i = i + 4)
            {
                DataPoint dp = new DataPoint();
                dp.YValue = (double)values4[i];
                dp.XValue = i;
                ds4.DataPoints.Add(dp);
            }
            dsc.Add(ds1);
            dsc.Add(ds2);
            //dsc.Add(ds3);
            dsc.Add(ds4);
        }
        public void ImportLineData(ArrayList values)
        {
            dsc = new DataSeriesCollection();
            DataSeries ds = new DataSeries();
            ds.RenderAs = RenderAs.Line;
            foreach (Object value in values)
            {
                DataPoint dp = new DataPoint();
                dp.YValue = (double)value;
                ds.DataPoints.Add(dp);
            }

            dsc.Add(ds);

        }
        public void ImportLineData(ArrayList values)
        {
            dsc = new DataSeriesCollection();
            DataSeries ds = new DataSeries();

            ds.RenderAs = RenderAs.Line;
            foreach (Object value in values)
            {
                DataPoint dp = new DataPoint();
                dp.YValue = (double)value;
                ds.DataPoints.Add(dp);
            }

            dsc.Add(ds);
        }
示例#10
0
        private DataSeriesCollection GetAvgSDSeriseCollection(List <List <double> > dataLists)
        {
            DataSeriesCollection dsc = new DataSeriesCollection()
            {
                GetAvgSDSeries(dataLists[2], true, "2sd", twoSDBrush, RenderAs.Area),
                GetAvgSDSeries(dataLists[1], true, "1sd", oneSDBrush, RenderAs.Area),
                GetAvgSDSeries(dataLists[3], true, "-1sd", fOneSDBrush, RenderAs.Area),
                GetAvgSDSeries(dataLists[4], true, "-2sd", fTwoSDBrush, RenderAs.Area),
                GetAvgSDSeries(dataLists[0], true, "平均", avgBrush, RenderAs.QuickLine)
            };

            return(dsc);
            //DataSeries avgSerise =
            //DataSeries sd2Serise =
            //dsc.Add(sd2Serise);//平均曲线
            //AddAvgSeries(chart, dataLists[1], true, "1sd", null);//平均曲线
            //AddAvgSeries(chart, dataLists[3], true, "-1sd", fOneSDBrush);//平均曲线
            //AddAvgSeries(chart, dataLists.Last(), true, "-2sd", fTwoSDBrush);//平均曲线
            //AddSeries(chart, dataLists[0], true, "平均", null);
        }
示例#11
0
        private void MonthChart(IEnumerable <ProductivityModel> productivityModels)
        {
            var dataSeries = new DataSeriesCollection();
            var recruiters = Recruiter == null ? Recruiters : Recruiters.Where(r => r.Id == Recruiter.Id);

            foreach (var recruiter in recruiters)
            {
                var items = productivityModels.Where(p => p.RecruiterFullName == recruiter.FullName);
                if (items.Any())
                {
                    var series = new DataSeries {
                        LegendText = recruiter.FullName, RenderAs = RenderAs.Column
                    };
                    IEnumerable <DataPoint> dataPoints;
                    dataPoints = !string.IsNullOrEmpty(Week)
                                         ? items.GroupBy(i => i.Week,
                                                         (k, g) => new DataPoint
                    {
                        YValue     = g.Count(),
                        AxisXLabel = k
                    })
                                         : items.GroupBy(i => i.Month,
                                                         (k, g) => new DataPoint
                    {
                        YValue     = g.Count(),
                        AxisXLabel = k
                    });
                    foreach (var point in dataPoints)
                    {
                        series.DataPoints.Add(point);
                    }
                    dataSeries.Add(series);
                }
            }

            ChartSource = dataSeries;
            if (ChartUpdated != null)
            {
                ChartUpdated(this, EventArgs.Empty);
            }
        }
        //static int labelCounter = 0;
        private void AddValuesToPlotData(PlotData[] plotData)
        {
            if (!_HoldOn)
            {
                ClearPlot();
            }

            foreach (var t in plotData)
            {
                var points = t.Points;
                var title  = t.Title;

                Labels.Add(title);
                DataSeriesCollection.Add(new DataPointCollection
                {
                    DataPoints = points,
                    Title      = title,
                    ColorTag   = "ColorTag"
                });
                PlotTitles.Add(Title);
            }
            UpdatePlotSeries();
        }
        /// <summary>
        /// Submits the specified collections of x and y data points.
        /// If the controller has more than one data series the data points will be distributed evenly.
        /// </summary>
        /// <param name="xx">X data point collection.</param>
        /// <param name="yy">Y data point collection.</param>
        public void PushData(IEnumerable <TXDataPoint> xx, IEnumerable <TYDataPoint> yy)
        {
            if (DataSeriesCollection.Count == 0)
            {
                return;
            }

            var xList = xx.ToList();
            var yList = yy.ToList();

            List <List <TXDataPoint> > xxxx = new List <List <TXDataPoint> >();
            List <List <TYDataPoint> > yyyy = new List <List <TYDataPoint> >();

            foreach (var series in DataSeriesCollection.ToList())
            {
                xxxx.Add(new List <TXDataPoint>());
                yyyy.Add(new List <TYDataPoint>());
            }

            int counter = 0;

            for (int i = 0; i < xList.Count; i++)
            {
                xxxx[counter].Add(xList[i]);
                yyyy[counter].Add(yList[i]);

                counter++;

                if (counter >= xxxx.Count)
                {
                    counter = 0;
                }
            }

            PushData(xxxx, yyyy);
        }
        /// <summary>
        /// Submits the specified x and y data points.
        /// If the controller has more than one data series the data points will be duplicated.
        /// </summary>
        /// <param name="x">X data point.</param>
        /// <param name="y">Y data point.</param>
        public void PushData(TXDataPoint x, TYDataPoint y)
        {
            if (DataSeriesCollection.Count == 0)
            {
                return;
            }

            List <List <TXDataPoint> > xxxx = new List <List <TXDataPoint> >();
            List <List <TYDataPoint> > yyyy = new List <List <TYDataPoint> >();

            foreach (var series in DataSeriesCollection.ToList())
            {
                xxxx.Add(new List <TXDataPoint>()
                {
                    x
                });
                yyyy.Add(new List <TYDataPoint>()
                {
                    y
                });
            }

            PushData(xxxx, yyyy);
        }
示例#15
0
 private void SeriesAdded(DataSeries series)
 {
     this.FirePropertyChanged("DataSeriesCollection");
     series.DataPoints.Added.SubscribeForLifetime(DataPointRemoved, DataSeriesCollection.GetMembershipLifetime(series));
     ResetFocusedSeries();
 }
示例#16
0
 private DataSeriesCollection GetAvgSDSeriseCollection( List<List<double>> dataLists)
 {
     DataSeriesCollection dsc = new DataSeriesCollection()
     {
         GetAvgSDSeries(dataLists[2], true, "2sd", twoSDBrush,RenderAs.Area),
         GetAvgSDSeries(dataLists[1], true, "1sd", oneSDBrush,RenderAs.Area),
         GetAvgSDSeries(dataLists[3], true, "-1sd", fOneSDBrush,RenderAs.Area),
         GetAvgSDSeries(dataLists[4], true, "-2sd", fTwoSDBrush,RenderAs.Area),
        GetAvgSDSeries(dataLists[0], true, "平均", avgBrush,RenderAs.QuickLine)
      };
     return dsc;
     //DataSeries avgSerise =
     //DataSeries sd2Serise =
     //dsc.Add(sd2Serise);//平均曲线
     //AddAvgSeries(chart, dataLists[1], true, "1sd", null);//平均曲线
     //AddAvgSeries(chart, dataLists[3], true, "-1sd", fOneSDBrush);//平均曲线
     //AddAvgSeries(chart, dataLists.Last(), true, "-2sd", fTwoSDBrush);//平均曲线
     //AddSeries(chart, dataLists[0], true, "平均", null);
 }
示例#17
0
        public void UpdateChart()
        {
            chart1.Series.Clear();
            chart2.Series.Clear();
            if (CurrentStandardInfo == null || modelList == null || modelList?.Count == 0)
            {
                return;
            }
            Task task = new Task(() =>
            {
                if (CurrentStandardInfo.Tag == -1)//导入的参考值
                {
                    Model.ExportStandModel standModel        = Stand.StandConfig.GetStandModel(CurrentStandardInfo.StandFileName);
                    List <List <double> > oddavgsd           = standModel.OddAvgSD;
                    List <List <double> > evenavgsd          = standModel.EvenAvgSD;
                    DataSeriesCollection oddAvgSDCollection  = GetAvgSDSeriseCollection(oddavgsd);
                    DataSeriesCollection evenAvgSDCollection = GetAvgSDSeriseCollection(evenavgsd);
                    Dispatcher.Invoke(new Action(() =>
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            var oddItem = oddAvgSDCollection[i];
                            chart1.Series.Add(oddItem);
                            var evenItem = evenAvgSDCollection[i];
                            chart2.Series.Add(evenItem);
                        }
                    }));
                }
                else
                {
                    Dictionary <DataPointsType, List <List <double> > > dataDict = null;
                    if (dataPointsDict.Keys.Contains(CurrentStandardInfo.ID))
                    {
                        dataDict = dataPointsDict[CurrentStandardInfo.ID];
                        if (dataDict[DataPointsType.ODD].Count != modelList.Count)
                        {
                            dataDict = StandardChartCache.GetStandardDataPoints(CurrentStandardInfo, modelList);
                            dataPointsDict[CurrentStandardInfo.ID] = dataDict;
                        }
                    }
                    else
                    {
                        dataDict = StandardChartCache.GetStandardDataPoints(CurrentStandardInfo, modelList);
                        dataPointsDict.Add(CurrentStandardInfo.ID, dataDict);
                    }


                    if (!oddAvgSDSeriseDict.Keys.Contains(CurrentStandardInfo.ID))
                    {
                        List <List <double> > oddavgsd  = dataDict[DataPointsType.ODDAvgSD];
                        List <List <double> > evenavgsd = dataDict[DataPointsType.EVENAVGSD];
                        oddAvgSDSeriseDict.Add(CurrentStandardInfo.ID, GetAvgSDSeriseCollection(oddavgsd));
                        evenAvgSDSeriseDict.Add(CurrentStandardInfo.ID, GetAvgSDSeriseCollection(evenavgsd));
                    }
                    Dispatcher.Invoke(new Action(() =>
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            var oddItem = oddAvgSDSeriseDict[CurrentStandardInfo.ID][i];
                            chart1.Series.Add(oddItem);
                            var evenItem = evenAvgSDSeriseDict[CurrentStandardInfo.ID][i];
                            chart2.Series.Add(evenItem);
                        }
                    }));
                }
            });

            task.Start();
        }
        private void MonthChart(IEnumerable<ProductivityModel> productivityModels)
        {
            var dataSeries = new DataSeriesCollection();
            var recruiters = Recruiter == null ? Recruiters : Recruiters.Where(r => r.Id == Recruiter.Id);
            foreach (var recruiter in recruiters)
            {
                var items = productivityModels.Where(p => p.RecruiterFullName == recruiter.FullName);
                if (items.Any())
                {
                    var series = new DataSeries { LegendText = recruiter.FullName, RenderAs = RenderAs.Column };
                    IEnumerable<DataPoint> dataPoints;
                    dataPoints = !string.IsNullOrEmpty(Week)
                                         ? items.GroupBy(i => i.Week,
                                                         (k, g) => new DataPoint
                                                         {
                                                             YValue = g.Count(),
                                                             AxisXLabel = k
                                                         })
                                         : items.GroupBy(i => i.Month,
                                                         (k, g) => new DataPoint
                                                         {
                                                             YValue = g.Count(),
                                                             AxisXLabel = k
                                                         });
                    foreach (var point in dataPoints) series.DataPoints.Add(point);
                    dataSeries.Add(series);
                }
            }

            ChartSource = dataSeries;
            if (ChartUpdated != null) ChartUpdated(this, EventArgs.Empty);
        }
示例#19
0
        /// <summary>
        /// Initializes the various properties of the class
        /// </summary>
        private void Init()
        {
            // Initialize colorSets
            //ColorSets = new ColorSets();

            // Initialize tooltip
            ToolTips = new ToolTipCollection();

            // Initialize title list
            Titles = new TitleCollection();

            // Initialize legend list
            Legends = new LegendCollection();

            // Initialize trendLine list
            TrendLines = new TrendLineCollection();

            // Initialize AxesX list
            AxesX = new AxisCollection();

            // Initialize AxesY list
            AxesY = new AxisCollection();

            // Initialize Series list
            Series = new DataSeriesCollection();

            // Initialize PlotArea
            PlotArea = new PlotArea() { Chart = this };

            // Attach event handler on collection changed event with ToolTip collection
            ToolTips.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ToolTips_CollectionChanged);

            // Attach event handler on collection changed event with Title collection
            Titles.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Titles_CollectionChanged);

            // Attach event handler on collection changed event with Legend collection
            Legends.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Legends_CollectionChanged);

            // Attach event handler on collection changed event with TrendLines collection
            TrendLines.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(TrendLines_CollectionChanged);

            // Attach event handler on collection changed event with DataSeries collection
            Series.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Series_CollectionChanged);

            // Attach event handler on collection changed event with axisX collection
            (AxesX as AxisCollection).CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(AxesX_CollectionChanged);

            // Attach event handler on collection changed event with AxisY collection
            (AxesY as AxisCollection).CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(AxesY_CollectionChanged);
        }