Closed GoogleCodeExporter closed 9 years ago
I'm not sure I understand this. Take a look at CPTestApp. You can change the
window/host view size and the graph changes too. Are you sure you are really
changing the size of the host view?
Drew
Original comment by drewmcco...@mac.com
on 29 Apr 2011 at 9:43
[deleted comment]
[deleted comment]
[deleted comment]
When i initially create the graph everything looks fine; the bars are well
proportioned. When i then update the view´s frame size and do things like
adjusting the bar´s width .. the graph is too big for the view. Some bars are
cut off and others out of (right hand) bounds. It´s hard to say due to the
method being called for initiall configuration is the same!
//define x and y axis dimensions
int numberOfSections = [self numberOfRecordsForPlot:nil];
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0f) length:CPDecimalFromFloat(numberOfSections)];
float maxheight = self.maxHeight;
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0f) length:CPDecimalFromFloat(maxheight)];// + maxheight/8)];
//Create Labels for xAxis at respective ticklocation with Name of Section
CPXYAxisSet* axisSet = (CPXYAxisSet*)graph.axisSet;
CPTextStyle* textStyle = [CPTextStyle textStyle];
textStyle.color = [CPColor blackColor];
textStyle.fontSize = 14.0;
NSMutableArray* axisLabels = [[NSMutableArray alloc] init];
for (int i = 0; i < numberOfSections; i++) {
NSString* name = [[[[conv sections] objectAtIndex:i]sectionHeader]name];
int length = [name length];
length = length >= 14 ? 14 : length;
NSString* sectionName = [name substringWithRange:NSMakeRange(0, length)];
sectionName = [sectionName stringByAppendingString:@"..."];
CPAxisLabel* label = [[CPAxisLabel alloc] initWithText:sectionName
textStyle:textStyle];
label.rotation = M_PI*1.96;
// position label under respective bar
label.tickLocation = [[NSNumber numberWithFloat:i+0.5] decimalValue];
[axisLabels addObject:label];
[label release];
}
NSSet* labelSet = [NSSet setWithArray:axisLabels];
axisSet.xAxis.axisLabels = labelSet;
[axisLabels release];
//recalculate bar width of bars
float barWidth = (graph.bounds.size.width - 2*padding) / ([self numberOfRecordsForPlot:nil]*2+1);
openBarPlot.barWidth = barWidth;
failBarPlot.barWidth = barWidth;
doneBarPlot.barWidth = barWidth;
//tell the graph to reload from datasource and draw all it´s plots
[graph reloadData];
}
Original comment by Wrede....@gmail.com
on 29 Apr 2011 at 11:12
It looks like you are setting the bar widths in view coordinates, right?
I think the default is plot coordinates. You need to set the property
barWidthsAreInViewCoordinates on CPBarPlot to YES.
Original comment by drewmcco...@mac.com
on 29 Apr 2011 at 1:24
Well the issue is not about the width but the height. It seems to me that the
space the graph is drawn doesn´t change. The bar width is an independent
property of the plots not the graph. That´s why changing the width works.I
change the view´s size like this (self is the superview´s controller).
[self updateGraphsDimensions];
-> [graphViewController.view setFrame:[self.view.frame]];
[graphViewController configureGraph];
-> the method posted above..
But thank´s for your reply: Setting the barwidth in axis ranges would require
barWidthsAreInViewCoordinates to be set to FALSE ? (default must be YES since i
already work with view dimensions)
Original comment by Wrede....@gmail.com
on 29 Apr 2011 at 2:24
If you change the frame of your graph hosting view, all Core Plot graph
elements should resize correctly. In your code above, which view is the hosting
view?
Original comment by eskr...@mac.com
on 29 Apr 2011 at 9:05
Yes i know this behavior from other applications but unfortunately not in this
one. The graphhostingview is the view of the graphViewController. It´s frame
is changed within the detailviewcontroller which adds the hostingview to his
subviews from time to time.
Original comment by Wrede....@gmail.com
on 29 Apr 2011 at 9:26
Issue 299 has been merged into this issue.
Original comment by eskr...@mac.com
on 1 Jul 2011 at 1:39
This issue was closed by revision 211c3eb41a4f.
Original comment by eskr...@mac.com
on 1 Jul 2011 at 3:05
Issue 424 has been merged into this issue.
Original comment by eskr...@mac.com
on 11 Apr 2012 at 9:47
Original issue reported on code.google.com by
Wrede....@gmail.com
on 29 Apr 2011 at 9:30