ios - 核心情节线未显示
<p><p>我创建了 CorePlot 框架的简单实现。图表显示正常,但没有绘制线条。我已经尝试注销我的样本值并且确实有数据。任何关于为什么绘制数据行不显示的任何和所有输入都将不胜感激!</p>
<p><strong>头文件:</strong></p>
<pre><code>#import <UIKit/UIKit.h>
#import "PresentedViewControllerDelegate.h"
#import "CorePlot-CocoaTouch.h"
#define NUM_SAMPLES 30
@interface DeviceDetailModal : UIViewController <PresentedViewControllerDelegate, UIWebViewDelegate, UITableViewDataSource, UITableViewDelegate, CPTPlotDataSource>{
CPTXYGraph *graph;
NSMutableArray *samples;
double xxx;
double yyy1;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, weak) id <PresentedViewControllerDelegate> delegate;
@end
</code></pre>
<p><strong>主文件</strong></p>
<pre><code>#import <Foundation/Foundation.h>
#import "DeviceDetailModal.h"
#import "DetailCell.h"
#import "CorePlot-CocoaTouch.h"
#define START_POINT 0 // Start at origin
#define END_POINT 15.0 // TODO time is 15 seconds
#define X_VAL @"X_VAL"
#define Y_VAL @"Y_VAL"
@implementation DeviceDetailModal
-(void)viewDidLoad{
UIBarButtonItem *closeButton = [ initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(closeView)];
self.navigationItem.leftBarButtonItem = closeButton;
[ setTintColor:];
[ setBarTintColor:];
self.tableView.layer.cornerRadius = 10.0;
self.tableView.layer.borderWidth = 0.7;
self.tableView.layer.borderColor = .CGColor;
;
NSNumber *xAxisStart = ;
NSNumber *xAxisLength = ;
double maxY = [ doubleValue];
NSNumber *yAxisStart = ;
NSNumber *yAxisLength = ;
CGRect hostingRect = CGRectMake(20, 330, 335, 347);
CPTGraphHostingView *hostingView = [ initWithFrame:hostingRect];
;
graph = [ initWithFrame:hostingView.bounds];
hostingView.hostedGraph = graph;
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:xAxisStart
length:xAxisLength];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:yAxisStart
length:yAxisLength];
CPTScatterPlot *dataSourceLinePlot = [ init];
dataSourceLinePlot.delegate = self;
// LINE STYLE
CPTMutableLineStyle *mainPlotLineStyle = [ mutableCopy];
;
CGColor]]];
;
// AXIS STYLE
CPTXYAxisSet *axisSet = (CPTXYAxisSet *);
CPTXYAxis *xAxis = ;
CPTXYAxis *yAxis = ;
CPTMutableLineStyle *axisLineStyle = ;
;
CGColor]]];
;
;
;
;
;
NSLog(@"PLOT: %@",dataSourceLinePlot);
;
}
-(void)generateDataSamples{
double length = (END_POINT - START_POINT);
double delta = length / (NUM_SAMPLES -1);
samples = [ initWithCapacity:NUM_SAMPLES];
for (int i = 0; i < NUM_SAMPLES; i++) {
double x = START_POINT + (delta * i);
//X^2
double y = x * x;
NSDictionary *sample = [NSDictionary dictionaryWithObjectsAndKeys:
,X_VAL,
,Y_VAL,
nil];
NSLog(@"SAMPLE: %@", sample);
;
}
;
}
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot{
return NUM_SAMPLES;
}
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index{
NSDictionary *sample = ;
if (fieldEnum == CPTScatterPlotFieldX) {
return ;
}else{
return ;
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>发现问题了!未设置绘图的数据源,我必须这样做:</p>
<pre><code>dataSourceLinePlot.dataSource = self;
</code></pre>
<p>当我的 numberOfRecordsPerPlot 方法从未被调用时,我发现了这一点。</p></p>
<p style="font-size: 20px;">关于ios - 核心情节线未显示,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/33357328/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/33357328/
</a>
</p>
页:
[1]