divyavamsee / core-plot

Automatically exported from code.google.com/p/core-plot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Core plot 1.1 axis labels are not displaying correctly, or updating. #481

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I also made a stackoverflow question for this:
http://stackoverflow.com/questions/13665079/coreplot-1-1-vs-1-0-axis-labels-not-
showing-correctly-and-very-slow-to-update

 0 down vote favorite

I just updated to version 1.1, and right away noticed that my axis labels are 
not displaying correctly at first, or updating properly.

In 1.0 they would load correctly (when the view first shows), and once a second 
I update the ranges (CPTPlotRange) and the data (-reloadData) and the axes and 
the data updated correctly every time. However, now with 1.1, the data and axis 
tick marks are updating correctly, but the axis labels lag behind. Sometimes I 
will see the new axis label start in the lower left corner, and over 3 seconds 
migrate to its correct location. And if the label is already there, it will lag 
behind the axis tick marks by 1 second or more.

I changed none of my code, only removed the old 1.0 files and replaced them 
with the 1.1 files. Below is all of the code related to one of the plots.

- (void) prepareGraphs {
    //Prepare beat graph
    //beatGraph defined as CPTXYGraph
    //beatGraphView defined as CPTGraphHostingView in both class and storyboard
    beatGraph = [[CPTXYGraph alloc] initWithFrame:self.beatGraphView.frame];

    self.beatGraphView.collapsesLayers = NO;
    self.beatGraphView.hostedGraph = beatGraph;

    beatGraph.paddingLeft = 0.0;
    beatGraph.paddingTop = 0.0;
    beatGraph.paddingRight = 0.0;
    beatGraph.paddingBottom = 0.0;

    CPTPlotAreaFrame *beatPlotAreaframe = (CPTPlotAreaFrame *)beatGraph.plotAreaFrame;
    beatPlotAreaframe.paddingLeft = 30;
    beatPlotAreaframe.paddingRight = 5;

    CPTXYPlotSpace *beatPlotSpace = (CPTXYPlotSpace *)beatGraph.defaultPlotSpace;
    beatPlotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) 
                        length:CPTDecimalFromFloat(31)];
    beatPlotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(75)
                        length:CPTDecimalFromFloat(20)];

    CPTXYAxisSet *beatPlotAxisSet = (CPTXYAxisSet *)beatGraph.axisSet;
    beatPlotAxisSet.xAxis.hidden = TRUE;

    beatPlotAxisSet.yAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"10"] decimalValue];
    beatPlotAxisSet.yAxis.minorTicksPerInterval = 4;
    beatPlotAxisSet.yAxis.majorTickLineStyle = lineStyleThick;
    beatPlotAxisSet.yAxis.minorTickLineStyle = lineStyleThin;
    beatPlotAxisSet.yAxis.axisLineStyle = lineStyleThick;
    beatPlotAxisSet.yAxis.minorTickLength = 4.0f;
    beatPlotAxisSet.yAxis.majorTickLength = 5.0f;
    beatPlotAxisSet.yAxis.labelOffset = 0.0f;
    beatPlotAxisSet.yAxis.labelFormatter = integerLabelFormat;

    //beat plot
    //beatPlot defined as CPTScatterPlot
    beatPlot = [[CPTScatterPlot alloc] init];
    beatPlot.identifier = @"Beat Plot";

    CPTMutableLineStyle *beatPlotLineStyle = [beatPlot.dataLineStyle mutableCopy];
    beatPlotLineStyle.lineWidth = 1.0f;
    beatPlotLineStyle.lineColor = [CPTColor redColor];
    beatPlot.dataLineStyle = beatPlotLineStyle;

    CPTPlotSymbol *beatPlotSymbol = [CPTPlotSymbol ellipsePlotSymbol];
    beatPlotSymbol.fill = [CPTFill fillWithColor:[CPTColor greenColor]];
    beatPlotSymbol.size = CGSizeMake(5.0, 5.0);
    beatPlot.plotSymbol = beatPlotSymbol;

    beatPlot.cachePrecision = CPTPlotCachePrecisionDouble;
    [beatGraph addPlot:beatPlot];
}

- (void)updateGraphs {
    //Get the cached arrays for the beat and spectrum plots
    [self.currentRecord getBeatArraysForSeconds:30 beats:&beatsForBeatPlot xArray:beatXArray yArray:beatYArray];

    //Set beat graph y-axis
    CPTXYPlotSpace *beatPlotSpace = (CPTXYPlotSpace *)beatGraph.defaultPlotSpace;
    double minbpm;
    double maxbpm;

    vDSP_maxvD(beatYArray, 1, &maxbpm, beatsForBeatPlot);
    vDSP_minvD(beatYArray, 1, &minbpm, beatsForBeatPlot);

    maxbpm*=1.01;
    minbpm*=0.99;

    beatPlotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(minbpm)
                    length:CPTDecimalFromDouble(maxbpm-minbpm)];

    //reloaddata
    [beatGraph reloadData];
}

Here are two screen shots both taken right after viewDidAppear, before any data 
has been plotted. Any help would be greatly appreciated.

version 1.0 version 1.1

Additional Information

While running the code with version 1.1 inside Instruments, I found that the 
axes will eventually correct themselves. The last thing to run in my code is 
the viewDidLoad. In this test case I never call -reloadData (it doesn't make a 
difference if I do anyways), and nothing else happens once the view is loaded. 
However, after 15 to 40 seconds (it varies run to run), the axes fix themselves 
and Instruments shows a few additional calls. Most of it looks like system 
calls, but there is one call to -[CPTAnnotationHostLayer 
sublayersExcludedFromAutomaticLayout] and below that -[__NSPlaceholderSet 
initWithObjects:count:]. However, neither of these are in my code, so I can't 
seem to trace where they were called from, or why so late, or why randomly.

The attached file is what shows on 1.1 right after viewDidLoad.  (In 1.0, the 
labels are correctly placed)

Original issue reported on code.google.com by tsxag...@gmail.com on 4 Dec 2012 at 2:46

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by eskr...@mac.com on 27 Dec 2012 at 9:49

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 6f5db889b882.

Original comment by eskr...@mac.com on 1 Jan 2013 at 9:25