コアプロット1.0とiOS 5.1を使用してiOSアプリケーションのグラフを作成しています。コアプロット使用時にデータポイントが表示されない
私はコアプロットを見つけると、散布図のデータ自体を除いて、私のグラフに示したすべてのものを持つことができるすべてのチュートリアルを経てきた...
はそうここにあるため評判のスクリーンショットを投稿することはできませんAですhttp://francoismaillet.com/coreplot_problem.png
SimpleScatterPlot.m exampleのnumberOfRecordsForPlotおよびnumberForPlotメソッドを使用しています。 generateDataメソッドは、0と2の間の数値を生成します。
私はしばらくの間、サークルを回していましたが、どんな助けでも大歓迎です。ここで
は私のクラスのインタフェースです:
interface PriceChartViewController : UIViewController <CPTPlotDataSource, CPTScatterPlotDelegate>{
NSArray *plotData;
}
ここに私のviewDidLoadメソッドです:
- (void)viewDidLoad {
[super viewDidLoad];
[self generateData];
CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc] initWithFrame:self.view.bounds];
CPTXYGraph *graph = [[[CPTXYGraph alloc] initWithFrame:self.view.bounds] autorelease];
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[graph applyTheme:theme];
hostingView.hostedGraph = graph;
//hostingView.collapsesLayers = YES;
graph.paddingLeft = 15.0;
graph.paddingTop = 40.0;
graph.paddingRight = 15.0;
graph.paddingBottom = 40.0;
// Get plotSpace from graph
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-2)
length:CPTDecimalFromFloat(4)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-2)
length:CPTDecimalFromFloat(4)];
[graph addPlotSpace:plotSpace];
// Get axisset from graph
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTMutableLineStyle *majorGridLineStyle = [CPTMutableLineStyle lineStyle];
majorGridLineStyle.lineWidth = 1.0f;
majorGridLineStyle.lineColor = [[CPTColor whiteColor] colorWithAlphaComponent:0.75f];
CPTMutableLineStyle *minorGridLineStyle = [CPTMutableLineStyle lineStyle];
minorGridLineStyle.lineWidth = 1.0f;
minorGridLineStyle.lineColor = [[CPTColor whiteColor] colorWithAlphaComponent:0.25f];
CPTXYAxis *x = axisSet.xAxis;
x.title = @"X axis";
x.titleOffset = -20.0f;
x.titleLocation = CPTDecimalFromFloat(30.0f);
x.majorGridLineStyle = majorGridLineStyle;
x.minorGridLineStyle = minorGridLineStyle;
x.majorIntervalLength = CPTDecimalFromInteger(1);
x.minorTicksPerInterval = 0.5;
x.plotSpace = plotSpace;
CPTXYAxis *y = axisSet.yAxis;
y.majorIntervalLength = CPTDecimalFromInteger(1);
y.minorTicksPerInterval = 0.5;
//y.orthogonalCoordinateDecimal = CPTDecimalFromInteger(-0.5);
//y.preferredNumberOfMajorTicks = 8;
y.plotSpace = plotSpace;
// Create scatterplot
CPTScatterPlot *dataSourceLinePlot = [[CPTScatterPlot alloc] init];
dataSourceLinePlot.identifier = @"AllTests";
CPTMutableLineStyle *lineStyle = [[dataSourceLinePlot.dataLineStyle mutableCopy] autorelease];
//lineStyle.miterLimit = 1.0f;
lineStyle.lineWidth = 3.0f;
lineStyle.lineColor = [CPTColor blueColor];
dataSourceLinePlot.dataLineStyle = lineStyle;
dataSourceLinePlot.dataSource = self;
[graph addPlot:dataSourceLinePlot];
// Do a blue gradient
CPTColor *areaColor1 = [CPTColor colorWithComponentRed:0.3 green:0.3 blue:1.0 alpha:0.8];
CPTGradient *areaGradient1 = [CPTGradient gradientWithBeginningColor:areaColor1 endingColor:[CPTColor clearColor]];
areaGradient1.angle = -90.0f;
CPTFill *areaGradientFill = [CPTFill fillWithGradient:areaGradient1];
dataSourceLinePlot.areaFill = areaGradientFill;
dataSourceLinePlot.areaBaseValue = [[NSDecimalNumber zero] decimalValue];
// Auto scale the plot space to fit the plot data
// Extend the ranges by 30% for neatness
[plotSpace scaleToFitPlots:[NSArray arrayWithObjects:dataSourceLinePlot, nil]];
CPTMutablePlotRange *xRange = [[plotSpace.xRange mutableCopy] autorelease];
CPTMutablePlotRange *yRange = [[plotSpace.yRange mutableCopy] autorelease];
[xRange expandRangeByFactor:CPTDecimalFromDouble(1.3)];
[yRange expandRangeByFactor:CPTDecimalFromDouble(1.3)];
plotSpace.xRange = xRange;
plotSpace.yRange = yRange;
graph.legend = [CPTLegend legendWithGraph:graph];
graph.legend.textStyle = x.titleTextStyle;
graph.legend.fill = [CPTFill fillWithColor:[CPTColor darkGrayColor]];
graph.legend.borderLineStyle = x.axisLineStyle;
graph.legend.cornerRadius = 5.0;
graph.legend.swatchSize = CGSizeMake(25.0, 25.0);
graph.legendAnchor = CPTRectAnchorBottom;
graph.legendDisplacement = CGPointMake(0.0, 12.0);
[self setView:hostingView];
}
お返事ありがとうございます。私は行を削除しようとしたが、少なくともそれは余分なので、変更を加えるように見えなかった。 – CaRnAgE