daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Unable to have two CorePlot graphs show simultaneously
  2. - (void) graphSetup {
  3.     CPTTheme *theme = [CPTTheme themeNamed:kCPTPlainWhiteTheme];
  4.  
  5.     graph = (CPTXYGraph *)[theme newGraph];
  6.  
  7.     graphView.hostedGraph = graph;
  8.     graphView.allowPinchScaling = YES;
  9.  
  10.     graph.paddingLeft = -5;
  11.     graph.paddingTop = 0;
  12.     graph.paddingRight = -5;
  13.     graph.paddingBottom = -5;
  14.     graph.fill = nil;
  15.     graph.plotAreaFrame.fill = nil;
  16.     int a = 0;
  17.     for (int i = 0; i < [romAveragesArray count]; i++) {
  18.         if ([romAveragesArray objectAtIndex:i] != NULL)
  19.             a++;
  20.     }
  21.  
  22.     int localMax = 0;
  23.     int localMin = 0;
  24.  
  25.     for (int a = 0; a < [romAveragesArray count]; a++) {
  26.         if ([[romAveragesArray objectAtIndex:a] getValue] > localMax)
  27.             localMax = [[romAveragesArray objectAtIndex:a] getValue];
  28.         else if ([[romAveragesArray objectAtIndex:a] getValue] < localMin)
  29.             localMin = [[romAveragesArray objectAtIndex:a] getValue];
  30.     }
  31.  
  32.     for (int a = 0; a < [obaAveragesArray count]; a++) {
  33.         if ([[obaAveragesArray objectAtIndex:a] getValue] > localMax)
  34.             localMax = [[obaAveragesArray objectAtIndex:a] getValue];
  35.         else if ([[obaAveragesArray objectAtIndex:a] getValue] < localMin)
  36.             localMin = [[obaAveragesArray objectAtIndex:a] getValue];
  37.  
  38.     }
  39.  
  40.  
  41.     CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
  42.     plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0)
  43.                                                     length:CPTDecimalFromInt(145)];
  44.     NSLog(@"%d",a);
  45.     plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0)
  46.                                                     length:CPTDecimalFromInt(localMax+15)];
  47.  
  48.  
  49.  
  50.  
  51.     CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
  52.  
  53.     CPTXYAxis *x = axisSet.xAxis;
  54.     x.majorIntervalLength = CPTDecimalFromFloat(10);
  55.     x.minorTicksPerInterval = 2;
  56.     x.borderWidth = 0;
  57.     x.labelExclusionRanges = [NSArray arrayWithObjects:
  58.                               [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-100)
  59.                                                            length:CPTDecimalFromFloat(300)],
  60.                               nil];;
  61.  
  62.     CPTXYAxis *y = axisSet.yAxis;
  63.     y.majorIntervalLength = CPTDecimalFromFloat(10);
  64.     y.minorTicksPerInterval = 1;
  65.     y.labelExclusionRanges = [NSArray arrayWithObjects:
  66.                               [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-100)
  67.                                                            length:CPTDecimalFromFloat(300)],
  68.                               nil];
  69.  
  70.  
  71.  
  72.  
  73.  
  74.     CPTScatterPlot *dataSourceLinePlot = [[CPTScatterPlot alloc] init];
  75.     dataSourceLinePlot.identifier = @"Obama";
  76.     dataSourceLinePlot.dataSource = self;
  77.     CPTMutableLineStyle *style = [CPTMutableLineStyle lineStyle];
  78.     style.lineColor = [CPTColor colorWithComponentRed:0.3215686274509804 green:0.6078431372549019 blue:1.0 alpha:1.0];
  79.     dataSourceLinePlot.dataLineStyle = style;
  80.     [graph addPlot:dataSourceLinePlot];
  81.  
  82.  
  83.     CPTScatterPlot *dataSourceLinePlot1 = [[CPTScatterPlot alloc] init];
  84.     dataSourceLinePlot1.identifier = @"Rom";
  85.     dataSourceLinePlot1.dataSource = self;
  86.     CPTMutableLineStyle *style1 = [CPTMutableLineStyle lineStyle];
  87.     style1.lineColor = [CPTColor colorWithComponentRed:0.9803921568627451 green:0.47058823529411764 blue:0.47058823529411764 alpha:1.0];
  88.     dataSourceLinePlot1.dataLineStyle = style1;
  89.     [graph addPlot:dataSourceLinePlot1];
  90.      [self trendSetup];
  91.  
  92.     [self postStats];
  93.  
  94. }
  95.  
  96.  
  97. - (void) trendSetup {
  98.     CPTTheme *theme1 = [CPTTheme themeNamed:kCPTPlainWhiteTheme];
  99.  
  100.     trend = (CPTXYGraph *) [theme1 newGraph];
  101.     trendView.allowPinchScaling = YES;
  102.     trendView.hostedGraph = trend;
  103.  
  104.     trend.paddingLeft = -5;
  105.     trend.paddingRight = -5;
  106.     trend.paddingTop = 0;
  107.     trend.paddingBottom = -5;
  108.     trend.fill =  nil;
  109.     trend.plotAreaFrame.fill = nil;
  110.     int obaMax, localMax;
  111.     for (int i = 0; i < [obaArray count]; i++)
  112.         obaMax += [[obaArray objectAtIndex:i] getValue];
  113.  
  114.     int romMax;
  115.     for (int i = 0; i < [romArray count]; i++)
  116.         romMax += [[romArray objectAtIndex:i] getValue];
  117.  
  118.     if (romMax > obaMax)
  119.         localMax = romMax;
  120.     else
  121.         localMax = obaMax;
  122.  
  123.     CPTXYPlotSpace *trendSpace = (CPTXYPlotSpace *)trend.defaultPlotSpace;
  124.     trendSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0) length:CPTDecimalFromInt(504)];
  125.     trendSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0) length:CPTDecimalFromInt(localMax)];
  126.  
  127.     CPTXYAxisSet *trendSet = (CPTXYAxisSet *)trend.axisSet;
  128.  
  129.     CPTXYAxis *trendX = trendSet.xAxis;
  130.     trendX.majorIntervalLength = CPTDecimalFromInt(10);
  131.     trendX.minorTicksPerInterval = 2;
  132.     trendX.borderWidth  = 0;
  133.     trendX.labelExclusionRanges = [NSArray arrayWithObjects:[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-100) length:CPTDecimalFromFloat(300)], nil];;
  134.  
  135.     CPTXYAxis *trendY = trendSet.xAxis;
  136.     trendY.majorIntervalLength = CPTDecimalFromInt(10);
  137.     trendY.minorTicksPerInterval = 2;
  138.     trendY.borderWidth  = 0;
  139.     trendY.labelExclusionRanges = [NSArray arrayWithObjects:[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-100) length:CPTDecimalFromFloat(300)], nil];;
  140.  
  141.     CPTScatterPlot *trendSourceLinePlot = [[CPTScatterPlot alloc] init];
  142.     trendSourceLinePlot.identifier = @"Obama Trend";
  143.     trendSourceLinePlot.dataSource = self;
  144.     CPTMutableLineStyle *style3 = [CPTMutableLineStyle lineStyle];
  145.     style3.lineColor = [CPTColor colorWithComponentRed:0.3215686274509804 green:0.6078431372549019 blue:1.0 alpha:1.0];
  146.     trendSourceLinePlot.dataLineStyle = style3;
  147.     [trend addPlot:trendSourceLinePlot];
  148.  
  149.  
  150.     CPTScatterPlot *trendSourceLinePlot1 = [[CPTScatterPlot alloc] init];
  151.     trendSourceLinePlot1.identifier = @"Rom Trend";
  152.     trendSourceLinePlot1.dataSource = self;
  153.     CPTMutableLineStyle *style4 = [CPTMutableLineStyle lineStyle];
  154.     style4.lineColor = [CPTColor colorWithComponentRed:0.9803921568627451 green:0.47058823529411764 blue:0.47058823529411764 alpha:1.0];
  155.     trendSourceLinePlot1.dataLineStyle = style4;
  156.     [trend addPlot:trendSourceLinePlot1];
  157.  
  158. }
  159.    
  160. CPTTheme *theme1 = [CPTTheme themeNamed:kCPTPlainWhiteTheme];
  161. trend = (CPTXYGraph *) [theme1 newGraph];
  162. trendView.allowPinchScaling = YES;
  163. trendView.hostedGraph = trend;
  164. trend.paddingLeft = -5;
  165. trend.paddingRight = -5;
  166. trend.paddingTop = 0;
  167. trend.paddingBottom = -5;
  168. trend.fill =  nil;
  169. trend.plotAreaFrame.fill = nil;
  170.    
  171. [trend addPlot:trendSourceLinePlot];
  172. [trend addPlot:trendSourceLinePlot1];
  173.    
  174. [graph addPlot:trendSourceLinePlot];
  175. [graph addPlot:trendSourceLinePlot1];
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top