Custom View

Description: the view used to draw markers.

The CustomView.h File

#import <Charting/Charting.h>
#import <Charting/Chart.h>
// Determine custom view
@interface CustomView : UIView{
    Chart *chart;
}
- (void) setChart:(Chart *) newChart;
@end

The CustomView.m File

#import "CustomView.h"
@implementation CustomView
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor clearColor]];
    }
    return self;
}
// Set chart
- (void)setChart:(Chart *)chartParam{
    chart = chartParam;
}
// Redefine drawing method
- (void)drawRect:(CGRect)rect
{
    // Get graphic context
    CGContextRef context = UIGraphicsGetCurrentContext();
    // Get a data series
    ChartSeries *series = [chart seriesList][0];
    // Get data series point
    LinePoint *lPoint = [[series points] objectForKey:[NSNumber numberWithInt:2]];
    // Get series point marker
    ChartMarker *marker = [lPoint marker];
    // Determine drawing path
    CGMutablePathRef path = CGPathCreateMutable();
    // Determine marker drawing areas
    CGRect r1 = CGRectMake(10, 12, 15, 15);
    CGRect r2 = CGRectMake(100, 30, 15, 15);
    // Draw specified marker
    [marker addShapeToPath:path inRect:r1];
    // Draw round marker
    [ChartMarker addMarkerShapePathToPath:path forShape:MarkerShapeCircle forRect:r2];
    // Set fill color
    CGContextSetRGBFillColor(context, 0, 0.2, 1, 1);
    // Add path to drawing context
    CGContextAddPath(context, path);
    // Fill path with fill color
    CGContextFillPath(context);
}
@end

See also:

Chart Gradient Fill