■ 다크 모드의 캔들 차트를 그리는 방법을 보여준다.
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
using System; using System.Drawing; using System.Linq; using System.Windows.Forms; using ScottPlot; using ScottPlot.Plottable; using ScottPlot.Renderable; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Plot plot = new Plot(800, 600); OHLC[] priceArray = DataGen.RandomStockPrices(null, 100, TimeSpan.FromMinutes(5)); double[] xValueArray = priceArray.Select(x => x.DateTime.ToOADate()).ToArray(); FinancePlot financePlot = plot.AddCandlesticks(priceArray); financePlot.YAxisIndex = 1; plot.XAxis.DateTimeFormat(true); (double[] sma8XValueArray , double[] sma8YValueArray ) = financePlot.GetSMA(8); (double[] sma20XValueArray, double[] sma20YValueArray) = financePlot.GetSMA(20); ScatterPlot sma8ScatterPlot = plot.AddScatterLines(sma8XValueArray , sma8YValueArray , Color.Cyan , 2, label : "8일 SMA" ); ScatterPlot sma20ScatterPlot = plot.AddScatterLines(sma20XValueArray, sma20YValueArray, Color.Yellow, 2, label : "20일 SMA"); sma8ScatterPlot.YAxisIndex = 1; sma20ScatterPlot.YAxisIndex = 1; financePlot.ColorDown = ColorTranslator.FromHtml("#00FF00"); financePlot.ColorUp = ColorTranslator.FromHtml("#FF0000"); plot.Frameless(); plot.Layout(padding : 30); plot.Style(figureBackground : Color.Black, dataBackground : Color.Black); plot.XAxis.MajorGrid(color : ColorTranslator.FromHtml("#333333")); plot.XAxis.TickMarkColor(ColorTranslator.FromHtml("#333333")); plot.XAxis.TickLabelStyle(color : Color.White); plot.YAxis.Grid(false); plot.YAxis.Ticks(false); plot.YAxis2.Grid(true); plot.YAxis2.Ticks(true); plot.YAxis2.MajorGrid(color : ColorTranslator.FromHtml("#333333")); plot.YAxis2.TickMarkColor(ColorTranslator.FromHtml("#333333")); plot.YAxis2.TickLabelStyle(color : ColorTranslator.FromHtml("#00FF00")); Legend legend = plot.Legend(); legend.OutlineColor = Color.Transparent; legend.FillColor = Color.Transparent; legend.Font.Bold = true; legend.Font.Color = Color.White; this.formsPlot.Reset(plot); this.formsPlot.Refresh(); } #endregion } } |