如何在核心情节饼图中心添加图片和标题?
How to add image and title in the centre of core plot pie chart?
我需要在甜甜圈饼图的中心添加图像和标签。我使用核心图来绘制饼图。如何获取饼图的中心?
请看图
Donut pie chat
提前致谢。
将centerAnchor
中的坐标乘以绘图区域大小的相应部分bounds
,然后将其添加到x
或y
坐标中边界 origin
。您可以使用计算出的点作为图层注释的锚点。
饼图在画图时是这样计算中心的:
CPTPlotArea *thePlotArea = self.plotArea;
CGRect plotAreaBounds = thePlotArea.bounds;
CGPoint anchor = self.centerAnchor;
CGPoint centerPoint = CPTPointMake(plotAreaBounds.origin.x + plotAreaBounds.size.width * anchor.x,
plotAreaBounds.origin.y + plotAreaBounds.size.height * anchor.y);
centerPoint = [self convertPoint:centerPoint fromLayer:thePlotArea];
if ( self.alignsPointsToPixels ) {
centerPoint = CPTAlignPointToUserSpace(context, centerPoint);
}
我需要在甜甜圈饼图的中心添加图像和标签。我使用核心图来绘制饼图。如何获取饼图的中心?
请看图 Donut pie chat
提前致谢。
将centerAnchor
中的坐标乘以绘图区域大小的相应部分bounds
,然后将其添加到x
或y
坐标中边界 origin
。您可以使用计算出的点作为图层注释的锚点。
饼图在画图时是这样计算中心的:
CPTPlotArea *thePlotArea = self.plotArea;
CGRect plotAreaBounds = thePlotArea.bounds;
CGPoint anchor = self.centerAnchor;
CGPoint centerPoint = CPTPointMake(plotAreaBounds.origin.x + plotAreaBounds.size.width * anchor.x,
plotAreaBounds.origin.y + plotAreaBounds.size.height * anchor.y);
centerPoint = [self convertPoint:centerPoint fromLayer:thePlotArea];
if ( self.alignsPointsToPixels ) {
centerPoint = CPTAlignPointToUserSpace(context, centerPoint);
}