nsinvocation
nsinvocation

Reputation: 7637

Multiple colors for CPTXYAxis's labelTextStyle

CPTMutableTextStyle *xLabelTextStyle = [CPTMutableTextStyle textStyle];
xLabelTextStyle.color = [CPTColor redColor];

CPTXYAxis *x = axisSet.xAxis;
x.labelTextStyle = xLabelTextStyle;

Using above code all x-axis labels text became red. My goal is to set multiple colors for these labels, some labels may be blue, other may be yellow, etc. How can I achieve this in Core Plot ?

Upvotes: 0

Views: 161

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

You have at least two options:

  1. Use custom axis labels. Each label can use a different text style.

  2. Create a custom subclass of NSNumberFormatter to use for the axis labelFormatter. Override the -attributedStringForObjectValue:withDefaultAttributes: method and have it return appropriately styled text for each label.

Upvotes: 1

Related Questions