public override void ViewDidLoad() { base.ViewDidLoad(); TKChart chart = new TKChart(this.ExampleBounds); chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview(chart); var xAxis = new TKChartDateTimeCategoryAxis(); var formatter = new NSDateFormatter(); formatter.DateFormat = "d MMM"; xAxis.LabelFormatter = formatter; xAxis.Style.MajorTickStyle.TicksOffset = -3; xAxis.Style.MajorTickStyle.TicksHidden = false; xAxis.Style.MajorTickStyle.TicksWidth = 1.5f; xAxis.Style.MajorTickStyle.TicksFill = new TKSolidFill(new UIColor(203 / 255.0f, 203 / 255.0f, 203 / 255.0f, 1f)); xAxis.Style.MajorTickStyle.MaxTickClippingMode = TKChartAxisClippingMode.Visible; xAxis.PlotMode = TKChartAxisPlotMode.BetweenTicks; var yAxis = new TKChartNumericAxis(new NSNumber(320), new NSNumber(360)); yAxis.MajorTickInterval = 20; var series = new TKChartCandlestickSeries(StockDataPoint.LoadStockPoints(10).ToArray()); series.GapLength = 0.6f; series.XAxis = xAxis; chart.YAxis = yAxis; chart.AddSeries(series); }
void snippet1() { // >> chart-candlestick-cs var openPrices = new [] { 100, 125, 69, 99, 140, 125 }; var closePrices = new [] { 85, 65, 135, 120, 80, 136 }; var lowPrices = new [] { 50, 60, 65, 55, 75, 90 }; var highPrices = new [] { 129, 142, 141, 123, 150, 161 }; var dateNow = NSDate.Now; var financialDataPoints = new List <TKChartFinancialDataPoint> (); for (int i = 0; i < openPrices.Length; ++i) { var date = dateNow.AddSeconds((double)(60 * 60 * 24 * i)); financialDataPoints.Add(new TKChartFinancialDataPoint(date, new NSNumber(openPrices [i]), new NSNumber(highPrices [i]), new NSNumber(lowPrices [i]), new NSNumber(closePrices [i]), null)); } var candlestickSeries = new TKChartCandlestickSeries(financialDataPoints.ToArray()); chart.AddSeries(candlestickSeries); var xAxis = chart.XAxis as TKChartDateTimeAxis; xAxis.MinorTickIntervalUnit = TKChartDateTimeAxisIntervalUnit.Days; xAxis.PlotMode = TKChartAxisPlotMode.BetweenTicks; xAxis.MajorTickInterval = 1.0; // << chart-candlestick-cs }
public override void ViewDidLoad () { base.ViewDidLoad (); TKChart chart = new TKChart (this.View.Bounds); chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview (chart); var xAxis = new TKChartDateTimeCategoryAxis (); var formatter = new NSDateFormatter (); formatter.DateFormat = "d MMM"; xAxis.LabelFormatter = formatter; xAxis.Style.MajorTickStyle.TicksOffset = -3; xAxis.Style.MajorTickStyle.TicksHidden = false; xAxis.Style.MajorTickStyle.TicksWidth = 1.5f; xAxis.Style.MajorTickStyle.TicksFill = new TKSolidFill (new UIColor (203 / 255.0f, 203 / 255.0f, 203 / 255.0f, 1f)); xAxis.Style.MajorTickStyle.MaxTickClippingMode = TKChartAxisClippingMode.Visible; xAxis.PlotMode = TKChartAxisPlotMode.BetweenTicks; var yAxis = new TKChartNumericAxis (new NSNumber(320), new NSNumber(360)); yAxis.MajorTickInterval = 20; var series = new TKChartCandlestickSeries(StockDataPoint.LoadStockPoints(10).ToArray()); series.GapLength = 0.6f; series.XAxis = xAxis; chart.YAxis = yAxis; chart.AddSeries (series); }
void ReloadChart() { chart.RemoveAllData (); TKChartSeries series = null; if (this.SelectedOption == 0) { series = new TKChartCandlestickSeries (points.ToArray ()); } else { series = new TKChartOhlcSeries (points.ToArray ()); } series.SelectionMode = TKChartSeriesSelectionMode.DataPoint; TKChartNumericAxis yAxis = new TKChartNumericAxis (new NSNumber (300), new NSNumber (380)); yAxis.MajorTickInterval = 20; chart.YAxis = yAxis; chart.AddSeries (series); TKChartDateTimeAxis xAxis = (TKChartDateTimeAxis)chart.XAxis; xAxis.MinorTickIntervalUnit = TKChartDateTimeAxisIntervalUnit.Days; xAxis.Style.MajorTickStyle.TicksOffset = -3; xAxis.Style.MajorTickStyle.TicksHidden = false; xAxis.Style.MajorTickStyle.TicksWidth = 1.5f; xAxis.Style.MajorTickStyle.TicksFill = new TKSolidFill (UIColor.FromRGB (203, 203, 203)); xAxis.Style.MajorTickStyle.MaxTickClippingMode = TKChartAxisClippingMode.Visible; xAxis.AllowPan = true; xAxis.AllowZoom = true; yAxis.Style.LabelStyle.TextAlignment = TKChartAxisLabelAlignment.Bottom | TKChartAxisLabelAlignment.Right; yAxis.AllowPan = true; yAxis.AllowZoom = true; chart.ReloadData (); }
void snippet1() { // >> chart-indicators-bollinger-cs var candlesticks = new TKChartCandlestickSeries(financialDataPoints.ToArray()); var bollingerBands = new TKChartBollingerBandIndicator(candlesticks); financialChart.AddSeries(candlesticks); financialChart.AddSeries(bollingerBands); // << chart-indicators-bollinger-cs }
void snippet2() { // >> chart-indicators-technical-cs var candlesticks = new TKChartCandlestickSeries(financialDataPoints.ToArray()); var macdIndicator = new TKChartMACDIndicator(candlesticks); macdIndicator.LongPeriod = 26; macdIndicator.ShortPeriod = 12; macdIndicator.SignalPeriod = 9; financialChart.AddSeries(macdIndicator); // << chart-indicators-technical-cs }
void ReloadChart() { chart.RemoveAllData(); TKChartSeries series = null; if (this.SelectedOption == 0) { series = new TKChartCandlestickSeries(points.ToArray()); } else { series = new TKChartOhlcSeries(points.ToArray()); } series.Selection = TKChartSeriesSelection.DataPoint; TKChartNumericAxis yAxis = new TKChartNumericAxis(new NSNumber(300), new NSNumber(380)); yAxis.MajorTickInterval = 20; chart.YAxis = yAxis; chart.AddSeries(series); TKChartDateTimeAxis xAxis = (TKChartDateTimeAxis)chart.XAxis; xAxis.MinorTickIntervalUnit = TKChartDateTimeAxisIntervalUnit.Days; xAxis.Style.MajorTickStyle.TicksOffset = -3; xAxis.Style.MajorTickStyle.TicksHidden = false; xAxis.Style.MajorTickStyle.TicksWidth = 1.5f; xAxis.Style.MajorTickStyle.TicksFill = new TKSolidFill(UIColor.FromRGB(203, 203, 203)); xAxis.Style.MajorTickStyle.MaxTickClippingMode = TKChartAxisClippingMode.Visible; // >> chart-zoom-cs xAxis.AllowZoom = true; yAxis.AllowZoom = true; // << chart-zoom-cs // >> chart-pan-cs xAxis.AllowPan = true; yAxis.AllowPan = true; // << chart-pan-cs yAxis.Style.LabelStyle.TextAlignment = TKChartAxisLabelAlignment.Bottom | TKChartAxisLabelAlignment.Right; chart.ReloadData(); }
public override void ViewDidLoad() { base.ViewDidLoad(); TKChart chart = new TKChart(this.View.Bounds); chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview(chart); // >> chart-axis-datetime-cat-cs var xAxis = new TKChartDateTimeCategoryAxis(); var formatter = new NSDateFormatter(); formatter.DateFormat = "d MMM"; xAxis.LabelFormatter = formatter; xAxis.DateComponent = NSCalendarUnit.Hour | NSCalendarUnit.Minute | NSCalendarUnit.Second; // << chart-axis-datetime-cat-cs // >> chart-tick-style-set-cs xAxis.Style.MajorTickStyle.TicksOffset = -3; xAxis.Style.MajorTickStyle.TicksHidden = false; xAxis.Style.MajorTickStyle.TicksWidth = 1.5f; xAxis.Style.MajorTickStyle.TicksFill = new TKSolidFill(new UIColor(203 / 255.0f, 203 / 255.0f, 203 / 255.0f, 1f)); xAxis.Style.MajorTickStyle.MaxTickClippingMode = TKChartAxisClippingMode.Visible; // << chart-tick-style-set-cs // >> chart-category-plot-cs xAxis.PlotMode = TKChartAxisPlotMode.BetweenTicks; // << chart-category-plot-cs var yAxis = new TKChartNumericAxis(new NSNumber(320), new NSNumber(360)); yAxis.MajorTickInterval = 20; var series = new TKChartCandlestickSeries(StockDataPoint.LoadStockPoints(10).ToArray()); // >> chart-gap-cs series.GapLength = 0.6f; // << chart-gap-cs series.XAxis = xAxis; chart.YAxis = yAxis; chart.AddSeries(series); }