Note that there are some explanatory texts on larger screens.

plurals
  1. POCorePlot - CPTTimeFormatter gives me the same time for every element of my bar plot
    primarykey
    data
    text
    <p>I have a graph using Core-plot (CPTBarPlot) and I want to show days on the X axis, a different day for each bar in order. I have tried to set up CPTTimeFormatter as follows where x is my x axis.</p> <pre><code> NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init] ; dateFormatter.dateStyle = kCFDateFormatterMediumStyle; CPTTimeFormatter *timeFormatter = [[CPTTimeFormatter alloc] initWithDateFormatter:dateFormatter]; NSDate *refDate = [NSDate date]; timeFormatter.referenceDate = refDate; x.labelFormatter = timeFormatter; </code></pre> <p>Inside of numbersForPlot I am returning a set of numbers representing the elapsed seconds, and since I want to have sequential days it looks like 0, 86400, 172800, 259200, 345600, 432000, 518400 etc. </p> <p>I expected the X axis labels in this case to be sequential list of dates starting at refDate and going up by the number of seconds in numbersForPlot. Instead all I see is the same date repeating over and over for every bar on the x axis. Can anybody explain to me what I am doing wrong and how I might be able to fix it? thanks.</p> <p>EDIT: this is what my numbersForPlot function looks like inside my datasource:</p> <pre><code>-(NSArray *)numbersForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange { NSArray *nums = nil; switch ( fieldEnum ) { case CPTBarPlotFieldBarLocation: nums = [NSMutableArray arrayWithCapacity:indexRange.length]; for ( NSUInteger i = indexRange.location; i &lt; 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; } </code></pre> <p>The relevant part is case CPTBarPlotFieldBarLocation which returns n array of values which I believe is correct...</p> <p>NUMS = ( 0, 86400, 172800, 259200, 345600, 432000, 518400 )</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload