我正在使用核心图库在我的iPhone应用程序上绘制条形图,当我尝试向图表添加标签或其他视图时出现问题,
实际上我添加的视图是垂直反转的,就像这样........
代码就像
UILabel *lbl= [[UILabel alloc] initWithFrame:CGRectMake(250, 90, 70, 25)];
[lbl setBackgroundColor:[UIColor redColor]];
[lbl setText:@"HELLO"];
[self.view addSubview:lbl];
[lbl release];
Run Code Online (Sandbox Code Playgroud)
我不敢玩核心图库.
那么有没有其他方法来做正确的事情?我应该在添加视图之前进行转换吗?
如果这是解决方案,那么这将是昂贵的,因为我必须添加多个子视图.
希望我的问题对每个人都清楚.
我正在尝试一个核心情节iphone示例,我得到:
没有要编译的体系结构(ONLY_ACTIVE_ARCH = YES,活动arch = i386,VALID_ARCHS = armv6 armv7).
在项目设置 - >体系结构下,唯一的选项是标准,优化和本机arch.
有任何想法吗?
谢谢.
当我尝试编译以下代码时,我收到以下错误:
由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [UIView setHostedGraph:]:无法识别的选择器发送到实例0x6768c10'
码:
UIView *ChartView;
ChartView = [[UIView alloc] init];
graph = [[CPXYGraph alloc] initWithFrame: ChartView.bounds];
CPGraphHostingView *hostingView = (CPGraphHostingView *)ChartView;
hostingView.hostedGraph = graph;
Run Code Online (Sandbox Code Playgroud)
可能有什么不对?
这是我的代码.X轴标签未显示.我正在使用核心情节.
scatterGraph = [[CPXYGraph alloc] initWithFrame:CGRectZero];
CPTheme *theme = nil;
[scatterGraph applyTheme:theme];
hostView.hostedGraph = scatterGraph;
hostView.backgroundColor = [UIColor clearColor];
hostView.collapsesLayers = NO;
scatterGraph.paddingTop = 25.0;
scatterGraph.paddingRight = 25.0;
scatterGraph.paddingLeft = 25.0;
scatterGraph.paddingBottom = 25;
scatterGraph.plotAreaFrame.masksToBorder = NO;
CPXYPlotSpace *scatterPlot = (CPXYPlotSpace *) scatterGraph.defaultPlotSpace;
scatterPlot.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0) length:CPDecimalFromInt(yCount)];
float xx = [self findMax:LivePriceFeedArray] - [self findMin:LivePriceFeedArray]+1.0;
scatterPlot.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat([self findMin:LivePriceFeedArray]-0.5) length:CPDecimalFromFloat(xx)];
CPXYAxisSet *axisSet =(CPXYAxisSet *) scatterGraph.axisSet;
CPXYAxis *xAxis = axisSet.xAxis;
axisSet.delegate = self;
xAxis.title = @"Days";
xAxis.titleLocation = CPDecimalFromFloat(4.0f); …Run Code Online (Sandbox Code Playgroud) 使用此功能
- (void)scatterPlot:(CPTScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)index
Run Code Online (Sandbox Code Playgroud)
我可以为选定的点添加注释,尽管用手指在iPad或iPhone上选择图表上的一个点是很困难的.反正有没有让这个功能更宽容手指指针设备而不是鼠标?
我有一个iPhone项目,在Core Plot中显示过去24小时的一些数据.x轴表示时间,y轴表示数据值.现在我想通过在午夜画一条垂直线来突出显示一天的变化.如何才能做到这一点?
试图为我的gridLines获得一个简单的虚线但是,无法使其工作(目前是实线).在互联网上没有太多帮助!
CPTMutableLineStyle *gridLineStyle = [CPTMutableLineStyle lineStyle];
gridLineStyle.lineColor = [self axisGreyClr];
//gridLineStyle.lineWidth = 1.0f;
gridLineStyle.dashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.8f], nil];
gridLineStyle.patternPhase=0.0f;
Run Code Online (Sandbox Code Playgroud) 我正在使用核心图框架来创建带有图例的条形图.这一切都有效,除了图例复制了条形图每个部分中的列(请参阅随附的屏幕截图).

我查看了核心情节类引用,但无法找到解决此问题的任何内容.我试图将CPTLegend属性numberOfColumns设置为1,将numberOfRows设置为3,并使图例在图例中显示相应数量的项目,但它显示的数据不正确.

下面是我用来构建条形图的代码.你们对我如何解决这个问题有什么建议吗?我假设这不是核心情节的错误,而是传说的局限性,我希望有一个解决方法.
// Create barChart from theme
barChart = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[barChart applyTheme:theme];
chartView.hostedGraph = barChart;
barChart.plotAreaFrame.masksToBorder = NO;
barChart.paddingLeft = 60.0;
barChart.paddingTop = 10.0;
barChart.paddingRight = 0.0;
barChart.paddingBottom = 30.0;
//find max y
int maxY = 0;
NSMutableArray *maxDrillDownData = [chartData.drillDownData objectForKey:DRILLDOWN_EQUIPMENT_ALL_TYPE];
for (NSMutableArray *dataArray in maxDrillDownData) {
maxY = dataArray.count>maxY?dataArray.count:maxY;
}
//add buffer
maxY = maxY+100;
// Add plot space for horizontal bar charts
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)barChart.defaultPlotSpace;
plotSpace.yRange = …Run Code Online (Sandbox Code Playgroud) CPTXYGraph *graph = [[CPTXYGraph alloc]initWithFrame:self.hostingView.frame];
graph.borderColor = [CPTColor whiteColor].cgColor;
graph.paddingTop = 0.0f;
graph.paddingRight = 0.0f;
graph.paddingLeft = 0.0f;
graph.paddingBottom = 0.0f;
self.hostingView.hostedGraph = graph;
graph.axisSet = nil;
//Apply for theme to graph
self.graphTheme = [CPTTheme themeNamed:kCPTPlainWhiteTheme];
[graph applyTheme:self.graphTheme];
[graph release];
CPTPieChart *pieChart = [[CPTPieChart alloc]init];
pieChart.identifier = @"OverView";
pieChart.dataSource = self;
pieChart.sliceDirection = CPTPieDirectionClockwise;
pieChart.pieRadius = ((self.hostingView.frame.size.height / 2) - 5);
pieChart.startAngle = M_PI;
CPTGraph *tempGraph = self.hostingView.hostedGraph;
[tempGraph addPlot:pieChart];
[pieChart release];
Run Code Online (Sandbox Code Playgroud)
对于这个代码我得到黑色边框,我认为这是由于graph axisSet但我不知道如何删除.
我把core-plot 1.4标头放入我的项目,添加库,添加quartz-core,加速,-ObjC在链接器标志上但是如果我尝试编译我得到这个错误:

core-plot ×10
ios ×5
iphone ×4
objective-c ×2
uiview ×2
bar-chart ×1
compilation ×1
point ×1
scatter-plot ×1
select ×1
transform ×1
xcode5 ×1