ios - Losing the x-axis tick titles on coreplot -


my x axis tick mark labels seem disappear on own. show fine other times gone view. assume has data scaling i've tried lots of things , can fixed. code follows (i pretty copied directly 1 of examples). values positive. please let me know if have suggestions. thanks.

-(void)configurehostfour {     self.hostview = [(cptgraphhostingview *) [cptgraphhostingview alloc] initwithframe:self.view.bounds];     self.hostview.allowpinchscaling = yes;     [self.myviewfour addsubview:self.hostview];     cptgraphhostingview *bargraphview = [[cptgraphhostingview alloc] init];     self.hostview.frame = cgrectmake(self.myviewfour.bounds.origin.x, self.myviewfour.bounds.origin.y, self.myviewfour.bounds.size.width, self.myviewfour.bounds.size.height);     [self.hostview addsubview:bargraphview]; }  -(void)configuregraphfour {     // 1 - create graph     cptgraph *graph = [[cptxygraph alloc] initwithframe:self.hostview.bounds];     //        [graph applytheme:[cpttheme themenamed:kcptslatetheme]];     [graph applytheme:[cpttheme themenamed:kcptplainwhitetheme]];      self.hostview.hostedgraph = graph;     // 2 - set graph title     nsstring *title = @"heart rate";     graph.title = title;     // 3 - create , set text style     cptmutabletextstyle *titlestyle = [cptmutabletextstyle textstyle];     titlestyle.color = [cptcolor blackcolor];     titlestyle.fontname = @"helvetica-bold";     titlestyle.fontsize = 12.0f;     graph.titletextstyle = titlestyle;     graph.titleplotareaframeanchor = cptrectanchortop;     graph.titledisplacement = cgpointmake(0.0f, 17.0f);     // 4 - set padding plot area     [graph.plotareaframe setpaddingleft:1.0f];     [graph.plotareaframe setpaddingbottom:1.0f];     // 5 - enable user interactions plot space     cptxyplotspace *plotspace = (cptxyplotspace *) graph.defaultplotspace;     plotspace.allowsuserinteraction = yes; }  -(void)configureplotsfour {     // 1 - graph , plot space     cptgraph *graph = self.hostview.hostedgraph;     cptxyplotspace *plotspace = (cptxyplotspace *) graph.defaultplotspace;      // 2 - create plots     cptscatterplot *hrplot = [[cptscatterplot alloc] init];     hrplot.datasource = self;     hrplot.identifier = hrscore;     cptcolor *hrcolor = [cptcolor bluecolor];     [graph addplot:hrplot toplotspace:plotspace];      cptscatterplot *avghrplot = [[cptscatterplot alloc] init];     avghrplot.datasource = self;     avghrplot.identifier = hrscoreavg;     cptcolor *avghrcolor = [cptcolor redcolor];     [graph addplot:avghrplot toplotspace:plotspace];       // 3 - set plot space     [plotspace scaletofitplots:[nsarray arraywithobjects:hrplot, avghrplot, nil]];     cptmutableplotrange *xrange = [plotspace.xrange mutablecopy];     [xrange expandrangebyfactor:cptdecimalfromcgfloat(1.1f)];     plotspace.xrange = xrange;     cptmutableplotrange *yrange = [plotspace.yrange mutablecopy];     [yrange expandrangebyfactor:cptdecimalfromcgfloat(1.2f)];     plotspace.yrange = yrange;      // 4 - create styles , symbols     cptmutablelinestyle *hrlinestyle = [hrplot.datalinestyle mutablecopy];     hrlinestyle.linewidth = 2.0;     hrlinestyle.linecolor = hrcolor;     hrplot.datalinestyle = hrlinestyle;     cptmutablelinestyle *hrsymbollinestyle = [cptmutablelinestyle linestyle];     hrsymbollinestyle.linecolor = hrcolor;      cptmutablelinestyle *avghrlinestyle = [hrplot.datalinestyle mutablecopy];     avghrlinestyle.linewidth = 2.0;     avghrlinestyle.linecolor = avghrcolor;     avghrplot.datalinestyle = avghrlinestyle;     cptmutablelinestyle *avghrsymbollinestyle = [cptmutablelinestyle linestyle];     avghrsymbollinestyle.linecolor = avghrcolor;  }  -(void)configureaxesfour{     // 1 - create styles     cptmutabletextstyle *axistitlestyle = [cptmutabletextstyle textstyle];     axistitlestyle.color = [cptcolor blackcolor];     axistitlestyle.fontname = @"helvetica-bold";     axistitlestyle.fontsize = 10.0f;     cptmutablelinestyle *axislinestyle = [cptmutablelinestyle linestyle];     axislinestyle.linewidth = .01f;     axislinestyle.linecolor = [cptcolor blackcolor];      cptmutabletextstyle *axistextstyle = [[cptmutabletextstyle alloc] init];     axistextstyle.color = [cptcolor blackcolor];     axistextstyle.fontname = @"helvetica-bold";     axistextstyle.fontsize = 9.0f;     cptmutablelinestyle *ticklinestyle = [cptmutablelinestyle linestyle];     ticklinestyle.linecolor = [cptcolor blackcolor];     ticklinestyle.linewidth = 1.0f;     cptmutablelinestyle *gridlinestyle = [cptmutablelinestyle linestyle];     ticklinestyle.linecolor = [cptcolor blackcolor];     ticklinestyle.linewidth = 1.0f;     // 2 - axis set     cptxyaxisset *axisset = (cptxyaxisset *) self.hostview.hostedgraph.axisset;     // 3 - configure x-axis     cptaxis *x = axisset.xaxis;     x.title = @"day of month";     x.titletextstyle = axistitlestyle;     x.titleoffset = 20.0f;     x.axislinestyle = axislinestyle;     x.labelingpolicy = cptaxislabelingpolicynone;     x.labeltextstyle = axistextstyle;     x.majorticklinestyle = axislinestyle;     x.majorticklength = 4.0f;     x.tickdirection = cptsignnegative;      cgfloat datecount = [self.datearray count];     nsmutableset *xlabels = [nsmutableset setwithcapacity:datecount];     nsmutableset *xlocations = [nsmutableset setwithcapacity:datecount];     nsinteger = 0;     (nsstring *date in self.datearray) {         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;      // 4 - configure y-axis     cptaxis *y = axisset.yaxis;     y.title = @"";     y.titletextstyle = axistitlestyle;     y.titleoffset = -40.0f;     y.axislinestyle = axislinestyle;     y.majorgridlinestyle = gridlinestyle;     y.labelingpolicy = cptaxislabelingpolicynone;     y.labeltextstyle = axistextstyle;     y.labeloffset = 16.0f;     y.majorticklinestyle = axislinestyle;     y.majorticklength = 4.0f;     y.minorticklength = 2.0f;     y.tickdirection = cptsignpositive;     nsinteger majorincrement = self.hrtick;     nsinteger minorincrement = self.hrhalftick;     cgfloat ymax = 700.0f;  // should determine dynamically based on max price     nsmutableset *ylabels = [nsmutableset set];     nsmutableset *ymajorlocations = [nsmutableset set];     nsmutableset *yminorlocations = [nsmutableset set];     (nsinteger j = minorincrement; j <= ymax; j += minorincrement) {         nsuinteger mod = j % majorincrement;         if (mod == 0) {             cptaxislabel *label = [[cptaxislabel alloc] initwithtext:[nsstring stringwithformat:@"%li", (long)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;     y.minorticklocations = yminorlocations; }  #pragma mark - cptplotdatasource methods -(nsuinteger)numberofrecordsforplot:(cptplot *)plot {     return [self.datearray count]; }  -(nsnumber *)numberforplot:(cptplot *)plot field:(nsuinteger)fieldenum recordindex:(nsuinteger)index {     nsinteger valuecount = [self.datearray count];     switch (fieldenum) {         case cptscatterplotfieldx:             if (index < valuecount) {                 return [nsnumber numberwithunsignedinteger:index];             }             break;          case cptscatterplotfieldy:              if ([plot.identifier isequal:hrscore] == yes) {                 nslog(@"hrscore");                 return [self.hrarray objectatindex:index];             } else if ([plot.identifier isequal:hrscoreavg] == yes) {                 nslog(@"hravg");                 return [self.avghrarray objectatindex:index];             } else if ([plot.identifier isequal:fgscore] == yes) {                 nslog(@"gfscore");                  return [self.fgarray objectatindex:index];             } else if ([plot.identifier isequal:fgscoreavg] == yes) {                 nslog(@"fgavg");                  return [self.avgfgarray objectatindex:index];             } else if ([plot.identifier isequal:weightscore] == yes) {                 nslog(@"weight");                  return [self.weightarray objectatindex:index];             } else if ([plot.identifier isequal:weightscoreavg] == yes) {                 nslog(@"weight av");                  return [self.avgweightarray objectatindex:index];             } else if ([plot.identifier isequal:mapscore] == yes) {                 nslog(@"map");                  return [self.maparray objectatindex:index];             } else if ([plot.identifier isequal:mapscoreavg] == yes) {                 nslog(@"map avg");                  return [self.avgmaparray objectatindex:index];             }              break;     }     return [nsdecimalnumber zero]; } 

the tick locations , labels being placed on integer values starting @ 0 (0). don't xrange is, if length less 1 (1) , doesn't cover 1 of tick locations, won't see ticks or labels.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -