Welcome Guest, Not a member yet? Register   Sign In
Array manipulation
#4

[eluser]Thatch[/eluser]
You know I thought at first I was over writing but each array for the image information in numbered and those show up properly when I print the array.

I grabbed the code and pared it down some so that perhaps it will make more sense...
Code:
function buildPie($data)
            {
                 $this->load->library('charts');
                $config = array(
                'SpliceDistance'=>10,
                'TitleFontSize' => 16,
                'TitleFontName' => 'pf_arma_five.ttf');
                
                $percents = $data['percents'];
                $legend = $data['legend'];
                $title = $data['title'];
                $bottom_label='bottom label';
                
                $i = $data['count'];
                
                $data['image'.$i] = $this->charts->pieChart(100,$percents,$legend,'',$title,$bottom_label,$config);
        
                
                return $data;
                
            }
            
            function results()
            {
                $data['count'] = 0;
              
                $data['percents'] = array(19,34,13,20,10,4);
                $data['legend'] = array('one','two','tree','four','five','six');
                $data['title'] = 'Title 1';
            
                $data['count']++;
                $onion = $this->buildPie($data);

                
                $data['percents'] = array(1,2,3,4,45,45);
                $data['legend'] = array('one','two','tree','four','five','six');
                $data['title'] = 'Title 2';
                
                $data['count']++;
                $onion = $this->buildPie($data);


                
                $data['percents'] = array(15,20,25,10,10,10);
                $data['legend'] = array('one','two','tree','four','five','six');
                $data['title'] = 'Title 3';
                
                $data['count']++;
                $onion = $this->buildPie($data);
                
                
                $this->load->view('includes/template', $onion);
                
            }

You'll see that I am adding to 'count' in the original function as this would not update when I tried to increment it inside the buildPie function (where it makes much more sense to be).

Thanks for the assistance so far.


Messages In This Thread
Array manipulation - by El Forum - 03-22-2010, 02:51 PM
Array manipulation - by El Forum - 03-22-2010, 03:08 PM
Array manipulation - by El Forum - 03-22-2010, 03:09 PM
Array manipulation - by El Forum - 03-22-2010, 03:21 PM
Array manipulation - by El Forum - 03-22-2010, 05:28 PM
Array manipulation - by El Forum - 03-22-2010, 06:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB