/// <summary> /// Determine the value for any minor tic. /// </summary> /// <remarks> /// This method properly accounts for <see cref="Scale.IsLog"/>, <see cref="Scale.IsText"/>, /// and other axis format settings. /// </remarks> /// <param name="baseVal"> /// The value of the first major tic (floating point double). This tic value is the base /// reference for all tics (including minor ones). /// </param> /// <param name="iTic"> /// The major tic number (0 = first major tic). For log scales, this is the actual power of 10. /// </param> /// <returns> /// The specified minor tic value (floating point double). /// </returns> override internal double CalcMinorTicValue(double baseVal, int iTic) { XDate xDate = new XDate(baseVal); switch (_minorUnit) { case DateUnit.Year: default: xDate.AddYears((double)iTic * _minorStep); break; case DateUnit.Month: xDate.AddMonths((double)iTic * _minorStep); break; case DateUnit.Day: xDate.AddDays((double)iTic * _minorStep); break; case DateUnit.Hour: xDate.AddHours((double)iTic * _minorStep); break; case DateUnit.Minute: xDate.AddMinutes((double)iTic * _minorStep); break; case DateUnit.Second: xDate.AddSeconds((double)iTic * _minorStep); break; } return(xDate.XLDate); }
public JapaneseCandleStickDemo() : base("Demonstration of the Japanese Candlestick Chart Type", "Japanese CandleStick Demo", DemoType.Bar) { GraphPane myPane = base.GraphPane; myPane.Title.Text = "UER/USD(欧/日)"; myPane.XAxis.Title.Text = "交易日期"; myPane.YAxis.Title.Text = "价格, $¥"; StockPointList spl = new StockPointList(); Random rand = new Random(); // First day is jan 1st XDate xDate = new XDate(2002, 12, 1); double open = 50.0; for (int i = 0; i < 50; i++) { double x = xDate.XLDate; double close = open + rand.NextDouble() * 10.0 - 5.0; double hi = Math.Max(open, close) + rand.NextDouble() * 5.0; double low = Math.Min(open, close) - rand.NextDouble() * 3.0; StockPt pt = new StockPt(x, hi, low, open, close, 100); spl.Add(pt); open = close; xDate.AddHours(1); if (XDate.XLDateToDayOfWeek(xDate.XLDate) == 6) { xDate.AddDays(1.0); } } JapaneseCandleStickItem myCurve = myPane.AddJapaneseCandleStick("蜡烛线", spl); myCurve.Stick.IsAutoSize = true; myCurve.Stick.Color = Color.Blue; myPane.XAxis.Type = AxisType.DateAsOrdinal; myPane.XAxis.Scale.Min = new XDate(2006, 1, 1); myPane.Chart.Fill = new Fill(Color.Black, Color.LightGoldenrodYellow, 45.0f); myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f); //myPane.Chart.Fill = new Fill(Color.Black); //myPane.Fill = new Fill(Color.Black); base.ZedGraphControl.AxisChange(); }
private void button2_Click(object sender, EventArgs e) { XDate toDate = DateTime.Now; XDate fromDate = toDate; fromDate.AddHours(-5); IEnumerable <UnitData> q; dbl.GetDataAtTime(fromDate, toDate, 2, out q); textBox1.Text = ""; foreach (var i in q) { textBox1.AppendText(string.Format("{0} \t{1} \t{2}\r\n", ((XDate)i.Time).DateTime.ToLongTimeString(), i.GetValue(0), i.GetValue(1))); } }
/// <summary> /// 计算某主刻度值 /// </summary> /// <param name="baseVal"></param> /// <param name="tic"></param> /// <returns></returns> private double CalcMajorTicValue(double baseVal, double tic) { XDate xDate = new XDate(baseVal); switch (_majorUnit) { case DateUnit.Year: default: xDate.AddYears(tic * _majorStep); break; case DateUnit.Month: xDate.AddMonths(tic * _majorStep); break; case DateUnit.Day: xDate.AddDays(tic * _majorStep); break; case DateUnit.Hour: xDate.AddHours(tic * _majorStep); break; case DateUnit.Minute: xDate.AddMinutes(tic * _majorStep); break; case DateUnit.Second: xDate.AddSeconds(tic * _majorStep); break; case DateUnit.Millisecond: xDate.AddMilliseconds(tic * _majorStep); break; } return(xDate.XLDate); }