如何使用 iphone sdk 中的核心绘图库包装添加到绘图中的文本

发布于 2024-12-11 11:23:01 字数 902 浏览 0 评论 0原文

我已经像这样向饼图添加了标签 -(CPTLayer *)dataLabelForPlot:(CPTPlot *)绘图记录索引:(NSUInteger)索引 {

CPTTextLayer *newLayer = nil;
UIFont *theFont;

static CPTMutableTextStyle *whiteText = nil;

if ( !whiteText )
{
    whiteText = [[CPTMutableTextStyle alloc] init];
    whiteText.color = [CPTColor blackColor];
    whiteText.textAlignment = CPTTextAlignmentCenter;
    whiteText.fontName = @"Helvetica-Bold";
    whiteText.fontSize =  10.0f;
   theFont = [UIFont fontWithName:whiteText.fontName size:whiteText.fontSize];


}
if ( [plot isKindOfClass:[CPTPieChart class]] ) 
{
    newLayer.delegate = self;
    newLayer = [[[CPTTextLayer alloc] initWithText:[NSString stringWithFormat:@"%@", [pieChartData2 objectAtIndex:index]] style:whiteText] autorelease];
      }

return newLayer;
    }

我想要的是 (1)我想将太长的文本换行。 (2) 我想显示切片标题及其值。 (3) 我需要在 title 和 Slice 上画一条线。 请任何人帮助我。

提前致谢

I had added labels to the pie chart like this
-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index
{

CPTTextLayer *newLayer = nil;
UIFont *theFont;

static CPTMutableTextStyle *whiteText = nil;

if ( !whiteText )
{
    whiteText = [[CPTMutableTextStyle alloc] init];
    whiteText.color = [CPTColor blackColor];
    whiteText.textAlignment = CPTTextAlignmentCenter;
    whiteText.fontName = @"Helvetica-Bold";
    whiteText.fontSize =  10.0f;
   theFont = [UIFont fontWithName:whiteText.fontName size:whiteText.fontSize];


}
if ( [plot isKindOfClass:[CPTPieChart class]] ) 
{
    newLayer.delegate = self;
    newLayer = [[[CPTTextLayer alloc] initWithText:[NSString stringWithFormat:@"%@", [pieChartData2 objectAtIndex:index]] style:whiteText] autorelease];
      }

return newLayer;
    }

What I want here is
(1)I want to wrap the text which is too long.
(2) I want to display the the Slice title and and its value .
(3) I need to draw a line to title and Slice .
Please any one help me.

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

提笔书几行 2024-12-18 11:23:01
  1. 您可以在文本中插入换行符 ('\n') 以换行到下一行。 Core Plot 不会自动换行任何文本。

  2. 这是一个数据源方法 - 它应该能够访问数据值和标题。使用两者来构建标签字符串。

  3. 尚不支持在标签上绘制线条。您可以创建 CPTTextLayer 的自定义子类,除了文本之外还绘制线条,并使用它代替库存 CPTTextLayer 来制作标签。

  1. You can insert newline characters ('\n') in the text to wrap to the next line. Core Plot does not auto-wrap any text.

  2. This is a datasource method—it should have access to the data values and the title. Use both to build the label string.

  3. Drawing lines to a label is not supported yet. You could make a custom subclass of CPTTextLayer that draws the line in addition to the text and use that instead of the stock CPTTextLayer to make the labels.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文