views:

91

answers:

2

I am testing a CPPieChart and finding that the data source delegate method -sliceLabelForPieChart:recordIndex: is not displaying a slice label.

In addition, there is no title property for the pie chart type.

So I figured I would test using a UILabel instance:

UILabel *viewTitle = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 24.0f)];
viewTitle.text = @"Total Space";
[hostingView addSubview:viewTitle];
[viewTitle release];

Interestingly, it looks like the label coordinates are inverted and the text is mirrored:

alt text

What is the best way to resolve the coordinate system inversion and text mirroring?

+1  A: 

Sorry about that. At some point, I need to finish the implementation of that chart type.

The reason the UILabel is being flipped is that we host the Core Plot graphs within a UIView that inverts its layer's coordinate system. This is done to preserve the same coordinate system between Mac and iPhone for the framework (based on the normal Quartz coordinate system where 0,0 is the bottom left).

Instead of adding a UILabel to the graph, you could directly add a CPTextLayer to the graph layer (or one of the other layers in the display hierarchy). CPTextLayers play within the standard coordinate space of the Core Plot graphs, so they should render properly.

Brad Larson
No worries and thanks for the detailed answer! I'll try out the CPTextLayer option.
Alex Reynolds
A: 

Slice labels are not implemented--that delegate method exists to define the interface, but is not used yet.

We recently added the ability to add titles to the graph but not individual plots. The iPhone version of CPTestApp adds a title to the bar chart to show how it's done.

Eric Skroch
I looked at the bar chart in the `CPTestApp` for the iPhone, but unlike the bar chart I don't believe that `CPPieChart` has a `title` property.
Alex Reynolds
It's not on the plot, the `title` property is on the graph itself.
Eric Skroch
I was confused. I think I see it now: the pie chart is its own `CPPieChart` object, but the bar chart is an instance of `CPXYGraph` in the test app. The pie chart is added to a `CPXYGraph` instance.
Alex Reynolds