2017-06-01 38 views
0

https://www.dropbox.com/s/8fqez61k9jhnoa4/Screen%20Shot%202017-06-01%20at%201.04.25%20PM.png?dl=0YAXIS在忍的iOS圖表切斷

  • (無效)createBurnoutChart {

    //創建圖表(如果需要) 如果(burnoutChart ==無){ 如果(UI_USER_INTERFACE_IDIOM( )== UIUserInterfaceIdiomPad)

     burnoutChart = [[ShinobiChart alloc] initWithFrame:CGRectMake(0, 270, 768,725)]; // iPad 
    else 
    
        burnoutChart = [[ShinobiChart alloc] initWithFrame:CGRectMake(0, 165, 320,290)]; // iPhone 
    
    // Set a different theme on the chart 
    SChartMidnightTheme *midnight = [[SChartMidnightTheme alloc] init]; 
    [burnoutChart setTheme:midnight]; 
    
    //As the chart is a UIView, set its resizing mask to allow it to automatically resize when screen orientation changes. 
    burnoutChart.autoresizingMask = ~UIViewAutoresizingNone; 
    
    // Initialise the data source we will use for the chart 
    burnoutDatasource = [[LineChartDataSource alloc] initWithFileName:LineChartSource_Burnout seriesCount:1]; 
    
    // Give the chart the data source 
    burnoutChart.datasource = burnoutDatasource; 
    
    // Create a date time axis to use as the x axis. 
    SChartDateTimeAxis *xAxis = [[SChartDateTimeAxis alloc] init]; 
    
    // Enable panning and zooming on the x-axis. 
    xAxis.enableGesturePanning = YES; 
    xAxis.enableGestureZooming = YES; 
    xAxis.enableMomentumPanning = YES; 
    xAxis.enableMomentumZooming = YES; 
    xAxis.axisPositionValue = [NSNumber numberWithInt: 0]; 
    
    // And allow them to scroll past the default range 
    xAxis.allowPanningOutOfMaxRange = YES; 
    xAxis.allowPanningOutOfDefaultRange = YES; 
    
    // Make the frequency of tick marks be one day 
    SChartDateFrequency *freq = [[SChartDateFrequency alloc] initWithDay:1]; 
    xAxis.majorTickFrequency = freq; 
    
    burnoutChart.xAxis = xAxis; 
    
    //Create a number axis to use as the y axis. 
    //TODO:Checkback 
    NSNumber *lowRange = [[NSNumber alloc] initWithInteger:0]; 
    NSNumber *highRange = [[NSNumber alloc] initWithInteger:100]; 
    
    SChartNumberRange *yRange = [[SChartNumberRange alloc] initWithMinimum:lowRange andMaximum:highRange]; 
    SChartNumberAxis *yAxis = [[SChartNumberAxis alloc] initWithRange:yRange ]; 
    
    //Enable panning and zooming on Y 
    yAxis.enableGesturePanning = YES; 
    yAxis.enableGestureZooming = YES; 
    yAxis.enableMomentumPanning = YES; 
    yAxis.enableMomentumZooming = YES; 
    

    // yAxis.axisPositionValue = [NSNumber的numberWithInt:0];

    // And allow them to scroll past the default range 
    yAxis.allowPanningOutOfMaxRange = NO; 
    yAxis.allowPanningOutOfDefaultRange = NO; 
    
    
    burnoutChart.yAxis.defaultRange; 
    burnoutChart.yAxis = yAxis; 
    
    //Set the chart title 
    burnoutChart.title = @""; 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
        burnoutChart.titleLabel.font = [UIFont fontWithName:@"TrebuchetMS" size:27.0f]; 
    } else { 
        burnoutChart.titleLabel.font = [UIFont fontWithName:@"TrebuchetMS" size:17.0f]; 
    } 
    burnoutChart.titleLabel.textColor = [UIColor whiteColor]; 
    
    
    // If you have a trial version, you need to enter your licence key here: 
    // chart.licenseKey = @""; 
    
    // Add the chart to the view controller 
    [self.viewBurnoutChart addSubview:burnoutChart]; 
    

    }

    //確保我們得到的最新數據 NSInteger的lastScore = [burnoutDatasource reReadData] [self vasBurnoutImage:lastScore]; [self vasBurnoutScore:lastScore]; [burnoutChart reloadData]; [burnoutChart redrawChartAndGL:YES];

    // *****重置可見部分..如果我曾經得到它拖曳 //[burnoutChart.xAxis resetZoomLevel]; }

該圖表顯示良好,但是當涉及到Y軸停止恰好在100極限範圍。我想顯示更多的時間間隔,以免它看起來被切斷。

回答

0

有兩種方法可以實現這一目標:

  • 如果你想手動設置範圍的軸(如你目前做的),然後簡單地增加射程例如至103.勾號標籤不應受影響。
  • 如果您很高興讓圖表確定範圍,那麼您可以使用rangePaddingHigh屬性來調整添加到計算範圍的填充量。

我希望有幫助!

+0

感謝它的工作! –