Thursday, 15 May 2014

ios - Core Plot: Are "setLabelingPolicy:CPTAxisLabelingPolicyNone" and "setMajorGridLineStyle:majorGridLineStyle" Mutually exclusive? -



ios - Core Plot: Are "setLabelingPolicy:CPTAxisLabelingPolicyNone" and "setMajorGridLineStyle:majorGridLineStyle" Mutually exclusive? -

i trying draw custom labels , grid lines on y-axis, if set label policy cptaxislabelingpolicynone, , add together custom labels y-axis, desired labels drawn on y-axis.

[yaxis setlabelingpolicy:cptaxislabelingpolicynone];

however couldn't grid lines working.

[yaxis setmajorgridlinestyle:majorgridlinestyle];

if remove label policy none, grid lines.

wondering solution?

code setting y-axis labels:

nsmutablearray *ylabels = [nsmutablearray arraywithobjects:@"none", @"awake", @"light",@"middle",@"deep", nil]; nsmutablearray *customlabelsy = [nsmutablearray arraywithcapacity:[ylabels count]]; (int loc=1; loc <= 4; loc++) { cptaxislabel *newlabely = [[cptaxislabel alloc] initwithtext: [ylabels objectatindex:loc] textstyle:textstyle]; newlabely.ticklocation = [[nsdecimalnumber numberwithint:loc] decimalvalue]; newlabely.offset = yaxis.labeloffset + yaxis.majorticklength; [customlabelsy addobject:newlabely]; } [yaxis setaxislabels:[nsset setwitharray:customlabelsy]];

with cptaxislabelingpolicynone, app must provide tick locations (major and/or minor) if want tick marks and/or grid lines. independent of labels, can label locations don't have tick marks and/or skip of tick locations when creating labels.

edit:

keep track of locations when creating labels , set majorticklocations when done.

nsmutableset *locations = [nsmutableset set]; (int loc=1; loc <= 4; loc++) { // create labels [locations addobject:@(loc)]; } yaxis.majorticklocations = locations;

ios core-plot

No comments:

Post a Comment