https://www.dropbox.com/s/8fqez61k9jhnoa4/screen shot 2017-06-06-01 1.04.25%20pm.pmm.pngmm.png?P>
-
(void(createburnoutchart {
//创建图表(如果需要(if(burnoutchart == nil({ if(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 reareaddata];[自vasburnoutimage:LastScore];[self vasburnoutscore:lastScore];[BurnoutChart ReloAddata];[burnoutchart redrawchartandgl:是];
//*****对于重置可见部分很重要。//[burnoutchart.xaxis resetzoomlevel];}
图表显示得很好,但是当涉及到Yaxis时,它完全停止在100限制范围内。我想显示更多的间隔,以使它看起来不会被切断。
有两种方法可以实现:
- 如果您想手动为轴设置范围(如当前所做的那样(,则只需增加范围,例如到103。tick标签不应受到影响。
- 如果您很乐意让图表确定范围,则可以使用
rangePaddingHigh
属性调整添加了多少填充范围。
我希望有帮助!