Hi, I don't understand the complain. You can choose to take max+100 or round max up in PHP. What is missing exactly ?
--Ed On Fri, Sep 17, 2010 at 2:22 AM, Xyn1407 <[email protected]> wrote: > I recently created a site that creates charts with google charts api > and information it collects from a database that the owner of the site > inputs. All works well except for the left and right axis top numbers. > These display odd top numbers and I am wondering what it would take to > get it to round the number up to the nearest 100 so that it displays > evenly. > > I set the code to go 100 over and I think that somewhere in here is my > problem. If a user inputs a number of 255 and that number is the > highest within the chart data then the top number displays 355. It > displays both top number 255 and 355. Now what this does is makes the > gains look higher that they actually are because it goes from 200, 255 > and then 355. > > Please see example out put here > > http://chart.apis.google.com/chart?cht=lc&chd=t:0,180,182,190,200,198,193,180,175,173,0|0,120,130,150,170,180,200,215,230,227,0|0,200,202,215,221,218,213,210,205,203,0|0,140,150,170,190,200,220,235,255,253,0&chls=3|3|3|3|3|3,6,3&chf=bg,s,FFFFFF&chxl=0:|2500|3000|3500|4000|4500|5000|5500|6000|6500|7000|7500|1:|100|200|255|355|2:|100|200|255|355&chs=575x300&chf=bg,s,FFFFFF&chco=444444,444444,0000FF,0000FF&chxt=x,y,r&chds=50,355&chm=h,76A4FB,0,0:1:.2,2,-1|V,76A4FB,0,::2,0.5,-1 > > I am sure there must be away to dynamically add the axis labels > without it pulling in the info from the data itself right? > > Here is an example of the code I am using. > > <?php > > $id_entity = $_product->getId(); > > $chart_num_rows = 0; > > $db_obj = mysql_connect('localhost', 'XXX', 'XXX'); > > mysql_select_db('XXXX', $db_obj); > > $query = " > SELECT > a.frontend_label AS frontend_label, > b.value AS value > FROM XXX AS a, XXX AS b > WHERE a.attribute_id = b.attribute_id > && b.entity_id = ".$id_entity." > && a.attribute_id BETWEEN 564 AND 568 > ORDER BY a.attribute_id ASC > "; > > $result = mysql_query($query); > > if(mysql_num_rows($result) != 0) { > > @$chart_num_rows = mysql_num_rows($result); > } > > if($chart_num_rows != 0) { > > $max = 0; > > $min = 0; > > $array = array(); > > for($i = 0; $i < $chart_num_rows; $i++) { > > $row = mysql_fetch_object($result); > > $clean = str_replace(" ", '', $row->value); > > $explode = explode(',', $clean); > > if($i == 4) { > > $min = min($explode); > > $max = max($explode); > > } else { > > if($min < min($explode)) { > > $min = min($explode); > } > > if($max < max($explode)) { > > $min = max($explode); > } > > } > > $array[$i][0] = $row->frontend_label; > /* Labels */ > $array[$i][1] = $clean; > /* Line Data */ > $array[$i][2] = str_replace(',', '|', $clean); /* > Labels */ > > } > > $count = 100; > > $left_right = ''; > > while($count < $max) { > > $left_right .= $count.'|'; > > $count = ($count + 100); > > } > > $left_right .= $max.'|'.($max + 100); > > > $output = '<img src="http://chart.apis.google.com/chart? > cht=lc&chd=t:'.$array[1][1].'|'.$array[2][1].'|'.$array[3][1].'|'. > $array[4][1]; > $output .= > '&chls=3|3|3|3|3|3,6,3&chf=bg,s,FFFFFF&chxl=0:|'.$array[0] > [2].'|1:|'.$left_right.'|2:|'.$left_right; > $output .= > '&chs=575x300&chf=bg,s,FFFFFF&chco=444444,444444,0000FF, > 0000FF&chxt=x,y,r&chds=50,'.($max + 100); > $output .= > '&chm=h,76A4FB,0,0:1:.2,2,-1|V,76A4FB,0,::2,0.5,-1"><br / > ><br />'; > > > } else { > > $output = 'There are no current statistics available for > this > chart.'; > > } > > echo $output; > > ?> > > -- > You received this message because you are subscribed to the Google Groups > "Google Chart API" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-chart-api%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-chart-api?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Chart API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-chart-api?hl=en.
