2012-03-28 79 views
0

我的代碼如下:散點圖在iPhone上使用核心積突出點

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
     [self generateDataSamples]; 

    CPTGraphHostingView *hostingview=[[CPTGraphHostingView alloc] initWithFrame:self.view.bounds]; 
    [self.view addSubview:hostingview]; 

    graph=[[CPTXYGraph alloc] initWithFrame:self.view.bounds]; 
    hostingview.hostedGraph =graph; 

    // Border 
    graph.plotAreaFrame.borderLineStyle = nil; 
    graph.plotAreaFrame.cornerRadius = 0.0f; 

    // Paddings 
    graph.paddingLeft = 0.0f; 
    graph.paddingRight = 0.0f; 
    graph.paddingTop = 0.0f; 
    graph.paddingBottom = 0.0f; 

    graph.plotAreaFrame.paddingLeft = 70.0; 
    graph.plotAreaFrame.paddingTop = 20.0; 
    graph.plotAreaFrame.paddingRight = 20.0; 
    graph.plotAreaFrame.paddingBottom = 80.0; 


    CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle]; 
    lineStyle.lineColor = [CPTColor blackColor]; 
    lineStyle.lineWidth = 2.0f; 

    CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace; 
    plotSpace.allowsUserInteraction = NO; 
    plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0) length:CPTDecimalFromFloat(7.0)]; 
    plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0) length:CPTDecimalFromFloat(50.0)]; 


    CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet; 
    CPTXYAxis *x = axisSet.xAxis; 
    x.majorIntervalLength = CPTDecimalFromString(@"1.0"); 
    x.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0.0"); 
    x.minorTicksPerInterval =9; 
    // x.majorGridLineStyle = majorGridLineStyle; 
    // x.minorGridLineStyle = minorGridLineStyle; 

    x.title = @"X Axis"; 
    x.titleOffset = 30.0; 
    x.titleLocation = CPTDecimalFromString(@"1.25"); 

    // Label y with an automatic label policy. 
    CPTXYAxis *y = axisSet.yAxis; 
    y.labelingPolicy = CPTAxisLabelingPolicyAutomatic; 
    y.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0.0"); 
    y.minorTicksPerInterval =9; 
    y.preferredNumberOfMajorTicks = 8; 
    //y.majorGridLineStyle = majorGridLineStyle; 
    // y.minorGridLineStyle = minorGridLineStyle; 
    y.labelOffset = 10.0; 

    y.title = @"Y Axis"; 
    y.titleOffset = 30.0; 
    y.titleLocation = CPTDecimalFromString(@"1.0"); 

    // Set axes 
    graph.axisSet.axes = [NSArray arrayWithObjects:x, y, nil]; 



    CPTScatterPlot *datasourceLinePlot =[[CPTScatterPlot alloc] init]; 
    datasourceLinePlot.dataSource =self; 

    [graph addPlot:datasourceLinePlot]; 

    [datasourceLinePlot release]; 
    [graph release]; 
    [hostingview release]; 

} 

這段代碼在iPhone上使用核心積庫生成散點圖...!

代碼在輸出下正常工作。

enter image description here

,但我儘量高光點不知道....!

我想要突出顯示x和y值點像點....!

幫助我與我們...!

回答

2

使用繪圖符號:

CPTPlotSymbol *plotSymbol = [CPTPlotSymbol ellipsePlotSymbol]; 
plotSymbol.fill = [CPTFill fillWithColor:[CPTColor whiteColor]]; 
plotSymbol.size = CGSizeMake(10.0, 10.0); 
datasourceLinePlot.plotSymbol = plotSymbol; 
相關問題