piaoyongren / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

MaxValue of Y-Axis under 5 -> Screen seems to freeze #162

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. set the maxValue of the y-Axis under 5

What is the expected output? What do you see instead?
the y-axis should have the max-Value set on for instance 4, but the diagram is 
not drawn at all and the screen seems to freeze. Try it out ;)

What version of the product are you using? On what operating system?
XCode 3.2.2, OS 10.6.3

Original issue reported on code.google.com by hannesk....@gmail.com on 19 Jun 2010 at 8:03

GoogleCodeExporter commented 8 years ago
You need to be more specific. What chart are you setting it to under 5?
Can you use Activity Monitor or Instruments to see where the app is freezing?

Drew

Original comment by drewmcco...@mac.com on 20 Jun 2010 at 7:39

GoogleCodeExporter commented 8 years ago
I am using the BarChart and when i do this for instance:

int maxValue=4;
float tenpercentofmaxY = self.maxValue * 0.1;

plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0f) 
length:CPDecimalFromFloat(self.maxValue + tenpercentofmaxY)];

and the rest of the code is the same as in the sample-application: 
CPTestApp-iPhone

then the screen seems to freeze when i push the ViewController of the 
CPLayerHostingView with the help of a NavigationController.

Do you need more information? I could also send you the example project 
tomorrow..if you want

Original comment by hannesk....@gmail.com on 20 Jun 2010 at 5:28

GoogleCodeExporter commented 8 years ago
Are you doing this just once, or are you doing it in a timer callback many 
times. Every time you do this, the chart will redraw. If you do it too much, it 
will effectively freeze.

Original comment by drewmcco...@mac.com on 21 Jun 2010 at 7:23

GoogleCodeExporter commented 8 years ago
So i added my prjoect, it is not that big, but here are some hints how you can 
easily reproduce the behaviour:

Class:
ChartThatThingViewController

Line:44
ABDiagramData *entry = [[ABDiagramData alloc] initWithData:[bevs 
objectAtIndex:r]:30+i*2+4];

Change to:
ABDiagramData *entry = [[ABDiagramData alloc] initWithData:[bevs 
objectAtIndex:r]:3];
(The 2nd value is the amount of the bar-block)

Line: 50
int maxValue = 30+i*2+4 * 1.10;

Change to:
int maxValue = 4;
(this is the maximum value of all barcharts in the diagram)

and start the application (it will switch to landscape mode and displays a 
black screen - if there will be a view before this it will show the view before 
- so it seems to freeze)

Original comment by hannesk....@gmail.com on 21 Jun 2010 at 7:56

Attachments:

GoogleCodeExporter commented 8 years ago
There is a bug in -[CPAxis 
tickLocationsBeginningAt:increasing:majorTickLocations:minorTickLocations:]. 
When the majorIntervalLength is zero, it gets stuck in an infinite loop while 
computing the label locations. We'll need to add a check for zero interval 
length and bail out of the loop.

Your seeing this problem because of the following line in your code:
    y.majorIntervalLength = CPDecimalFromFloat(maxValue/5);

This is an integer division, which rounds to zero when maxValue < 5. Simple 
fix—make it a floating point division, like this:
    y.majorIntervalLength = CPDecimalFromFloat(maxValue/5.0);

This should work as long as maxValue > 0.

Original comment by eskr...@mac.com on 23 Jun 2010 at 2:49

GoogleCodeExporter commented 8 years ago
Why are you making four bar plots? It appears you're trying to have varying 
colors for the bars. It would be easier to have one bar plot and use the 
barFillForBarPlot:recordIndex:index delegate method to return the correct fill 
for each bar. Core Plot fills can be solid colors, gradients, or images. The 
"tubular" style bars just have a gradient as the default fill. If you need more 
help with this, please take your questions about fills to the discussion board. 
This issue will be closed when we fix the infinite loop in the labeling routine.

Original comment by eskr...@mac.com on 23 Jun 2010 at 3:00

GoogleCodeExporter commented 8 years ago
Ya well as you already correctly figured out, my intention to use 4 bar plots 
was to have the effect of differing bar plot colors. I will open a thread on 
the discussion board, about barPlots with different colors. It would be very 
nice if you could explain, what the correct way is.

Original comment by hannesk....@gmail.com on 23 Jun 2010 at 6:51

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 09497ac24e.

Original comment by eskr...@mac.com on 24 Jun 2010 at 2:25