/// <summary> /// <see cref="ChartItemCollection.CopyAndAdjustItemValue(ChartItem, CoordinateType)"/> /// </summary> public override ChartItem CopyAndAdjustItemValue(ChartItem item, CoordinateType coordinateType) { MultipleChartItem mItem = item as MultipleChartItem; if (mItem == null) { return(mItem); } var copyItem = new MultipleChartItem() { Value = (coordinateType == CoordinateType.Log10 && IsValueValid(mItem.Value)) ? Math.Pow(10, mItem.Value) : mItem.Value, ValueChange = mItem.ValueChange, Date = mItem.Date, ExtraData = mItem.ExtraData, Values = new List <double>(iValuePointLength), ValueChanges = mItem.ValueChanges != null ? new List <double>(iValuePointLength) : null }; for (int j = 0; j < iValuePointLength; j++) { copyItem.Values.Add((coordinateType == CoordinateType.Log10 && IsValueValid(mItem.Values[j])) ? Math.Pow(10, mItem.Values[j]) : mItem.Values[j]); if (mItem.ValueChanges != null) { copyItem.ValueChanges.Add(mItem.ValueChanges[j]); } } return(copyItem); }
/// <summary> /// <see cref="ChartItemCollection.FindMaxAndMinIndex"/> /// </summary> protected override void FindMaxAndMinIndex() { if (coordinateType != CoordinateType.Percentage) { double max = double.MinValue, min = double.MaxValue; for (int i = iStartPosition; i < iStartPosition + points.Length; i++) { MultipleChartItem item = Items[i] as MultipleChartItem; if (!IsItemValid(Items[i])) { continue; } if (IsValueValid(item.Value)) { if (item.Value > max) { iMaxPosition = i - iStartPosition; iMaxPositionInner = -1; max = item.Value; } if (item.Value < min) { iMinPosition = i - iStartPosition; iMinPositionInner = -1; min = item.Value; } } for (int j = 0; j < item.Values.Count; j++) { var value = item.Values[j]; if (IsValueValid(value)) { if (value > max) { iMaxPosition = i - iStartPosition; iMaxPositionInner = j; max = value; } if (value < min) { iMinPosition = i - iStartPosition; iMinPositionInner = j; min = value; } } } } } else { FindMaxMin4PercentageCoordiate(); } }
/// <summary> /// <see cref="ChartItemCollection.ConvertChartItemLog10(ChartItem)"/> /// </summary> protected override void ConvertChartItemLog10(ChartItem item) { MultipleChartItem mItem = item as MultipleChartItem; if (IsValueValid(mItem.Value)) { mItem.Value = Math.Log10(mItem.Value); } for (int j = 0; j < iValuePointLength; j++) { if (IsValueValid(mItem.Values[j])) { mItem.Values[j] = Math.Log10(mItem.Values[j]); } } }
private MultipleChartItem GetStartItem(int j) { MultipleChartItem resukltItem = null; if (j == -1) { for (int i = iStartPosition; i < iStartPosition + points.Length; i++) { MultipleChartItem item = Items[i] as MultipleChartItem; if (!IsItemValid(Items[i])) { continue; } if (IsValueValid(item.Value)) { resukltItem = item; break; } } } else { for (int i = iStartPosition; i < iStartPosition + points.Length; i++) { MultipleChartItem item = Items[i] as MultipleChartItem; if (!IsItemValid(Items[i])) { continue; } if (IsValueValid(item.Values[j])) { resukltItem = item; break; } } } return(resukltItem); }
/// <summary> /// <see cref="ChartItemCollection.ConvertFrom(QueryItem)"/> /// </summary> public override ChartItem ConvertFrom(QueryItem queryItem) { MultipleChartItem item = new MultipleChartItem() { Date = queryItem.Date }; if (queryItem.Close != null) { item.Value = queryItem.Close.Value; } if (queryItem.Values != null) { item.Values = new List <double>(queryItem.Values.Length); item.Values.AddRange(queryItem.Values); } return(item); }
private void FindMaxMin4PercentageCoordiate() { int iMax = -1; double max = double.MinValue, min = double.MaxValue; int[] iMaxs = new int[iValuePointLength]; for (int i = 0; i < iMaxs.Length; i++) { iMaxs[i] = -1; } double[] maxs = new double[iValuePointLength]; for (int i = 0; i < maxs.Length; i++) { maxs[i] = double.MinValue; } int iMin = -1; int[] iMins = new int[iValuePointLength]; for (int i = 0; i < iMins.Length; i++) { iMins[i] = -1; } double[] mins = new double[iValuePointLength]; for (int i = 0; i < mins.Length; i++) { mins[i] = double.MaxValue; } for (int i = iStartPosition; i < iStartPosition + points.Length; i++) { MultipleChartItem item = Items[i] as MultipleChartItem; if (!IsItemValid(Items[i])) { continue; } if (IsValueValid(item.Value)) { if (item.Value > max) { iMax = i - iStartPosition; max = item.Value; } if (item.Value < min) { iMin = i - iStartPosition; min = item.Value; } } for (int j = 0; j < item.Values.Count; j++) { var value = item.Values[j]; if (IsValueValid(value)) { if (value > maxs[j]) { iMaxs[j] = i - iStartPosition; maxs[j] = value; } if (value < mins[j]) { iMins[j] = i - iStartPosition; mins[j] = value; } } } } var itemStart = GetStartItem(-1); if (itemStart != null) { max = (max - itemStart.Value) / itemStart.Value; min = (min - itemStart.Value) / itemStart.Value; iMaxPosition = iMax; iMaxPositionInner = -1; iMinPosition = iMin; iMinPositionInner = -1; } for (int j = 0; j < iValuePointLength; j++) { itemStart = GetStartItem(j); var jMax = (maxs[j] - itemStart.Values[j]) / itemStart.Values[j]; var jMin = (mins[j] - itemStart.Values[j]) / itemStart.Values[j]; if (jMax > max) { max = jMax; iMaxPosition = iMaxs[j]; iMaxPositionInner = j; } if (jMin < min) { min = jMin; iMinPosition = iMins[j]; iMinPositionInner = j; } } }