public override void ViewDidLoad() { base.ViewDidLoad(); TKChart chart = new TKChart(this.View.Bounds); chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview(chart); string[] months = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun" }; int[] values = new int[] { 95, 40, 55, 30, 76, 34 }; List <TKChartDataPoint> list = new List <TKChartDataPoint> (); for (int i = 0; i < months.Length; i++) { list.Add(new TKChartDataPoint(new NSString(months[i]), new NSNumber(values[i]))); } TKChartLineSeries series = new TKChartLineSeries(list.ToArray()); // >> chart-point-shape-cs series.Style.PointShape = new TKPredefinedShape(TKShapeType.Circle, new SizeF(10, 10)); // << chart-point-shape-cs // >> chart-point-pallete-cs var paletteItem = new TKChartPaletteItem(); paletteItem.Fill = new TKSolidFill(UIColor.Red); var palette = new TKChartPalette(); palette.AddPaletteItem(paletteItem); series.Style.ShapePalette = palette; // << chart-point-pallete-cs chart.AddSeries(series); // >> chart-balloon-annotation-cs NSMutableParagraphStyle paragraphStyle = (NSMutableParagraphStyle) new NSParagraphStyle().MutableCopy(); paragraphStyle.Alignment = UITextAlignment.Center; NSMutableDictionary attributes = new NSMutableDictionary(); attributes.Add(UIStringAttributeKey.ForegroundColor, UIColor.White); attributes.Add(UIStringAttributeKey.ParagraphStyle, paragraphStyle); NSMutableAttributedString attributedText = new NSMutableAttributedString("Important milestone:\n $55000", attributes); attributedText.AddAttribute(UIStringAttributeKey.ForegroundColor, UIColor.Yellow, new NSRange(22, 6)); TKChartBalloonAnnotation balloon = new TKChartBalloonAnnotation(new NSString("Mar"), new NSNumber(55), series); balloon.AttributedText = attributedText; balloon.Style.DistanceFromPoint = 20; balloon.Style.ArrowSize = new Size(10, 10); chart.AddAnnotation(balloon); // << chart-balloon-annotation-cs balloon = new TKChartBalloonAnnotation("The lowest value:\n $30000", new NSString("Apr"), new NSNumber(30), series); balloon.Style.VerticalAlign = TKChartBalloonVerticalAlignment.Bottom; chart.AddAnnotation(balloon); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.pieChart = new TKChart(this.View.Bounds); this.pieChart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.pieChart.AllowAnimations = true; this.View.AddSubview(this.pieChart); List <TKChartDataPoint> array = new List <TKChartDataPoint>(); array.Add(new TKChartDataPoint(new NSNumber(25.0), null, "Auto &\nTransport")); array.Add(new TKChartDataPoint(new NSNumber(25.0), null, "Food &\nDining")); array.Add(new TKChartDataPoint(new NSNumber(25.0), null, "Fees &\nCharges")); array.Add(new TKChartDataPoint(new NSNumber(12.5), null, "Business\nServices")); array.Add(new TKChartDataPoint(new NSNumber(12.5), null, "Personal\nCare")); var series = new TKChartPieSeries(array.ToArray()); series.Selection = TKChartSeriesSelection.DataPoint; series.ExpandRadius = (nfloat)1.04; series.RotationAngle = (nfloat)(-(Math.PI / 2.0f + Math.PI / 4.0f)); series.RadiusInset = 50; series.LabelDisplayMode = TKChartPieSeriesLabelDisplayMode.Inside; series.Style.PointLabelStyle.TextHidden = false; series.Style.PointLabelStyle.StringFormat = "%.0f%%"; series.Style.PointLabelStyle.TextColor = UIColor.White; pieChart.AddSeries(series); foreach (TKChartDataPoint pt in series.Items) { var annotation = new TKChartBalloonAnnotation(pt.DataName, pt, series); annotation.Style.Fill = null; annotation.Style.Stroke = null; annotation.Style.DistanceFromPoint = 0; annotation.Style.TextColor = UIColor.Gray; pieChart.AddAnnotation(annotation); } }
public override void ViewDidLoad() { base.ViewDidLoad (); TKChart chart = new TKChart (this.ExampleBounds); chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.View.AddSubview (chart); string[] months = new string[]{ "Jan", "Feb", "Mar", "Apr", "May", "Jun" }; int[] values = new int[]{ 95, 40, 55, 30, 76, 34 }; List<TKChartDataPoint> list = new List<TKChartDataPoint> (); for (int i = 0; i < months.Length; i++) { list.Add (new TKChartDataPoint(new NSString(months[i]), new NSNumber(values[i]))); } TKChartLineSeries series = new TKChartLineSeries (list.ToArray()); series.Style.PointShape = new TKPredefinedShape (TKShapeType.Circle, new SizeF (10, 10)); chart.AddSeries (series); NSMutableParagraphStyle paragraphStyle = (NSMutableParagraphStyle)new NSParagraphStyle ().MutableCopy(); paragraphStyle.Alignment = UITextAlignment.Center; NSMutableDictionary attributes = new NSMutableDictionary (); attributes.Add (UIStringAttributeKey.ForegroundColor, UIColor.White); attributes.Add (UIStringAttributeKey.ParagraphStyle, paragraphStyle); NSMutableAttributedString attributedText = new NSMutableAttributedString ("Important milestone:\n $55000", attributes); attributedText.AddAttribute (UIStringAttributeKey.ForegroundColor, UIColor.Yellow, new NSRange (22, 6)); TKChartBalloonAnnotation balloon = new TKChartBalloonAnnotation (new NSString("Mar"), new NSNumber(55), series); balloon.AttributedText = attributedText; balloon.Style.DistanceFromPoint = 20; balloon.Style.ArrowSize = new Size (10, 10); chart.AddAnnotation (balloon); balloon = new TKChartBalloonAnnotation ("The lowest value:\n $30000", new NSString("Apr"), new NSNumber(30), series); balloon.Style.VerticalAlign = TKChartBalloonVerticalAlignment.Bottom; chart.AddAnnotation (balloon); }
public override void ViewDidLoad () { base.ViewDidLoad (); this.pieChart = new TKChart(this.View.Bounds); this.pieChart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.pieChart.AllowAnimations = true; this.View.AddSubview(this.pieChart); List<TKChartDataPoint> array = new List<TKChartDataPoint>(); array.Add(new TKChartDataPoint(new NSNumber(25.0), null, "Auto &\nTransport")); array.Add(new TKChartDataPoint(new NSNumber(25.0), null, "Food &\nDining")); array.Add(new TKChartDataPoint(new NSNumber(25.0), null, "Fees &\nCharges")); array.Add(new TKChartDataPoint(new NSNumber(12.5), null, "Business\nServices")); array.Add(new TKChartDataPoint(new NSNumber(12.5), null, "Personal\nCare")); var series = new TKChartPieSeries(array.ToArray()); series.SelectionMode = TKChartSeriesSelectionMode.DataPoint; series.ExpandRadius = (nfloat)1.04; series.RotationAngle = (nfloat)(-(Math.PI/2.0f + Math.PI/4.0f)); series.RadiusInset = 50; series.LabelDisplayMode = TKChartPieSeriesLabelDisplayMode.Inside; series.Style.PointLabelStyle.TextHidden = false; series.Style.PointLabelStyle.StringFormat = "%.0f%%"; series.Style.PointLabelStyle.TextColor = UIColor.White; pieChart.AddSeries(series); foreach (TKChartDataPoint pt in series.Items) { var annotation = new TKChartBalloonAnnotation(pt.DataName, pt, series); annotation.Style.Fill = null; annotation.Style.Stroke = null; annotation.Style.DistanceFromPoint = 0; annotation.Style.TextColor = UIColor.Gray; pieChart.AddAnnotation(annotation); } }