public void setStyles(TKChartSeries series) { TKChartPaletteItem item = series.Style.Palette.PaletteItemAtIndex(series.Index); if (series is TKChartColumnSeries && item.Drawables.Length > 1) { NSObject drawable = item.Drawables [2]; if (drawable is TKStroke) { TKStroke stroke = drawable as TKStroke; series.YAxis.Style.LineStroke = new TKStroke(stroke.Fill); } else { series.YAxis.Style.LineStroke = new TKStroke(item.Stroke.Fill); } } else { series.YAxis.Style.LineStroke = new TKStroke(item.Stroke.Fill); } series.YAxis.Style.MajorTickStyle.TicksFill = series.YAxis.Style.LineStroke.Fill; series.YAxis.Style.MajorTickStyle.MaxTickClippingMode = TKChartAxisClippingMode.Visible; series.YAxis.Style.MajorTickStyle.MinTickClippingMode = TKChartAxisClippingMode.Visible; if (series.YAxis.Style.MajorTickStyle.TicksFill is TKSolidFill) { TKSolidFill solidFill = series.YAxis.Style.MajorTickStyle.TicksFill as TKSolidFill; series.YAxis.Style.LabelStyle.TextColor = solidFill.Color; } }
public override TKChartPaletteItem PaletteItemForSeries(TKChart chart, TKChartSeries series, nint index) { TKChartPaletteItem item = null; if (series.Index == 1) { UIColor[] colors = new UIColor[] { new UIColor(0f, 1f, 0f, 0.4f), new UIColor(1f, 0f, 0f, 0.4f), new UIColor(0f, 0f, 1f, 0.4f), }; TKLinearGradientFill gradient = new TKLinearGradientFill(colors, new PointF(0.5f, 0.0f), new PointF(0.5f, 1.0f)); item = new TKChartPaletteItem(gradient); } else { TKImageFill image = new TKImageFill(new UIImage("pattern1.png"), 5.0f); image.ResizingMode = TKImageFillResizingMode.Tile; TKStroke stroke = new TKStroke(UIColor.Black, 1.0f); stroke.CornerRadius = 5.0f; stroke.DashPattern = new NSNumber[] { new NSNumber(2), new NSNumber(2), new NSNumber(5), new NSNumber(2) }; item = new TKChartPaletteItem(new NSObject[] { image, stroke }); } return(item); }
public override void DrawInContext(CGContext ctx) { UIGraphics.PushContext(ctx); CGRect bounds = this.Bounds; TKFill fill = this.LabelStyle.Fill; TKStroke stroke = new TKStroke(UIColor.Black); TKBalloonShape shape = new TKBalloonShape(TKBalloonShapeArrowPosition.Bottom, new CGSize(bounds.Size.Width - stroke.Width, bounds.Size.Height - stroke.Width)); CGRect textRect; if (this.IsOutsideBounds == true) { shape.ArrowPosition = TKBalloonShapeArrowPosition.Top; textRect = new CGRect(bounds.Left, bounds.Top - this.LabelStyle.Insets.Top + shape.ArrowSize.Height, bounds.Size.Width, bounds.Size.Height + this.LabelStyle.Insets.Bottom); } else { textRect = new CGRect(bounds.Left, bounds.Top - this.LabelStyle.Insets.Top, bounds.Size.Width, bounds.Size.Height + this.LabelStyle.Insets.Bottom); } shape.DrawInContext(ctx, new CGPoint(bounds.GetMidX(), bounds.GetMidY()), new TKDrawing[] { fill, stroke }); NSMutableParagraphStyle paragraphStyle = new NSMutableParagraphStyle(); paragraphStyle.Alignment = this.LabelStyle.TextAlignment; NSDictionary attributes = new NSDictionary(UIStringAttributeKey.Font, UIFont.SystemFontOfSize(18), UIStringAttributeKey.ForegroundColor, this.LabelStyle.TextColor, UIStringAttributeKey.ParagraphStyle, paragraphStyle); NSString text = new NSString(this.Text); text.WeakDrawString(textRect, NSStringDrawingOptions.TruncatesLastVisibleLine | NSStringDrawingOptions.UsesLineFragmentOrigin, attributes, null); UIGraphics.PopContext(); }
public override void DrawInContext (CGContext ctx) { UIGraphics.PushContext (ctx); CGRect bounds = this.Bounds; TKFill fill = this.LabelStyle.Fill; TKStroke stroke = new TKStroke (UIColor.Black); TKBalloonShape shape = new TKBalloonShape (TKBalloonShapeArrowPosition.Bottom ,new CGSize(bounds.Size.Width - stroke.Width, bounds.Size.Height - stroke.Width)); CGRect textRect; if (this.IsOutsideBounds == true) { shape.ArrowPosition = TKBalloonShapeArrowPosition.Top; textRect = new CGRect (bounds.Left, bounds.Top - this.LabelStyle.Insets.Top + shape.ArrowSize.Height, bounds.Size.Width, bounds.Size.Height + this.LabelStyle.Insets.Bottom); } else { textRect = new CGRect (bounds.Left, bounds.Top - this.LabelStyle.Insets.Top, bounds.Size.Width, bounds.Size.Height + this.LabelStyle.Insets.Bottom); } shape.DrawInContext (ctx, new CGPoint (bounds.GetMidX (), bounds.GetMidY ()), new TKDrawing[]{ fill, stroke }); NSMutableParagraphStyle paragraphStyle = new NSMutableParagraphStyle (); paragraphStyle.Alignment = this.LabelStyle.TextAlignment; NSDictionary attributes = new NSDictionary (UIStringAttributeKey.Font, UIFont.SystemFontOfSize (18), UIStringAttributeKey.ForegroundColor, this.LabelStyle.TextColor, UIStringAttributeKey.ParagraphStyle, paragraphStyle); NSString text = new NSString (this.Text); text.WeakDrawString (textRect, NSStringDrawingOptions.TruncatesLastVisibleLine | NSStringDrawingOptions.UsesLineFragmentOrigin, attributes, null); UIGraphics.PopContext (); }
void snippet11() { // >> chart-drawing-stroke-rounded-corners-cs var stroke = new TKStroke(UIColor.Blue, 1.0f); stroke.CornerRadius = 5.0f; // << chart-drawing-stroke-rounded-corners-cs }
void snippet10() { // >> chart-drawing-stroke-cs var stroke = new TKStroke(UIColor.Blue); // << chart-drawing-stroke-cs Console.WriteLine(stroke); }
void snippet12() { // >> chart-drawing-stroke-dashed-cs var stroke = new TKStroke(UIColor.Blue, 1.0f); stroke.CornerRadius = 5.0f; stroke.DashPattern = new NSNumber[] { new NSNumber(2), new NSNumber(2), new NSNumber(5), new NSNumber(2) }; // << chart-drawing-stroke-dashed-cs }
void snippet13() { // >> chart-drawing-stroke-gradient-cs var fill = new TKLinearGradientFill(new UIColor[] { new UIColor(0.0f, 1.0f, 0.0f, 0.6f), new UIColor(1.0f, 0.0f, 0.0f, 0.6f), new UIColor(0.0f, 0.0f, 1.0f, 0.6f) }, new CGPoint(0, 0), new CGPoint(1, 1)); var stroke = new TKStroke(fill, 1.0f); stroke.CornerRadius = 5.0f; // << chart-drawing-stroke-gradient-cs }
void snippet14() { // >> chart-drawing-stroke-combined-cs var fill = new TKLinearGradientFill(new UIColor[] { new UIColor(0.0f, 1.0f, 0.0f, 0.6f), new UIColor(1.0f, 0.0f, 0.0f, 0.6f), new UIColor(0.0f, 0.0f, 1.0f, 0.6f) }, new CGPoint(0, 0), new CGPoint(1, 1)); var stroke = new TKStroke(fill, 1.0f); stroke.CornerRadius = 5.0f; stroke.DashPattern = new NSNumber[] { new NSNumber(2), new NSNumber(2), new NSNumber(5), new NSNumber(2) }; stroke.Corners = UIRectCorner.TopRight | UIRectCorner.BottomLeft; // << chart-drawing-stroke-combined-cs }
// >> chart-ohlc-visual-cs public override TKChartPaletteItem PaletteItemForSeries(TKChart chart, TKChartSeries series, nint index) { var dataPoint = series.DataPointAtIndex((uint)index); TKStroke stroke = null; if (dataPoint.Close.DoubleValue < dataPoint.Open.DoubleValue) { stroke = new TKStroke(UIColor.Red); } else { stroke = new TKStroke(UIColor.Green); } var paletteItem = new TKChartPaletteItem(stroke); return(paletteItem); }
// >> chart-candlestick-visual-cs public override TKChartPaletteItem PaletteItemForSeries(TKChart chart, TKChartSeries series, nint index) { var dataPoint = series.DataPointAtIndex((uint)index); var stroke = new TKStroke(UIColor.Black); var fill = new TKSolidFill(); if (dataPoint.Close.DoubleValue < dataPoint.Open.DoubleValue) { fill.Color = UIColor.Red; } else { fill.Color = UIColor.Green; } var paletteItem = new TKChartPaletteItem(stroke, fill); return(paletteItem); }
void snippet18() { TKChartSeries series = null; // >> chart-drawing-pallete-items-arrays-cs series.Style.Palette = new TKChartPalette(); var redFill = new TKSolidFill(UIColor.Red, 2.0f); var stroke1 = new TKStroke(UIColor.Yellow, 1.0f); stroke1.CornerRadius = 2.0f; stroke1.Insets = new UIEdgeInsets(1, 1, 1, 1); var stroke2 = new TKStroke(UIColor.Black, 1.0f); stroke2.CornerRadius = 2.0f; series.Style.Palette.AddPaletteItem(new TKChartPaletteItem(new TKDrawing[] { redFill, stroke1, stroke2 })); // << chart-drawing-pallete-items-arrays-cs // >> chart-drawing-pallete-point-cs series.Style.PointShape = new TKPredefinedShape(TKShapeType.Rhombus, new CGSize(15, 15)); // << chart-drawing-pallete-point-cs }
public override TKChartPaletteItem PaletteItemForSeries(TKChart chart, TKChartSeries series, nint index) { TKChartPaletteItem item = null; if (series.Index == 1) { UIColor[] colors = new UIColor[] { new UIColor(0f, 1f, 0f, 0.4f), new UIColor(1f, 0f, 0f, 0.4f), new UIColor(0f, 0f, 1f, 0.4f), }; TKLinearGradientFill gradient = new TKLinearGradientFill(colors, new PointF (0.5f, 0.0f), new PointF (0.5f, 1.0f)); item = new TKChartPaletteItem (gradient); } else { TKImageFill image = new TKImageFill(new UIImage ("pattern1.png"), 5.0f); image.ResizingMode = TKImageFillResizingMode.Tile; TKStroke stroke = new TKStroke (UIColor.Black, 1.0f); stroke.CornerRadius = 5.0f; stroke.DashPattern = new NSNumber[] { new NSNumber(2), new NSNumber(2), new NSNumber(5), new NSNumber(2) }; item = new TKChartPaletteItem (new NSObject[] { image, stroke }); } return item; }