iphone - Core plot majorIntervalLength : unable to make it work -
am trying plot simple graph (cannot tough! have used core plot before!). have dates plotted in x-axis. , small float values in y-axis, 0.139503, 0.139481, etc. have plot 5 such values (which fetch backend). y-axis range, finding lowest of these values , setting start of y-axis range. , setting majorintervallength (highestvalue - lowestvalue)/5, (for example) 0.007946. y-axis interval seems fixed @ interval of 1. so, since y-axis values small (difference between them in order of 0.01), plots being drawn @ y=0.0. here's code snippet :
-(void) initializegraph { if ((self.graph == nil) || (self.graph == null)) { self.graphhostview = [(cptgraphhostingview *) [cptgraphhostingview alloc] initwithframe:self.view.bounds]; self.graph = [[cptxygraph alloc] initwithframe:self.graphhostview.bounds]; graph.paddingleft = 2.0; graph.paddingright = 2.0; graph.paddingtop = 2.0; graph.paddingbottom = 2.0; graph.title = @"graph plot"; // plotting style set line plots cptmutablelinestyle *linestyle = [cptmutablelinestyle linestyle]; linestyle.linecolor = [cptcolor blackcolor]; linestyle.linewidth = 2.0f; cptxyaxisset *axisset = (cptxyaxisset *) self.graph.axisset; axisset.xaxis.majorticklinestyle = linestyle; axisset.xaxis.majorticklength = 7.0f; axisset.xaxis.labelingpolicy = cptaxislabelingpolicyequaldivisions; axisset.yaxis.labelingpolicy = cptaxislabelingpolicyequaldivisions; axisset.xaxis.labelrotation = 90.0; cptxyplotspace *plotspace = (cptxyplotspace *) self.graph.defaultplotspace; // determine lowest , highest values plotted in y axis) cgfloat ylow = 0.1; cgfloat yhigh = ylow; (int i=0 ; i<self.dict.count ; i++) { mycustomobject *mydata = (mycustomobject *) [dict objectforkey: [self.arraykeys objectatindex:i]]; if (mydata.mem < ylow) { ylow = mydata.mem; } if (yhigh < mydata.mem) { yhigh = mydata.mem; } } plotspace.xrange = [cptplotrange plotrangewithlocation:cptdecimalfromfloat(0) length:cptdecimalfromfloat(5)]; plotspace.yrange = [cptplotrange plotrangewithlocation:cptdecimalfromfloat(ylow) length:cptdecimalfromfloat(5)]; // determine point graph starts //axisset.yaxis.orthogonalcoordinatedecimal = cptdecimalfromfloat(ylow); axisset.yaxis.majorintervallength = cptdecimalfromcgfloat((yhigh-ylow)/5.0); nslog(@"y axis interval : %f", (yhigh-ylow)/5.0); ... } -(nsnumber *) numberforplot:(cptplot *)plot field:(nsuinteger)fieldenum recordindex:(nsuinteger)index { if ( fieldenum == cptscatterplotfieldy ) { return [nsnumber numberwithfloat:mydata.mem]; } else { return [nsnumber numberwithint:index]; } } why majorintervallength y axis setting not working?
are setting axisset.yaxis.majorticklength anywhere? don't see in code above.
if majorticklength nil nothing show tick's.
Comments
Post a Comment