ios - 如何在核心情节饼图中心添加图片和标题?

标签 ios xcode swift core-plot cppiechart

我需要在圆环饼图的中心添加图像和标签。我使用核心图来绘制饼图。如何获取饼图的中心?

请看图片 Donut pie chat

提前致谢。

最佳答案

centerAnchor 中的坐标乘以绘图区域 bounds 大小的相应部分,并将其添加到 xy 边界的坐标 origin。您可以使用计算出的点作为图层注释的 anchor 。

饼图在画图的时候是这样计算中心的:

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);
}

关于ios - 如何在核心情节饼图中心添加图片和标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33730303/

相关文章:

iPhone 影音播放器

ios - NSMutableArray removeAllObjects 崩溃

ios - 使用上下尾随和前导时,将 uilabel 中的文本与标签顶部对齐

ios - 如何在 Google Cloud Platform 中启动 macOS 实例?我需要 mac 实例来运行 xamarin ios 应用程序的 xcode 构建

ios - Swift 3 - 异步显示警报 Controller ,长函数在后台运行

ios - ClassicURLConnection exc_bad_access错误。的iOS

iOS - Diceroll 增加一个对象的出现频率

ios - 在 View Controller /页面 View Controller 中全屏显示图像(快速)

ios - 错误: "Thread 1: EXC_BAD_ACCESS(Code=EXC_I386_GPFLT)

android - 用于应用程序下载和卸载计数 + 应用程序评级的 Google Play 商店 API