Monday 15 September 2014

ios7.1 - Core Plot 1.4 - Reduce the gap between Y-axis and X-axis labels -



ios7.1 - Core Plot 1.4 - Reduce the gap between Y-axis and X-axis labels -

i trying implement core plot in ios application. there many issues facing.i going list 1 one.

1)when app runs should start graph showing origin (0,0). because @ nowadays displaying somewhere not visible. changed below boolean value yes , scrolled , saw the line way above origin.

"plotspace.allowsuserinteraction = yes;

2)i can manually adjust space between 2 points on x-axis , y-axis lines.

here code tried next rey wenderlich tutorial plot graph, see in image can see 1 line. others lines need drag , downwards see others lines. , special eric skroch , team wonderful work.

//////// configure x-axes cptxyaxis *xaxis = [axisset xaxis]; cptaxis *x = axisset.xaxis; x.title = @""; x.titletextstyle = axistitlestyle; x.titleoffset = 5.0f; x.labeloffset = 5.0f; x.axislinestyle = axislinestyle; x.labelingpolicy = cptaxislabelingpolicyautomatic; x.labeltextstyle = axistextstyle; x.majorticklinestyle = axislinestyle; x.majorticklength = 4.0f; x.labelrotation=45.0f; cgfloat datecount = [dayarray count]; nsmutableset *xlabels = [nsmutableset setwithcapacity:datecount]; nsmutableset *xlocations = [nsmutableset setwithcapacity:datecount]; nsinteger = 0; (nsstring *date in dayarray) { cptaxislabel *label = [[cptaxislabel alloc] initwithtext:date textstyle:x.labeltextstyle]; cgfloat location = i++; label.ticklocation = cptdecimalfromcgfloat(location); label.offset = x.majorticklength; if (label) { [xlabels addobject:label]; [xlocations addobject:[nsnumber numberwithfloat:location]]; } } x.axislabels = xlabels; x.majorticklocations = xlocations; //////// configure y-axes cptaxis *y = axisset.yaxis; y.title = @"hb"; y.titletextstyle = axistitlestyle; y.titleoffset = -50.0f; y.axislinestyle = axislinestyle; y.majorgridlinestyle = gridlinestyle; y.labelingpolicy = cptaxislabelingpolicylocationsprovided; y.labeltextstyle = axistextstyle; y.labeloffset = -0.0f; y.majorticklinestyle = axislinestyle; y.majorticklength = 1.0f; y.minorticklength = 1.0f; nsinteger majorincrement = 2; nsinteger minorincrement = 2; cgfloat ymax = 30.0f; nsmutableset *ylabels = [nsmutableset set]; nsmutableset *ymajorlocations = [nsmutableset set]; nsmutableset *yminorlocations = [nsmutableset set]; (nsinteger j = 0; j <= ymax; j += minorincrement) { nsuinteger mod = j % majorincrement; if (mod == 0) { cptaxislabel *label = [[cptaxislabel alloc] initwithtext:[nsstring stringwithformat:@"%i", j] textstyle:y.labeltextstyle]; nsdecimal location =cptdecimalfrominteger(j); label.ticklocation =location; label.offset = -y.majorticklength- y.labeloffset; if (label) { [ylabels addobject:label]; } [ymajorlocations addobject:[nsdecimalnumber decimalnumberwithdecimal:location]]; } else { [yminorlocations addobject:[nsdecimalnumber decimalnumberwithdecimal:cptdecimalfrominteger(j)]]; } } y.axislabels = ylabels; y.majorticklocations = ymajorlocations;

if want provide custom axis labels, alter labelingpolicy:

x.labelingpolicy = cptaxislabelingpolicynone; y.labelingpolicy = cptaxislabelingpolicynone;

the automatic labeling policy sets tick locations , labels automatically "nice" values based on length of plot range. locations provided policy automatically creates labels @ tick locations provide.

core-plot ios7.1 linechart

No comments:

Post a Comment