Exemple #1
0
function render_pie_chart($options)
{
    $values = array();
    $colours = array();
    if (is_array($options['data'])) {
        foreach ($options['data'] as $data) {
            //	$values[]  = new OFC_Charts_Pie_Value($data['value'], $data['text']) ;
            $value = new OFC_Charts_Pie_Value($data['value'], $data['text']);
            $value->label = $data['text'];
            $values[] = $value;
            $colours[] = $data['color'];
        }
    }
    $chart = new OFC_Chart();
    $chart->set_bg_colour(array_var($options, 'background-color', '#FFFFFF'));
    $chart->set_title(new OFC_Elements_Title(array_var($options, 'title', "")));
    $pie = new OFC_Charts_Pie();
    if (array_var($options, 'start_angle')) {
        $pie->set_start_angle(array_var($options, 'start_angle'));
    }
    $pie->tip = array_var($options, 'tip') ? array_var($options, 'tip') : "#val#/#total#<br>#percent#";
    $pie->values = $values;
    $pie->colours = $colours;
    $pie->alpha = array_var($options, 'alpha') ? array_var($options, 'alpha') : 0.7;
    $pie->set_animate(array_var($options, 'animate', true));
    $chart->add_element($pie);
    $chart->x_axis = null;
    $filename = 'tmp/' . gen_id() . '.json';
    file_put_contents(ROOT . "/{$filename}", $chart->toPrettyString());
    open_flash_chart_object(array_var($options, 'width'), array_var($options, 'height'), ROOT_URL . "/{$filename}", gen_id());
}
Exemple #2
0
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

require_once(OFC_LIBRARY_PATH . '/lib/OFC/OFC_Chart.php');

$title = new OFC_Elements_Title( 'Area Chart' );

$pie = new OFC_Charts_Pie();
$pie->set_start_angle( 35 );
$pie->set_animate( true );

$chart = new OFC_Chart();
$chart->set_title( $title );
$chart->add_element( $pie );


$chart->x_axis = null;

echo $chart->toPrettyString();