Hi all,

I have a table containing about 10 records and each record has a unique ID. I'm trying to dynamically generate a pie chart according to each record

The output I want is this:

$pct_data = array(
            new pie_value($this->Client->count_all_by_pct(1,$thisMonth), $this->Pct->info(1)->name.', '.$this->Pct->info(1)->location.' ('.$this->Client->count_all_by_pct(1,$thisMonth).')'),
            new pie_value($this->Client->count_all_by_pct(4,$thisMonth), $this->Pct->info(4)->name.', '.$this->Pct->info(4)->location.' ('.$this->Client->count_all_by_pct(4,$thisMonth).')'),
            new pie_value($this->Client->count_all_by_pct(6,$thisMonth), $this->Pct->info(6)->name.', '.$this->Pct->info(6)->location.' ('.$this->Client->count_all_by_pct(6,$thisMonth).')'),
            new pie_value($this->Client->count_all_by_pct(54,$thisMonth), $this->Pct->info(54)->name.', '.$this->Pct->info(54)->location.' ('.$this->Client->count_all_by_pct(54,$thisMonth).')'),
            new pie_value($this->Client->count_all_by_pct(71,$thisMonth), $this->Pct->info(71)->name.', '.$this->Pct->info(71)->location.' ('.$this->Client->count_all_by_pct(71,$thisMonth).')'),
            new pie_value($this->Client->count_all_by_pct(110,$thisMonth), $this->Pct->info(110)->name.', '.$this->Pct->info(110)->location.' ('.$this->Client->count_all_by_pct(110,$thisMonth).')')
        );  
        $pie->set_values($pct_data);

The code I have right now is this, but it doesn't seem to work...

foreach($this->Pct->get_them()->result_array() as $row)
       	{
            $pct_id = $row['pct_id'];
            foreach ($pct_id as $id)
            {
                $pct_data = new pie_value($this->Client->count_all_by_pct($id,$thisYear), $this->Pct->info($id)->name.', '.$this->Pct->info($id)-location.' ('.$this->Client->count_all_by_pct($id,$thisYear).')');
            }
        }
        
        $pie->set_values($pct_data);

Thanks!

instead of $pct_data = new pie_value(...); you need $pct_data[B][][/B] = new pie_value(...);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.