MrWooJ

Adding PNScatterChart - DataItem

  1 +//
  2 +// PNScatterChartDataItem.h
  3 +// PNChartDemo
  4 +//
  5 +// Created by Alireza Arabi on 12/4/14.
  6 +// Copyright (c) 2014 kevinzhow. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface PNScatterChartDataItem : NSObject
  12 +
  13 ++ (PNScatterChartDataItem *)dataItemWithX:(CGFloat)x AndWithY:(CGFloat)y;
  14 +
  15 +@property (readonly) CGFloat x; // should be within the x range
  16 +@property (readonly) CGFloat y; // should be within the y range
  17 +
  18 +@end
  1 +//
  2 +// PNScatterChartDataItem.m
  3 +// PNChartDemo
  4 +//
  5 +// Created by Alireza Arabi on 12/4/14.
  6 +// Copyright (c) 2014 kevinzhow. All rights reserved.
  7 +//
  8 +
  9 +#import "PNScatterChartDataItem.h"
  10 +
  11 +@interface PNScatterChartDataItem ()
  12 +
  13 +- (id)initWithX:(CGFloat)x AndWithY:(CGFloat)y;
  14 +
  15 +@property (readwrite) CGFloat x; // should be within the x range
  16 +@property (readwrite) CGFloat y; // should be within the y range
  17 +
  18 +@end
  19 +
  20 +@implementation PNScatterChartDataItem
  21 +
  22 ++ (PNScatterChartDataItem *)dataItemWithX:(CGFloat)x AndWithY:(CGFloat)y
  23 +{
  24 + return [[PNScatterChartDataItem alloc] initWithX:x AndWithY:y];
  25 +}
  26 +
  27 +- (id)initWithX:(CGFloat)x AndWithY:(CGFloat)y
  28 +{
  29 + if ((self = [super init])) {
  30 + self.x = x;
  31 + self.y = y;
  32 + }
  33 +
  34 + return self;
  35 +}
  36 +
  37 +@end