当前位置: 首页>>代码示例>>C#>>正文


C# DataSeries.AddRange方法代码示例

本文整理汇总了C#中DataSeries.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# DataSeries.AddRange方法的具体用法?C# DataSeries.AddRange怎么用?C# DataSeries.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataSeries的用法示例。


在下文中一共展示了DataSeries.AddRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainWindow

 public MainWindow()
 {
     InitializeComponent();
     DataSeries data = new DataSeries();
     data.AddRange(new List<DataPoint>()
     {
         new DataPoint { XValue = 1, YValue = 1 },
         new DataPoint { XValue = 2, YValue = 5 },
         new DataPoint { XValue = 3, YValue = 6 },
         new DataPoint { XValue = 4, YValue = 9 },
         new DataPoint { XValue = 5, YValue = 5 },
         new DataPoint { XValue = 6, YValue = 7 },
         new DataPoint { XValue = 7, YValue = 12 },
         new DataPoint { XValue = 8, YValue = 10 },
     });
     data.Definition = new LineSeriesDefinition();
     this.radChart.DefaultView.ChartArea.DataSeries.Add(data);
 }
开发者ID:CJMarsland,项目名称:xaml-sdk,代码行数:18,代码来源:MainWindow.xaml.cs

示例2: FillWithSampleFinancialData


//.........这里部分代码省略.........
            for (int i = 1; i <= numberOfPeaks; i++)
            {
                peakIndices[i - 1] = Math.Min(i * numberOfItems / numberOfPeaks, numberOfItems - 1);
            }

            bool trend = false;

            int currentIndex = 0;
            int startValue = 20;

            //Calculate open close values
            for (int j = 0; j < numberOfPeaks; j++)
            {
                trend = !trend;

                int peakIndex = numberOfItems - 1;

                try
                {
                    peakIndex = peakIndices[j];
                }
                catch { }

                for (int k = currentIndex + 1; k <= peakIndex; k++, currentIndex++)
                {
                    int factor = random.Next(1, 5) ;

                    if (trend)
                    {
                        openArray[k] = random.Next(Math.Abs(startValue + factor), Math.Abs(startValue + (int)1.1 * factor));
                    }
                    else
                    {
                        int min = Math.Min(Math.Abs(startValue - factor), Math.Abs(startValue - (int)1.1 * factor));
                        int max = Math.Max(Math.Abs(startValue - (int)1.1 * factor), Math.Abs(startValue - factor));

                        openArray[k] = random.Next(min, max);
                    }
                    closeArray[k - 1] = openArray[k];
                }
            }

            openArray[0] = random.Next(startValue, closeArray[0]);
            closeArray[numberOfItems - 1] = random.Next(openArray[numberOfItems - 1], openArray[numberOfItems - 1] + 15);

            random = new Random((int)(series.GetHashCode() + DateTime.Now.Ticks));

            //Calculate high values
            for (int i = 0; i < numberOfItems; i++)
            {
                int max = Math.Max(openArray[i], closeArray[i]);
                int abs = Math.Abs(openArray[i] - closeArray[i]);

                do
                {
                    maxArray[i] = random.Next(max + 1, max + 3 );
                }
                while (maxArray[i] <= max);
            }

            //Calculate low values
            for (int i = 0; i < numberOfItems; i++)
            {
                int min = Math.Min(openArray[i], closeArray[i]);

                Debug.Assert(min >= 0, "Open or close value is negative");

                int abs = Math.Abs(openArray[i] - closeArray[i]);

                do
                {
                    if (min > 0)
                        minArray[i] = Math.Abs(random.Next(min - 3 , min - 1));
                    else
                        minArray[i] = 0;
                }
                while ( minArray[i] > min || minArray[i] < 0);
            }

            List<DataPoint> randomPoints = new List<DataPoint>();

            for (int i = 0; i < numberOfItems; i++)
            {
                DataPoint point = new DataPoint();
                point.Open = openArray[i];
                point.Close = closeArray[i];
                point.Low = minArray[i];
                point.High = maxArray[i];

                randomPoints.Add(point);
            }

            IEnumerable<DataPoint> invalid = from r in randomPoints
                                             where r.Low < 0 || r.Open < 0 || r.High < 0 || r.Close < 0
                                             select r;

            Debug.Assert(invalid.Count() == 0, "The generated data contains negative values.");

            series.AddRange(randomPoints);
        }
开发者ID:nitinr708,项目名称:ProwarenessDashboard,代码行数:101,代码来源:SeriesExtensions.cs


注:本文中的DataSeries.AddRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。