ios - CorePlot - CPTTimeFormatter gives me the same time for every element of my bar plot -


i have graph using core-plot (cptbarplot) , want show days on x axis, different day each bar in order. have tried set cpttimeformatter follows x x axis.

    nsdateformatter *dateformatter = [[nsdateformatter alloc] init] ;     dateformatter.datestyle = kcfdateformattermediumstyle;     cpttimeformatter *timeformatter = [[cpttimeformatter alloc] initwithdateformatter:dateformatter];     nsdate *refdate = [nsdate date];      timeformatter.referencedate = refdate;     x.labelformatter = timeformatter; 

inside of numbersforplot returning set of numbers representing elapsed seconds, , since want have sequential days looks 0, 86400, 172800, 259200, 345600, 432000, 518400 etc.

i expected x axis labels in case sequential list of dates starting @ refdate , going number of seconds in numbersforplot. instead see same date repeating on , on every bar on x axis. can explain me doing wrong , how might able fix it? thanks.

edit: numbersforplot function looks inside datasource:

-(nsarray *)numbersforplot:(cptplot *)plot field:(nsuinteger)fieldenum recordindexrange:(nsrange)indexrange {        nsarray *nums = nil;      switch ( fieldenum ) {         case cptbarplotfieldbarlocation:             nums = [nsmutablearray arraywithcapacity:indexrange.length];             ( nsuinteger = indexrange.location; < nsmaxrange(indexrange); i++ ) {                 [(nsmutablearray *)nums addobject :[nsdecimalnumber numberwithunsignedinteger:i*secondsperday]];             }             nslog(@"nums  = %@",nums);              break;          case cptbarplotfieldbartip:             nums = [stepsperday objectsatindexes:[nsindexset indexsetwithindexesinrange:indexrange]];             break;          default:             break;     }      return nums; } 

the relevant part case cptbarplotfieldbarlocation returns n array of values believe correct...

nums = ( 0, 86400, 172800, 259200, 345600, 432000, 518400 )

your formatter code looks correct. make sure datasource returning correct x-values, e.g., 0, 86400, 172800, etc. values 1 day apart.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -