Im showing some data in a simple bar that charts some values, all is working, but now to build the scale for my Y axis, im having some problems with some basic stuff,
I get the ceiling value for my chart with scaleMaxInt in this case for testing = 900
then according to some simple test, I get for example 9 divisions [plus zero]…
so to make the thing work, I create the int pp=100
- (void) drawScaleLabels:(int)scaleMaxInt
{
//temp division for scale, NOTE WHERE TO USE 9 DIVISIONS!!
int scaleStep = scaleMaxInt/9;
NSLog(@"va ::%d", scaleStep);
// case scaleMax : 0 < scaleMax < 1000
float scaleDiv = 31.5;
for (int i = 0; i<9; i++)
{ // is 8, to 9 only for testing!!
int pp = 100;
self.divScaleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(469, scaleDiv+286, 60, 14)]autorelease];
self.divScaleLabel.font = [UIFont fontWithName:@"FS Albert" size:14];
self.divScaleLabel.textColor = [UIColor whiteColor];
self.divScaleLabel.textAlignment = UITextAlignmentRight;
self.divScaleLabel.text =[NSString stringWithFormat:@"$%d",scaleMaxInt-scaleStep];
self.divScaleLabel.backgroundColor =[UIColor clearColor];
[self.view addSubview:self.divScaleLabel];
scaleDiv = scaleDiv + 31.5;
scaleStep = scaleStep+pp;
}
}
wich shows the list of values in my Y axis: 900 , 800 , 700 ,600… 0
but if I use the result of the int scaleStep = scaleMaxInt/9
it gives me the list but with the value*2
- (void) drawScaleLabels:(int)scaleMaxInt
{
//temp division for scale, NOTE WHERE TO USE 9 DIVISIONS!!
int scaleStep = scaleMaxInt/9;
NSLog(@"va ::%d", scaleStep);
// case scaleMax : 0 < scaleMax < 1000
float scaleDiv = 31.5;
for (int i = 0; i<9; i++)
{ // is 8, to 9 only for testing!!
//int pp = 100;
self.divScaleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(469, scaleDiv+286, 60, 14)]autorelease];
self.divScaleLabel.font = [UIFont fontWithName:@"FS Albert" size:14];
self.divScaleLabel.textColor = [UIColor whiteColor];
self.divScaleLabel.textAlignment = UITextAlignmentRight;
self.divScaleLabel.text =[NSString stringWithFormat:@"$%d",scaleMaxInt-scaleStep];
self.divScaleLabel.backgroundColor =[UIColor clearColor];
[self.view addSubview:self.divScaleLabel];
scaleDiv = scaleDiv + 31.5;
NSLog(@"va ::%d", scaleStep);
scaleStep = scaleStep+scaleStep;
}
}
so Y axis is, 900, 800 , 700, 500 , 100, -700 …-24700
Im stupidly stuck with this!,
how can i generate the list for Y axis?, with a dynamic value, dependent of scaleMaxInt
that doesn’t get confused??
thanks a lot!
You have this in your loop:
That means you are doubling
scaleStepon each pass through the loop. Remove that line. Instead, setself.divScaleLabel.textlike this: