本文整理汇总了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);
}
示例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);
}