本文整理汇总了C#中DataSeries.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# DataSeries.GetHashCode方法的具体用法?C# DataSeries.GetHashCode怎么用?C# DataSeries.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSeries
的用法示例。
在下文中一共展示了DataSeries.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillWithSampleData
public static void FillWithSampleData(DataSeries series, int numberOfItems, int sum)
{
int localSum = 0;
Random random = new Random((int)(series.GetHashCode() + DateTime.Now.Ticks));
for (int i = 0; i < numberOfItems; i++)
{
int randomNumber = 0;
while (randomNumber <= 0)
randomNumber = random.Next(sum / numberOfItems - 3, sum / numberOfItems + 3);
if (localSum + randomNumber > sum)
randomNumber = sum - localSum;
if ((i == numberOfItems - 1) && (localSum + randomNumber < sum))
randomNumber = sum - localSum;
localSum += randomNumber;
DataPoint dataPoint = new DataPoint();
dataPoint.YValue = randomNumber;
series.Add(dataPoint);
}
}
示例2: FillWithSampleFinancialData
public static void FillWithSampleFinancialData(DataSeries series, int numberOfItems, int numberOfPeaks)
{
Random random = new Random((int)(series.GetHashCode() + DateTime.Now.Ticks));
int[] openArray = new int[numberOfItems];
int[] closeArray = new int[numberOfItems];
int[] maxArray = new int[numberOfItems];
int[] minArray = new int[numberOfItems];
int[] peakIndices = new int[numberOfPeaks];
// Calculate peak indices
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];
//.........这里部分代码省略.........