iphone - Unable to display the bars in bar chart? -


- (void)constructbarchart {     // create barchart theme     barchart = [[cptxygraph alloc] initwithframe:cgrectzero];     cpttheme *theme = [cpttheme themenamed:kcptdarkgradienttheme];     [barchart applytheme:theme];     barchartview.hostedgraph = barchart;     barchart.plotareaframe.maskstoborder = no;      barchart.paddingleft = 70.0;     barchart.paddingtop = 20.0;     barchart.paddingright = 20.0;     barchart.paddingbottom = 80.0;      // add plot space horizontal bar charts     cptxyplotspace *plotspace = (cptxyplotspace *)barchart.defaultplotspace;     plotspace.yrange = [cptplotrange plotrangewithlocation:cptdecimalfromfloat(0.0f) length:cptdecimalfromfloat(300.0f)];       plotspace.xrange = [cptplotrange plotrangewithlocation:cptdecimalfromfloat(0.0f) length:cptdecimalfromfloat(5.0f)];      cptxyaxisset *axisset = (cptxyaxisset *)barchart.axisset;     cptxyaxis *x = axisset.xaxis;     x.axislinestyle = nil;     x.majorticklinestyle = nil;     x.minorticklinestyle = nil;     x.majorintervallength = cptdecimalfromstring(@"5");     x.orthogonalcoordinatedecimal = cptdecimalfromstring(@"0");     x.title = @"x axis";     x.titlelocation = cptdecimalfromfloat(7.5f);     x.titleoffset = 55.0f;      // define custom labels data elements     x.labelrotation = m_pi/4;     x.labelingpolicy = cptaxislabelingpolicynone;     //nsarray *customticklocations = [nsarray arraywithobjects:[nsdecimalnumber numberwithint:1], [nsdecimalnumber numberwithint:5], [nsdecimalnumber numberwithint:10], [nsdecimalnumber numberwithint:15], nil];      nsarray *customticklocations = [nsarray arraywithobjects:[nsdecimalnumber numberwithint:1], [nsdecimalnumber numberwithint:2],[nsdecimalnumber numberwithint:3],[nsdecimalnumber numberwithint:4],[nsdecimalnumber numberwithint:5],nil];      nsarray *xaxislabels = [nsarray arraywithobjects:@"label a", @"label b", @"label c", @"label d", @"label e", nil];       barchardata = [[nsmutablearray alloc]initwithobjects:[nsdecimalnumber numberwithint:30], [nsdecimalnumber numberwithint:30],[nsdecimalnumber numberwithint:40],[nsdecimalnumber numberwithint:50],[nsdecimalnumber numberwithint:100],nil];       nsuinteger labellocation = 0;     nsmutablearray *customlabels = [nsmutablearray arraywithcapacity:[xaxislabels count]];     (nsnumber *ticklocation in customticklocations)      {         cptaxislabel *newlabel = [[cptaxislabel alloc] initwithtext: [xaxislabels objectatindex:labellocation++] textstyle:x.labeltextstyle];         newlabel.ticklocation = [ticklocation decimalvalue];         newlabel.offset = x.labeloffset + x.majorticklength;         newlabel.rotation = m_pi/4;         [customlabels addobject:newlabel];         [newlabel release];     }      x.axislabels =  [nsset setwitharray:customlabels];      cptxyaxis *y = axisset.yaxis;     y.axislinestyle = nil;     y.majorticklinestyle = nil;     y.minorticklinestyle = nil;     y.majorintervallength = cptdecimalfromstring(@"50");     y.orthogonalcoordinatedecimal = cptdecimalfromstring(@"0");     y.title = @"y axis";     y.titleoffset = 45.0f;     y.titlelocation = cptdecimalfromfloat(150.0f);       /*     // first bar plot     cptbarplot *barplot = [cptbarplot tubularbarplotwithcolor:[cptcolor darkgraycolor] horizontalbars:no];      barplot.basevalue = cptdecimalfromstring(@"0");     barplot.datasource = self;     barplot.baroffset = cptdecimalfromfloat(-0.25f);     barplot.identifier = @"bar plot 1";     [barchart addplot:barplot toplotspace:plotspace];     */      // second bar plot     cptbarplot *barplot = [cptbarplot tubularbarplotwithcolor:[cptcolor bluecolor] horizontalbars:no];     barplot.datasource = self;     barplot.basevalue = cptdecimalfromstring(@"0");     barplot.baroffset = cptdecimalfromfloat(0.25f);     barplot.barcornerradius = 2.0f;     barplot.identifier = @"bar plot 2";     barplot.delegate = self;     [barchart addplot:barplot toplotspace:plotspace]; }      -(nsnumber *)numberforplot:(cptplot *)plot field:(nsuinteger)fieldenum recordindex:(nsuinteger)index      {         nsdecimalnumber *num = nil;               printf("\n  ====================index =====%d",index);             if(fieldenum == cptbarplotfieldbarlocation )             {                 num = [barchardata objectatindex:index];             }             else             {                 num = [barchardata objectatindex:index];             }             nslog(@"\n  ====================num =====%@",num);          }           return num;     } 

i unable display bars in bar chart. getting console out put this

  ====================index =====0 2011-07-21 12:51:00.692 cpttestapp-ipad[1004:207]    ====================num =====30    ====================index =====1 2011-07-21 12:51:00.693 cpttestapp-ipad[1004:207]    ====================num =====30    ====================index =====2 2011-07-21 12:51:00.694 cpttestapp-ipad[1004:207]    ====================num =====40    ====================index =====3 2011-07-21 12:51:00.695 cpttestapp-ipad[1004:207]    ====================num =====50    ====================index =====4 2011-07-21 12:51:00.696 cpttestapp-ipad[1004:207]    ====================num =====100    ====================index =====0 2011-07-21 12:51:00.697 cpttestapp-ipad[1004:207]    ====================num =====30    ====================index =====1 2011-07-21 12:51:00.698 cpttestapp-ipad[1004:207]    ====================num =====30    ====================index =====2 2011-07-21 12:51:00.699 cpttestapp-ipad[1004:207]    ====================num =====40    ====================index =====3 2011-07-21 12:51:00.699 cpttestapp-ipad[1004:207]    ====================num =====50    ====================index =====4 2011-07-21 12:51:00.700 cpttestapp-ipad[1004:207]    ====================num =====100 

in numberforplot:field:recordindex method, when field cptbarplotfieldbarlocation should return index instead of [barchardata objectatindex:index].


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -