本文整理汇总了C#中ZedGraph.GraphPane.AddOHLCBar方法的典型用法代码示例。如果您正苦于以下问题:C# GraphPane.AddOHLCBar方法的具体用法?C# GraphPane.AddOHLCBar怎么用?C# GraphPane.AddOHLCBar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZedGraph.GraphPane
的用法示例。
在下文中一共展示了GraphPane.AddOHLCBar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBarWidth_NonOrdinalAxisIntradayValues_2Pixels
public void GetBarWidth_NonOrdinalAxisIntradayValues_2Pixels()
{
GraphPane myPane = new GraphPane();
myPane.Rect = new RectangleF(0, 0, 640f, 480f);
myPane.XAxis.Type = AxisType.Date;
StockPointList spl = CreateStockPointList(5);
OHLCBarItem myCurve = myPane.AddOHLCBar("trades", spl, Color.Black);
AxisChangeAndDraw(myPane);
Assert.That(myCurve.Bar.GetBarWidth(myPane, myPane.XAxis, 1.0f), Is.EqualTo(2f));
}
示例2: DrawOHLCGraph
/// <summary>
/// Draws the Open High Low Close graph.
/// </summary>
/// <param name="data">The stock points to plot.</param>
/// <param name="control">The control to plot on.</param>
public void DrawOHLCGraph(ref StockPoints data, ref ZedGraph.ZedGraphControl control)
{
StockPointList pointList = new StockPointList();
XDate date = new XDate();
foreach (StockPoint s in data)
{
date = new XDate(s.PointDateTime.Year, s.PointDateTime.Month, s.PointDateTime.Day, s.PointDateTime.Hour, s.PointDateTime.Minute, 0);
StockPt p = new StockPt(date.XLDate, s.High, s.Low, s.Open, s.Close, s.Volume);
pointList.Add(p);
}
Color[] colors = { Color.Red, Color.Black };
Fill myFill = new Fill(colors);
myFill.Type = FillType.GradientByColorValue;
myFill.SecondaryValueGradientColor = Color.Empty;
myFill.RangeMin = 1;
myFill.RangeMax = 2;
MasterPane masterPane = control.MasterPane;
masterPane.Margin.All = 10;
masterPane.InnerPaneGap = 5;
GraphPane ohlcPane = new GraphPane(new Rectangle(10, 10, 10, 10), "OHLC", "Time", "Price");
ohlcPane.IsBoundedRanges = true;
OHLCBarItem bar = ohlcPane.AddOHLCBar("Price", pointList, Color.Empty);
bar.Bar.GradientFill = myFill;
bar.Bar.IsAutoSize = true;
bar.Bar.Size = 5;
ohlcPane.Title.Text = "OHLC Graph";
ohlcPane.XAxis.Type = AxisType.DateAsOrdinal;
ohlcPane.XAxis.Title.Text = "Date";
ohlcPane.YAxis.Title.Text = "Price";
ohlcPane.Margin.All = 0;
ohlcPane.Margin.Top = 10;
ohlcPane.YAxis.MinSpace = 10;
ohlcPane.Y2Axis.MinSpace = 10;
ohlcPane.AxisChange();
masterPane.Add(ohlcPane);
control.IsShowHScrollBar = true;
control.ScrollMinX = 0;
control.ScrollMaxX = data.Count;
control.GraphPane.XAxis.Scale.Max = data.Count;
if (data.Count >= 99)
{
control.GraphPane.XAxis.Scale.Min = data.Count - 99;
}
else
{
control.GraphPane.XAxis.Scale.Min = 0;
}
using (Graphics g = control.CreateGraphics())
{
masterPane.SetLayout(g, PaneLayout.SingleColumn);
masterPane.AxisChange(g);
// Synchronize the Axes
//// g.Dispose();
}
}