1
votes

Is it possible to set a UILabel into a horizontal bar of a bar chart? (CorePlot)

Thank you!

1
Do you have to use a UILabel or do you just want to draw text inside the bar? - Eric Skroch
I just want to draw inside the bar. - DAS

1 Answers

2
votes

If you just need to label one of the bars, you can use a CPTPlotSpaceAnnotation. Set the anchorPlotPoint to a point in the bar (exactly where depends on how you want to align the label). Make a CPTTextLayer that contains the desired text and set that as the content layer for the annotation. Add the annotation to the plot.

If you want to label all (or most) of the bars, use data labels. Set the label offset to a negative value to push the labels inside the bars.