0
我正在用coreplot製作應用程序,並試圖讓我的標籤沿Xaxis讀取12pm,1pm,2pm等。我已成功將NSDateFormatter實現到xAxis.label格式器中。CorePlot:xAxis NSDateFormatter麻煩
問題是,間隔時間似乎以秒爲單位(見下圖)我需要他們在幾個小時內。
我試圖通過使xAxis.majorIntervalLength 3600解決這個問題,但這只是使圖形看起來就像這樣:
蜱是史迪威那裏,但現在他們如果這是合理的,那麼就把3600放在一起。這裏是我的代碼:
CPTXYAxisSet *faxisSet = (CPTXYAxisSet *)self.graph.axisSet;
faxisSet.xAxis.title = @"Time";
faxisSet.xAxis.titleTextStyle = textStyle;
faxisSet.xAxis.titleOffset = 30.0f;
faxisSet.xAxis.axisLineStyle = axislineStyle;
faxisSet.xAxis.majorTickLineStyle = axislineStyle;
faxisSet.xAxis.minorTickLineStyle = axislineStyle;
faxisSet.xAxis.labelTextStyle = textStyle;
faxisSet.xAxis.labelOffset = 3.0f;
faxisSet.xAxis.majorIntervalLength = CPTDecimalFromFloat(3600.0f);
faxisSet.xAxis.minorTicksPerInterval = 1;
faxisSet.xAxis.minorTickLength = 5.0f;
faxisSet.xAxis.majorTickLength = 7.0f;
NSString *dats1 = @"16";
NSDateFormatter *dateFormatter3 = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter3 setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter3 setDateFormat:@"hh:mm:ss a"];
CPTTimeFormatter *timeFormatter = [[CPTTimeFormatter alloc]initWithDateFormatter:dateFormatter3];
timeFormatter.referenceDate = [dateFormatter3 dateFromString:dats1];
faxisSet.xAxis.labelFormatter = timeFormatter;
基本上,我想有每一個其他刻度讀取小時,但我想他們除了保持相同的距離。
我會感謝任何幫助,謝謝!
謝謝,完美無缺! – pj409 2013-04-05 01:08:16