Add php files
This commit is contained in:
138
include/ECM/open_flash_chart2/php5-ofc-library/build_package.php
Executable file
138
include/ECM/open_flash_chart2/php5-ofc-library/build_package.php
Executable file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
require_once('PEAR/PackageFileManager2.php');
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_DIE);
|
||||
|
||||
/**
|
||||
* Package Options
|
||||
*/
|
||||
$package = 'OCF';
|
||||
$baseInstallDir = 'OCF';
|
||||
$channel = 'pear.php.net';
|
||||
|
||||
$description = 'Open Flash Charts interface library';
|
||||
$dirRoles = array(
|
||||
// dirname=> role
|
||||
'simpletest'=> 'test',
|
||||
'examples'=> 'data',
|
||||
);
|
||||
|
||||
$exceptions = array(
|
||||
// filename=> role
|
||||
'build_package.php'=> 'data',
|
||||
);
|
||||
|
||||
$ignore = array(
|
||||
// file|dir/
|
||||
'tmp/',
|
||||
);
|
||||
|
||||
$roles = array(
|
||||
// fileext=> role
|
||||
'php'=> 'php',
|
||||
);
|
||||
|
||||
$category = 'Libraries';
|
||||
|
||||
$license = 'PHP';
|
||||
$notes = 'Helper library for working with Open Flash Charts';
|
||||
|
||||
$version = '2.0.0';
|
||||
$apiVersion = '2.0.0';
|
||||
|
||||
$simpleoutput = true;
|
||||
$state = 'beta';
|
||||
$summary = 'Open Flash Charts interface library';
|
||||
|
||||
|
||||
/**
|
||||
* Package metadata
|
||||
*/
|
||||
|
||||
$releaseStability = 'beta';
|
||||
$apiStability = 'stable';
|
||||
|
||||
$maintainers = array(
|
||||
// role, username on PEAR.net,full name, email
|
||||
array('lead', 'open-flash-chart', 'John Glazebrook', 'open-flash-chart@teethgrinder.co.uk'),
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
$packageSourceDirectory = dirname(__FILE__);
|
||||
|
||||
$options = array(
|
||||
'baseinstalldir' => $baseInstallDir,
|
||||
'dir_roles' => $dirRoles,
|
||||
'exceptions' => $exceptions,
|
||||
'filelistgenerator' => 'File',
|
||||
'ignore' => $ignore,
|
||||
'packagedirectory' => $packageSourceDirectory,
|
||||
'pathtopackagefile' => dirname(__FILE__),
|
||||
'roles' => $roles,
|
||||
'simpleoutput' => $simpleoutput,
|
||||
'state' => $state,
|
||||
'version' => $version,
|
||||
);
|
||||
|
||||
$pkg = new PEAR_PackageFileManager2();
|
||||
|
||||
handleError($pkg->setOptions($options));
|
||||
|
||||
// Set misc package information
|
||||
$pkg->setPackage($package);
|
||||
$pkg->setSummary($summary);
|
||||
$pkg->setDescription($description);
|
||||
$pkg->setChannel($channel);
|
||||
|
||||
$pkg->setReleaseStability($releaseStability);
|
||||
$pkg->setAPIStability($apiStability);
|
||||
$pkg->setReleaseVersion($version);
|
||||
$pkg->setAPIVersion($apiVersion);
|
||||
|
||||
$pkg->setLicense($license);
|
||||
$pkg->setNotes($notes);
|
||||
|
||||
|
||||
|
||||
$pkg->setPackageType('php');
|
||||
$pkg->setPhpDep('5.0.0');
|
||||
$pkg->setPearinstallerDep('1.4.9');
|
||||
|
||||
// Require custom file role for our web installation
|
||||
// $pkg->addPackageDepWithChannel('required', 'Role_Web', 'pearified.com');
|
||||
|
||||
// Define that we will use our custom file role in this script
|
||||
// $pkg->addUsesRole('web', 'Webfiles');
|
||||
|
||||
// Create the current release and add it to the package definition
|
||||
$pkg->addRelease();
|
||||
|
||||
handleError($pkg->generateContents());
|
||||
|
||||
// Package release needs a maintainer
|
||||
foreach($maintainers as $m) {
|
||||
handleError($pkg->addMaintainer($m[0], $m[1], $m[2], $m[3]));
|
||||
}
|
||||
|
||||
if($argv[1] === 'write') {
|
||||
handleError($pkg->writePackageFile());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
handleError($pkg->debugPackageFile());
|
||||
|
||||
|
||||
/**
|
||||
* Simple error handler
|
||||
*
|
||||
* @param Exception $e
|
||||
*/
|
||||
function handleError($e) {
|
||||
if(PEAR::isError($e)) {
|
||||
die($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
29
include/ECM/open_flash_chart2/php5-ofc-library/examples/3d-bar-chart.php
Executable file
29
include/ECM/open_flash_chart2/php5-ofc-library/examples/3d-bar-chart.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
srand((double)microtime()*1000000);
|
||||
$data = array();
|
||||
|
||||
// add random height bars:
|
||||
for( $i=0; $i<10; $i++ )
|
||||
$data[] = rand(2,9);
|
||||
|
||||
require_once('OFC/OFC_Chart.php');
|
||||
|
||||
$title = new OFC_Elements_Title( date("D M d Y") );
|
||||
|
||||
$bar = new OFC_Charts_Bar_3d();
|
||||
$bar->set_values( $data );
|
||||
$bar->colour = '#D54C78';
|
||||
|
||||
$x_axis = new OFC_Elements_Axis_X();
|
||||
$x_axis->set_3d( 5 );
|
||||
$x_axis->colour = '#909090';
|
||||
$x_axis->set_labels( array(1,2,3,4,5,6,7,8,9,10) );
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( $title );
|
||||
$chart->add_element( $bar );
|
||||
$chart->set_x_axis( $x_axis );
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
|
||||
48
include/ECM/open_flash_chart2/php5-ofc-library/examples/area-hollow.php
Executable file
48
include/ECM/open_flash_chart2/php5-ofc-library/examples/area-hollow.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
|
||||
$data = array();
|
||||
|
||||
for( $i=0; $i<6.2; $i+=0.2 )
|
||||
{
|
||||
$tmp = sin($i) * 1.9;
|
||||
$data[] = $tmp;
|
||||
}
|
||||
|
||||
require_once('OFC/OFC_Chart.php');
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( new OFC_Elements_Title( 'Area Chart' ) );
|
||||
|
||||
//
|
||||
// Make our area chart:
|
||||
//
|
||||
$area = new OFC_Charts_Area_Hollow();
|
||||
// set the circle line width:
|
||||
$area->set_width( 1 );
|
||||
$area->set_values( $data );
|
||||
// add the area object to the chart:
|
||||
$chart->add_element( $area );
|
||||
|
||||
$y_axis = new OFC_Elements_Axis_Y();
|
||||
$y_axis->set_range( -2, 2, 2 );
|
||||
$y_axis->labels = null;
|
||||
$y_axis->set_offset( false );
|
||||
|
||||
$x_axis = new OFC_Elements_Axis_X();
|
||||
$x_axis->labels = $data;
|
||||
$x_axis->set_steps( 2 );
|
||||
|
||||
$x_labels = new OFC_Elements_Axis_X_Label_Set();
|
||||
$x_labels->set_steps( 4 );
|
||||
$x_labels->set_vertical();
|
||||
// Add the X Axis Labels to the X Axis
|
||||
$x_axis->set_labels( $x_labels );
|
||||
|
||||
|
||||
|
||||
$chart->add_y_axis( $y_axis );
|
||||
$chart->x_axis = $x_axis;
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
|
||||
32
include/ECM/open_flash_chart2/php5-ofc-library/examples/bar-chart.php
Executable file
32
include/ECM/open_flash_chart2/php5-ofc-library/examples/bar-chart.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/OFC_Chart.php');
|
||||
|
||||
$title = new OFC_Elements_Title( date("D M d Y") );
|
||||
|
||||
$bar = new OFC_Charts_Bar();
|
||||
$bar->set_values( array(9,8,7,6,5,4,3,2,1) );
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( $title );
|
||||
$chart->add_element( $bar );
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
68
include/ECM/open_flash_chart2/php5-ofc-library/examples/data-lines-2.php
Executable file
68
include/ECM/open_flash_chart2/php5-ofc-library/examples/data-lines-2.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/OFC_Chart.php');
|
||||
|
||||
// generate some random data
|
||||
srand((double)microtime()*1000000);
|
||||
|
||||
$data_1 = array();
|
||||
$data_2 = array();
|
||||
$data_3 = array();
|
||||
for( $i=0; $i<9; $i++ )
|
||||
{
|
||||
$data_1[] = rand(1,6);
|
||||
$data_2[] = rand(7,13);
|
||||
$data_3[] = rand(14,19);
|
||||
}
|
||||
|
||||
|
||||
$line_dot = new OFC_Charts_Line_Dot();
|
||||
$line_dot->set_width( 4 );
|
||||
$line_dot->set_colour( '#DFC329' );
|
||||
$line_dot->set_dot_size( 5 );
|
||||
$line_dot->set_values( $data_1 );
|
||||
|
||||
$line_hollow = new OFC_Charts_Line_Hollow();
|
||||
$line_hollow->set_width( 1 );
|
||||
$line_hollow->set_colour( '#6363AC' );
|
||||
$line_hollow->set_dot_size( 5 );
|
||||
$line_hollow->set_values( $data_2 );
|
||||
|
||||
$line = new OFC_Charts_Line();
|
||||
$line->set_width( 1 );
|
||||
$line->set_colour( '#5E4725' );
|
||||
$line->set_dot_size( 5 );
|
||||
$line->set_values( $data_3 );
|
||||
|
||||
$y = new OFC_Elements_Axis_Y();
|
||||
$y->set_range( 0, 20, 5 );
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( new OFC_Elements_Title( 'Three lines example' ) );
|
||||
$chart->set_y_axis( $y );
|
||||
//
|
||||
// here we add our data sets to the chart:
|
||||
//
|
||||
$chart->add_element( $line_dot );
|
||||
$chart->add_element( $line_hollow );
|
||||
$chart->add_element( $line );
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
33
include/ECM/open_flash_chart2/php5-ofc-library/examples/data-lines.php
Executable file
33
include/ECM/open_flash_chart2/php5-ofc-library/examples/data-lines.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/OFC_Chart.php');
|
||||
|
||||
$title = new OFC_Elements_Title( date("D M d Y") );
|
||||
|
||||
$line_dot = new OFC_Charts_Line();
|
||||
$line_dot->set_values( array(9,8,7,6,5,4,3,2,1) );
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( $title );
|
||||
$chart->add_element( $line_dot );
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
|
||||
32
include/ECM/open_flash_chart2/php5-ofc-library/examples/glass-bar-chart.php
Executable file
32
include/ECM/open_flash_chart2/php5-ofc-library/examples/glass-bar-chart.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/OFC_Chart.php');
|
||||
|
||||
$title = new OFC_Elements_Title( date("D M d Y") );
|
||||
|
||||
$bar = new OFC_Charts_Bar_Glass();
|
||||
$bar->set_values( array(9,8,7,6,5,4,3,2,1) );
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( $title );
|
||||
$chart->add_element( $bar );
|
||||
|
||||
echo $chart->toString();
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/OFC_Chart.php');
|
||||
|
||||
$title = new OFC_Elements_Title( "Our New House Schedule" );
|
||||
|
||||
$hbar = new OFC_Charts_Bar_Horizontal();
|
||||
$hbar->append_value( new OFC_Charts_Bar_Horizontal_Value(0,4) );
|
||||
$hbar->append_value( new OFC_Charts_Bar_Horizontal_Value(4,8) );
|
||||
$hbar->append_value( new OFC_Charts_Bar_Horizontal_Value(8,11) );
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( $title );
|
||||
$chart->add_element( $hbar );
|
||||
$chart->add_y_axis( new OFC_Elements_Axis_Y() );
|
||||
|
||||
$x = new OFC_Elements_Axis_X();
|
||||
$x->set_offset( false );
|
||||
$x->set_labels_from_array( array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec') );
|
||||
$chart->set_x_axis( $x );
|
||||
|
||||
$y = new OFC_Elements_Axis_Y();
|
||||
$y->set_offset( true );
|
||||
$y->set_labels( array( "Make garden look sexy","Paint house","Move into house" ) );
|
||||
$chart->add_y_axis( $y );
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
69
include/ECM/open_flash_chart2/php5-ofc-library/examples/line-dot.php
Executable file
69
include/ECM/open_flash_chart2/php5-ofc-library/examples/line-dot.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/OFC_Chart.php');
|
||||
|
||||
$data_1 = array();
|
||||
$data_2 = array();
|
||||
$data_3 = array();
|
||||
|
||||
for( $i=0; $i<6.2; $i+=0.2 )
|
||||
{
|
||||
$data_1[] = (sin($i) * 1.9) + 7;
|
||||
$data_2[] = (sin($i) * 1.9) + 10;
|
||||
$data_3[] = (sin($i) * 1.9) + 4;
|
||||
|
||||
// just show to two decimal places
|
||||
// in our labels:
|
||||
//$labels[] = number_format($tmp,2);
|
||||
}
|
||||
|
||||
$title = new OFC_Elements_Title( date("D M d Y") );
|
||||
|
||||
$line_1 = new OFC_Charts_Line_Dot();
|
||||
$line_1->set_values( $data_1 );
|
||||
$line_1->set_halo_size( 0 );
|
||||
$line_1->set_width( 2 );
|
||||
$line_1->set_dot_size( 4 );
|
||||
|
||||
$line_2 = new OFC_Charts_Line_Dot();
|
||||
$line_2->set_values( $data_2 );
|
||||
$line_2->set_halo_size( 1 );
|
||||
$line_2->set_width( 1 );
|
||||
$line_2->set_dot_size( 4 );
|
||||
|
||||
$line_3 = new OFC_Charts_Line_Dot();
|
||||
$line_3->set_values( $data_3 );
|
||||
$line_3->set_halo_size( 1 );
|
||||
$line_3->set_width( 6 );
|
||||
$line_3->set_dot_size( 4 );
|
||||
|
||||
$y = new OFC_Elements_Axis_Y();
|
||||
$y->set_range( 0, 15, 5 );
|
||||
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( $title );
|
||||
$chart->add_element( $line_1 );
|
||||
$chart->add_element( $line_2 );
|
||||
$chart->add_element( $line_3 );
|
||||
$chart->set_y_axis( $y );
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
69
include/ECM/open_flash_chart2/php5-ofc-library/examples/line-hollow.php
Executable file
69
include/ECM/open_flash_chart2/php5-ofc-library/examples/line-hollow.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/OFC_Chart.php');
|
||||
|
||||
$data_1 = array();
|
||||
$data_2 = array();
|
||||
$data_3 = array();
|
||||
|
||||
for( $i=0; $i<6.2; $i+=0.2 )
|
||||
{
|
||||
$data_1[] = (sin($i) * 1.9) + 7;
|
||||
$data_2[] = (sin($i) * 1.9) + 10;
|
||||
$data_3[] = (sin($i) * 1.9) + 4;
|
||||
|
||||
// just show to two decimal places
|
||||
// in our labels:
|
||||
//$labels[] = number_format($tmp,2);
|
||||
}
|
||||
|
||||
$title = new OFC_Elements_Title( date("D M d Y") );
|
||||
|
||||
$line_1 = new OFC_Charts_Line_Hollow();
|
||||
$line_1->set_values( $data_1 );
|
||||
$line_1->set_halo_size( 0 );
|
||||
$line_1->set_width( 2 );
|
||||
$line_1->set_dot_size( 5 );
|
||||
|
||||
$line_2 = new OFC_Charts_Line_Hollow();
|
||||
$line_2->set_values( $data_2 );
|
||||
$line_2->set_halo_size( 1 );
|
||||
$line_2->set_width( 1 );
|
||||
$line_2->set_dot_size( 4 );
|
||||
|
||||
$line_3 = new OFC_Charts_Line_Hollow();
|
||||
$line_3->set_values( $data_3 );
|
||||
$line_3->set_halo_size( 1 );
|
||||
$line_3->set_width( 6 );
|
||||
$line_3->set_dot_size( 4 );
|
||||
|
||||
$y = new OFC_Elements_Axis_Y();
|
||||
$y->set_range( 0, 15, 5 );
|
||||
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( $title );
|
||||
$chart->add_element( $line_1 );
|
||||
$chart->add_element( $line_2 );
|
||||
$chart->add_element( $line_3 );
|
||||
$chart->set_y_axis( $y );
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
37
include/ECM/open_flash_chart2/php5-ofc-library/examples/pie-chart.php
Executable file
37
include/ECM/open_flash_chart2/php5-ofc-library/examples/pie-chart.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/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();
|
||||
|
||||
63
include/ECM/open_flash_chart2/php5-ofc-library/examples/scatter-chart.php
Executable file
63
include/ECM/open_flash_chart2/php5-ofc-library/examples/scatter-chart.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/OFC_Chart.php');
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
|
||||
$title = new OFC_Elements_Title( date("D M d Y") );
|
||||
$chart->set_title( $title );
|
||||
|
||||
$scatter = new OFC_Charts_Scatter( '#FFD600', 10 );
|
||||
$scatter->set_values(
|
||||
array(
|
||||
new OFC_Charts_Scatter_Value( 0, 0 )
|
||||
)
|
||||
);
|
||||
|
||||
$chart->add_element( $scatter );
|
||||
|
||||
|
||||
//
|
||||
// plot a circle
|
||||
//
|
||||
$s2 = new OFC_Charts_Scatter( '#D600FF', 3 );
|
||||
$v = array();
|
||||
|
||||
for( $i=0; $i<360; $i+=5 )
|
||||
{
|
||||
$v[] = new OFC_Charts_Scatter_Value(
|
||||
number_format(sin(deg2rad($i)), 2, '.', ''),
|
||||
number_format(cos(deg2rad($i)), 2, '.', '') );
|
||||
}
|
||||
$s2->set_values( $v );
|
||||
$chart->add_element( $s2 );
|
||||
|
||||
$x = new OFC_Elements_Axis_X();
|
||||
$x->set_range( -2, 2 );
|
||||
$chart->set_x_axis( $x );
|
||||
|
||||
$y = new OFC_Elements_Axis_Y();
|
||||
$y->set_range( -2, 2 );
|
||||
$chart->add_y_axis( $y );
|
||||
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
|
||||
33
include/ECM/open_flash_chart2/php5-ofc-library/examples/sketch-bar-chart.php
Executable file
33
include/ECM/open_flash_chart2/php5-ofc-library/examples/sketch-bar-chart.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/OFC_Chart.php');
|
||||
|
||||
$title = new OFC_Elements_Title( date("D M d Y") );
|
||||
$title->set_style( '{color: #567300; font-size: 14px}' );
|
||||
|
||||
$bar = new OFC_Charts_Bar_Sketch( '#81AC00', '#567300', 5 );
|
||||
$bar->set_values( array(9,8,7,6,5,4,3,2,1) );
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( $title );
|
||||
$chart->add_element( $bar );
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require_once('OFC/OFC_Chart.php');
|
||||
|
||||
$title = new OFC_Elements_Title( date("D M d Y") );
|
||||
|
||||
$bar_stack = new OFC_Charts_Bar_Stack();
|
||||
$bar_stack->append_stack( array( 2.5, 5 ) );
|
||||
$bar_stack->append_stack( array( 7.5 ) );
|
||||
$bar_stack->append_stack( array( 5, new OFC_Charts_Bar_Stack_Value(5, '#ff0000') ) );
|
||||
$bar_stack->append_stack( array( 2, 2, 2, 2, new OFC_Charts_Bar_Stack_Value(2, '#ff00ff') ) );
|
||||
|
||||
$y = new OFC_Elements_Axis_Y();
|
||||
$y->set_range( 0, 14, 7 );
|
||||
|
||||
$x = new OFC_Elements_Axis_X();
|
||||
$x->set_labels( array( 'a', 'b', 'c', 'd' ) );
|
||||
|
||||
$chart = new OFC_Chart();
|
||||
$chart->set_title( $title );
|
||||
$chart->add_element( $bar_stack );
|
||||
$chart->set_x_axis( $x );
|
||||
$chart->add_y_axis( $y );
|
||||
|
||||
echo $chart->toPrettyString();
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Area.php');
|
||||
|
||||
class OFC_Charts_Area_Hollow extends OFC_Charts_Area
|
||||
{
|
||||
function OFC_Charts_Area_Hollow()
|
||||
{
|
||||
parent::OFC_Charts_Area();
|
||||
|
||||
$this->type = 'area_hollow';
|
||||
|
||||
$this->{'fill-alpha'} = 0.35;
|
||||
|
||||
$this->values = array();
|
||||
}
|
||||
|
||||
function set_width( $w )
|
||||
{
|
||||
$this->width = $w;
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_values( $v ) {
|
||||
$this->values = $v;
|
||||
}
|
||||
|
||||
function set_dot_size( $size )
|
||||
{
|
||||
$this->{'dot-size'} = $size;
|
||||
}
|
||||
|
||||
function set_key( $text, $font_size )
|
||||
{
|
||||
$this->text = $text;
|
||||
$this->{'font-size'} = $font_size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Bar.php');
|
||||
|
||||
class bar_3d_value
|
||||
{
|
||||
function bar_3d_value( $top )
|
||||
{
|
||||
$this->top = $top;
|
||||
// $this->bottom = $bottom;
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_tooltip( $tip )
|
||||
{
|
||||
$this->tip = $tip;
|
||||
}
|
||||
}
|
||||
|
||||
class OFC_Charts_Bar_3d extends OFC_Charts_Bar
|
||||
{
|
||||
function OFC_Charts_Bar_3d()
|
||||
{
|
||||
parent::OFC_Charts_Bar();
|
||||
|
||||
$this->type = 'bar_3d';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Bar.php');
|
||||
|
||||
class OFC_Charts_Bar_Filled_Value extends OFC_Charts_Bar_Value
|
||||
{
|
||||
function OFC_Charts_Bar_Filled_Value( $val, $colour )
|
||||
{
|
||||
parent::OFC_Charts_Bar_Value( $val, $colour );
|
||||
}
|
||||
|
||||
function set_outline_colour( $outline_colour )
|
||||
{
|
||||
$this->{'outline-colour'} = $outline_colour;
|
||||
}
|
||||
}
|
||||
|
||||
class OFC_Charts_Bar_Filled extends OFC_Charts_Bar
|
||||
{
|
||||
function OFC_Charts_Bar_Filled( $colour=null, $outline_colour=null )
|
||||
{
|
||||
parent::OFC_Charts_Bar();
|
||||
|
||||
$this->type = 'bar_filled';
|
||||
|
||||
if( isset( $colour ) )
|
||||
{
|
||||
$this->set_colour( $colour );
|
||||
}
|
||||
|
||||
if( isset( $outline_colour ) )
|
||||
{
|
||||
$this->set_outline_colour( $outline_colour );
|
||||
}
|
||||
}
|
||||
|
||||
function set_outline_colour( $outline_colour )
|
||||
{
|
||||
$this->{'outline-colour'} = $outline_colour;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Bar.php');
|
||||
|
||||
class bar_glass_value
|
||||
{
|
||||
function bar_glass_value( $top )
|
||||
{
|
||||
$this->top = $top;
|
||||
// $this->bottom = $bottom;
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_tooltip( $tip )
|
||||
{
|
||||
$this->tip = $tip;
|
||||
}
|
||||
}
|
||||
|
||||
class OFC_Charts_Bar_Glass extends OFC_Charts_Bar
|
||||
{
|
||||
|
||||
function OFC_Charts_Bar_Glass()
|
||||
{
|
||||
parent::OFC_Charts_Bar();
|
||||
|
||||
$this->type = 'bar_glass';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Bar.php');
|
||||
|
||||
class OFC_Charts_Bar_Horizontal_Value
|
||||
{
|
||||
function OFC_Charts_Bar_Horizontal_Value( $left, $right )
|
||||
{
|
||||
$this->left = $left;
|
||||
$this->right = $right;
|
||||
}
|
||||
}
|
||||
|
||||
class OFC_Charts_Bar_Horizontal
|
||||
{
|
||||
|
||||
function OFC_Charts_Bar_Horizontal()
|
||||
{
|
||||
$this->type = "hbar";
|
||||
$this->colour = "#9933CC";
|
||||
$this->text = "Page views";;
|
||||
$this->{'font-size'} = 10;
|
||||
$this->values = array();
|
||||
}
|
||||
|
||||
function append_value( $v )
|
||||
{
|
||||
$this->values[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Bar.php');
|
||||
|
||||
class OFC_Charts_Bar_Sketch extends OFC_Charts_Bar
|
||||
{
|
||||
function OFC_Charts_Bar_Sketch( $colour, $outline_colour, $fun_factor )
|
||||
{
|
||||
parent::OFC_Charts_Bar();
|
||||
|
||||
$this->type = 'bar_sketch';
|
||||
|
||||
$this->set_colour( $colour );
|
||||
$this->set_outline_colour( $outline_colour );
|
||||
$this->offset = $fun_factor;
|
||||
}
|
||||
|
||||
function set_outline_colour( $outline_colour )
|
||||
{
|
||||
$this->{'outline-colour'} = $outline_colour;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Bar.php');
|
||||
|
||||
class OFC_Charts_Bar_Stack_Value
|
||||
{
|
||||
function OFC_Charts_Bar_Stack_Value( $val, $colour )
|
||||
{
|
||||
$this->val = $val;
|
||||
$this->colour = $colour;
|
||||
}
|
||||
}
|
||||
|
||||
class OFC_Charts_Bar_Stack extends OFC_Charts_Bar
|
||||
{
|
||||
function OFC_Charts_Bar_Stack()
|
||||
{
|
||||
parent::OFC_Charts_Bar();
|
||||
|
||||
$this->type = 'bar_stack';
|
||||
}
|
||||
|
||||
function append_stack( $v )
|
||||
{
|
||||
$this->append_value( $v );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Bar.php');
|
||||
|
||||
class OFC_Charts_Bar_Value
|
||||
{
|
||||
function OFC_Charts_Bar_Value( $top, $bottom=null )
|
||||
{
|
||||
$this->top = $top;
|
||||
|
||||
if( isset( $bottom ) )
|
||||
{
|
||||
$this->bottom = $bottom;
|
||||
}
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_tooltip( $tip )
|
||||
{
|
||||
$this->tip = $tip;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Line.php');
|
||||
|
||||
class OFC_Charts_Line_Dot extends OFC_Charts_Line
|
||||
{
|
||||
function OFC_Charts_Line_Dot()
|
||||
{
|
||||
parent::OFC_Charts_Line();
|
||||
|
||||
$this->type = 'line_dot';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Line.php');
|
||||
|
||||
class OFC_Charts_Line_Hollow extends OFC_Charts_Line
|
||||
{
|
||||
function OFC_Charts_Line_Hollow()
|
||||
{
|
||||
parent::OFC_Charts_Line();
|
||||
|
||||
$this->type = 'line_hollow';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Base.php');
|
||||
|
||||
class OFC_Charts_Area extends OFC_Charts_Base
|
||||
{
|
||||
|
||||
function OFC_Charts_Area()
|
||||
{
|
||||
parent::OFC_Charts_Base();
|
||||
|
||||
$this->type = 'area';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Base.php');
|
||||
|
||||
class OFC_Charts_Bar_Value
|
||||
{
|
||||
function OFC_Charts_Bar_Value( $top, $bottom=null )
|
||||
{
|
||||
$this->top = $top;
|
||||
|
||||
if( isset( $bottom ) )
|
||||
{
|
||||
$this->bottom = $bottom;
|
||||
}
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_tooltip( $tip )
|
||||
{
|
||||
$this->tip = $tip;
|
||||
}
|
||||
}
|
||||
|
||||
class OFC_Charts_Bar extends OFC_Charts_Base
|
||||
{
|
||||
function OFC_Charts_Bar()
|
||||
{
|
||||
parent::OFC_Charts_Base();
|
||||
|
||||
$this->type = 'bar';
|
||||
}
|
||||
|
||||
function set_key( $text, $size )
|
||||
{
|
||||
$this->text = $text;
|
||||
$this->{'font-size'} = $size;
|
||||
}
|
||||
|
||||
function set_values( $v )
|
||||
{
|
||||
$this->values = $v;
|
||||
}
|
||||
|
||||
function append_value( $v )
|
||||
{
|
||||
$this->values[] = $v;
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_alpha( $alpha )
|
||||
{
|
||||
$this->alpha = $alpha;
|
||||
}
|
||||
|
||||
function set_tooltip( $tip )
|
||||
{
|
||||
$this->tip = $tip;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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
|
||||
*/
|
||||
|
||||
class OFC_Charts_Base
|
||||
{
|
||||
function OFC_Charts_Base()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Base.php');
|
||||
|
||||
class OFC_Charts_Line extends OFC_Charts_Base
|
||||
{
|
||||
function OFC_Charts_Line()
|
||||
{
|
||||
parent::OFC_Charts_Base();
|
||||
|
||||
$this->type = 'line';
|
||||
}
|
||||
|
||||
function set_values( $v )
|
||||
{
|
||||
$this->values = $v;
|
||||
}
|
||||
|
||||
function set_width( $width )
|
||||
{
|
||||
$this->width = $width;
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_dot_size( $size )
|
||||
{
|
||||
$this->{'dot-size'} = $size;
|
||||
}
|
||||
|
||||
function set_halo_size( $size )
|
||||
{
|
||||
$this->{'halo-size'} = $size;
|
||||
}
|
||||
|
||||
function set_key( $text, $font_size )
|
||||
{
|
||||
$this->text = $text;
|
||||
$this->{'font-size'} = $font_size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Base.php');
|
||||
|
||||
class OFC_Charts_Pie_Value
|
||||
{
|
||||
function OFC_Charts_Pie_Value( $value, $text )
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->text = $text;
|
||||
}
|
||||
}
|
||||
|
||||
class OFC_Charts_Pie extends OFC_Charts_Base
|
||||
{
|
||||
function OFC_Charts_Pie()
|
||||
{
|
||||
parent::OFC_Charts_Base();
|
||||
|
||||
$this->type = 'pie';
|
||||
$this->colours = array("#d01f3c","#356aa0","#C79810");
|
||||
$this->alpha = 0.6;
|
||||
$this->border = 2;
|
||||
$this->values = array(2,3,new OFC_Charts_Pie_Value(6.5, 'hello (6.5)'));
|
||||
}
|
||||
|
||||
// boolean
|
||||
function set_animate( $v )
|
||||
{
|
||||
$this->animate = $v;
|
||||
}
|
||||
|
||||
// real
|
||||
function set_start_angle( $angle )
|
||||
{
|
||||
$this->{'start-angle'} = $angle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Base.php');
|
||||
|
||||
class OFC_Charts_Scatter_Value
|
||||
{
|
||||
function OFC_Charts_Scatter_Value( $x, $y, $dot_size=-1 )
|
||||
{
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
|
||||
if( $dot_size > 0 )
|
||||
{
|
||||
$this->{'dot-size'} = $dot_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OFC_Charts_Scatter extends OFC_Charts_Base
|
||||
{
|
||||
function OFC_Charts_Scatter( $colour, $dot_size )
|
||||
{
|
||||
parent::OFC_Charts_Base();
|
||||
|
||||
$this->type = 'scatter';
|
||||
$this->set_colour( $colour );
|
||||
$this->set_dot_size( $dot_size );
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_dot_size( $dot_size )
|
||||
{
|
||||
$this->{'dot-size'} = $dot_size;
|
||||
}
|
||||
|
||||
function set_values( $values )
|
||||
{
|
||||
$this->values = $values;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Charts/OFC_Charts_Scatter.php');
|
||||
|
||||
class OFC_Charts_Scatter_Line extends OFC_Charts_Scatter
|
||||
{
|
||||
function OFC_Charts_Scatter_Line( $colour, $dot_size )
|
||||
{
|
||||
parent::OFC_Charts_Scatter( $colour, $dot_size );
|
||||
|
||||
$this->type = 'scatter_line';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Elements/OFC_Elements_Axis.php');
|
||||
require_once('OFC/Elements/Axis/OFC_Elements_Axis_X_Label_Set.php');
|
||||
|
||||
class OFC_Elements_Axis_X extends OFC_Elements_Axis
|
||||
{
|
||||
function OFC_Elements_Axis_X()
|
||||
{
|
||||
parent::OFC_Elements_Axis();
|
||||
}
|
||||
|
||||
function set_stroke( $stroke )
|
||||
{
|
||||
$this->stroke = $stroke;
|
||||
}
|
||||
|
||||
function set_tick_height( $height )
|
||||
{
|
||||
$this->{'tick-height'} = $height;
|
||||
}
|
||||
|
||||
// $o is a boolean
|
||||
function set_offset( $o )
|
||||
{
|
||||
$this->offset = ($o) ? true : false;
|
||||
}
|
||||
|
||||
function set_3d( $val )
|
||||
{
|
||||
$this->{'3d'} = $val;
|
||||
}
|
||||
|
||||
function set_labels( $x_axis_labels )
|
||||
{
|
||||
$this->labels = $x_axis_labels;
|
||||
}
|
||||
|
||||
function set_range( $min, $max, $steps=1 )
|
||||
{
|
||||
$this->min = $min;
|
||||
$this->max = $max;
|
||||
$this->set_steps( $steps );
|
||||
}
|
||||
|
||||
/**
|
||||
* helper function to make the examples
|
||||
* simpler.
|
||||
*/
|
||||
function set_labels_from_array( $a )
|
||||
{
|
||||
$x_axis_labels = new OFC_Elements_Axis_X_Label_Set();
|
||||
$x_axis_labels->set_labels( $a );
|
||||
|
||||
$this->labels = $x_axis_labels;
|
||||
|
||||
if( isset( $this->steps ) )
|
||||
{
|
||||
$x_axis_labels->set_steps( $this->steps );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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
|
||||
*/
|
||||
|
||||
class OFC_Elements_Axis_X_Label extends OFC_Elements_Base
|
||||
{
|
||||
function OFC_Elements_Axis_X_Label( $text, $colour, $size, $rotate )
|
||||
{
|
||||
parent::OFC_Elements_Base();
|
||||
|
||||
$this->set_text( $text );
|
||||
$this->set_colour( $colour );
|
||||
$this->set_size( $size );
|
||||
$this->set_rotate( $rotate );
|
||||
}
|
||||
|
||||
function set_text( $text )
|
||||
{
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_size( $size )
|
||||
{
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
function set_rotate( $rotate )
|
||||
{
|
||||
$this->rotate = $rotate;
|
||||
}
|
||||
|
||||
function set_vertical()
|
||||
{
|
||||
$this->rotate = 'vertical';
|
||||
}
|
||||
|
||||
function set_visible()
|
||||
{
|
||||
$this->visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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
|
||||
*/
|
||||
|
||||
class OFC_Elements_Axis_X_Label_Set
|
||||
{
|
||||
function OFC_Elements_Axis_X_Label_Set()
|
||||
{
|
||||
}
|
||||
|
||||
function set_steps( $steps )
|
||||
{
|
||||
$this->steps = $steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of [x_axis_label or string]
|
||||
*/
|
||||
function set_labels( $labels )
|
||||
{
|
||||
$this->labels = $labels;
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_size( $size )
|
||||
{
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
function set_vertical()
|
||||
{
|
||||
$this->rotate = 'vertical';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Elements/OFC_Elements_Axis.php');
|
||||
|
||||
class OFC_Elements_Axis_Y extends OFC_Elements_Axis
|
||||
{
|
||||
function OFC_Elements_Axis_Y()
|
||||
{
|
||||
parent::OFC_Elements_Axis();
|
||||
}
|
||||
|
||||
function set_grid_colour( $colour )
|
||||
{
|
||||
$this->{'grid-colour'} = $colour;
|
||||
}
|
||||
|
||||
function set_stroke( $s )
|
||||
{
|
||||
$this->stroke = $s;
|
||||
}
|
||||
|
||||
function set_tick_length( $val )
|
||||
{
|
||||
$this->{'tick-length'} = $val;
|
||||
}
|
||||
|
||||
function set_range( $min, $max, $steps=1 )
|
||||
{
|
||||
$this->min = $min;
|
||||
$this->max = $max;
|
||||
$this->set_steps( $steps );
|
||||
}
|
||||
|
||||
function set_offset( $off )
|
||||
{
|
||||
$this->offset = ($off) ? 1 : 0;
|
||||
}
|
||||
|
||||
function set_labels( $labels )
|
||||
{
|
||||
$this->labels = $labels;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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
|
||||
*/
|
||||
|
||||
class OFC_Elements_Axis_Y_Right extends OFC_Elements_Axis_Y
|
||||
{
|
||||
function OFC_Elements_Axis_Y_Right()
|
||||
{
|
||||
parent::OFC_Elements_Axis_Y();
|
||||
}
|
||||
|
||||
/**
|
||||
* y axis right does NOT control
|
||||
* grid colour, the left axis does
|
||||
*/
|
||||
function set_grid_colour( $colour )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Elements/OFC_Elements_Base.php');
|
||||
|
||||
class OFC_Elements_Legend_X extends OFC_Elements_Base
|
||||
{
|
||||
function OFC_Elements_Legend_X( $text='' )
|
||||
{
|
||||
parent::OFC_Elements_Base();
|
||||
|
||||
$this->text = $text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Elements/OFC_Elements_Base.php');
|
||||
|
||||
class OFC_Elements_Legend_Y extends OFC_Elements_Base
|
||||
{
|
||||
function OFC_Elements_Legend_Y( $text='' )
|
||||
{
|
||||
parent::OFC_Elements_Base();
|
||||
|
||||
$this->text = $text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Elements/OFC_Elements_Base.php');
|
||||
|
||||
class OFC_Elements_Axis extends OFC_Elements_Base
|
||||
{
|
||||
function OFC_Elements_Axis()
|
||||
{
|
||||
parent::OFC_Elements_Base();
|
||||
}
|
||||
|
||||
function set_colours( $colour, $grid_colour )
|
||||
{
|
||||
$this->set_colour( $colour );
|
||||
$this->set_grid_colour( $grid_colour );
|
||||
}
|
||||
|
||||
function set_colour( $colour )
|
||||
{
|
||||
$this->colour = $colour;
|
||||
}
|
||||
|
||||
function set_grid_colour( $colour )
|
||||
{
|
||||
$this->{'grid-colour'} = $colour;
|
||||
}
|
||||
|
||||
function set_steps( $steps=1 )
|
||||
{
|
||||
$this->steps = $steps;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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
|
||||
*/
|
||||
|
||||
class OFC_Elements_Base {
|
||||
|
||||
function OFC_Elements_Base() {
|
||||
}
|
||||
|
||||
function set_style($css) {
|
||||
$this->style = $css;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Elements/OFC_Elements_Base.php');
|
||||
|
||||
class OFC_Elements_Title extends OFC_Elements_Base
|
||||
{
|
||||
function OFC_Elements_Title( $text='' )
|
||||
{
|
||||
parent::OFC_Elements_Base();
|
||||
|
||||
$this->text = $text;
|
||||
}
|
||||
}
|
||||
|
||||
805
include/ECM/open_flash_chart2/php5-ofc-library/lib/OFC/JSON.php
Executable file
805
include/ECM/open_flash_chart2/php5-ofc-library/lib/OFC/JSON.php
Executable file
@@ -0,0 +1,805 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Converts to and from JSON format.
|
||||
*
|
||||
* JSON (JavaScript Object Notation) is a lightweight data-interchange
|
||||
* format. It is easy for humans to read and write. It is easy for machines
|
||||
* to parse and generate. It is based on a subset of the JavaScript
|
||||
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
|
||||
* This feature can also be found in Python. JSON is a text format that is
|
||||
* completely language independent but uses conventions that are familiar
|
||||
* to programmers of the C-family of languages, including C, C++, C#, Java,
|
||||
* JavaScript, Perl, TCL, and many others. These properties make JSON an
|
||||
* ideal data-interchange language.
|
||||
*
|
||||
* This package provides a simple encoder and decoder for JSON notation. It
|
||||
* is intended for use with client-side Javascript applications that make
|
||||
* use of HTTPRequest to perform server communication functions - data can
|
||||
* be encoded into JSON notation for use in a client-side javascript, or
|
||||
* decoded from incoming Javascript requests. JSON format is native to
|
||||
* Javascript, and can be directly eval()'ed with no further parsing
|
||||
* overhead
|
||||
*
|
||||
* All strings should be in ASCII or UTF-8 format!
|
||||
*
|
||||
* LICENSE: Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met: Redistributions of source code must retain the
|
||||
* above copyright notice, this list of conditions and the following
|
||||
* disclaimer. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* @category
|
||||
* @package Services_JSON
|
||||
* @author Michal Migurski <mike-json@teczno.com>
|
||||
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
|
||||
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
|
||||
* @copyright 2005 Michal Migurski
|
||||
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
|
||||
*/
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_SLICE', 1);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_STR', 2);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_ARR', 3);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_OBJ', 4);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_CMT', 5);
|
||||
|
||||
/**
|
||||
* Behavior switch for Services_JSON::decode()
|
||||
*/
|
||||
define('SERVICES_JSON_LOOSE_TYPE', 16);
|
||||
|
||||
/**
|
||||
* Behavior switch for Services_JSON::decode()
|
||||
*/
|
||||
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
|
||||
|
||||
/**
|
||||
* Converts to and from JSON format.
|
||||
*
|
||||
* Brief example of use:
|
||||
*
|
||||
* <code>
|
||||
* // create a new instance of Services_JSON
|
||||
* $json = new Services_JSON();
|
||||
*
|
||||
* // convert a complexe value to JSON notation, and send it to the browser
|
||||
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
|
||||
* $output = $json->encode($value);
|
||||
*
|
||||
* print($output);
|
||||
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
|
||||
*
|
||||
* // accept incoming POST data, assumed to be in JSON notation
|
||||
* $input = file_get_contents('php://input', 1000000);
|
||||
* $value = $json->decode($input);
|
||||
* </code>
|
||||
*/
|
||||
class Services_JSON
|
||||
{
|
||||
/**
|
||||
* constructs a new JSON instance
|
||||
*
|
||||
* @param int $use object behavior flags; combine with boolean-OR
|
||||
*
|
||||
* possible values:
|
||||
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
|
||||
* "{...}" syntax creates associative arrays
|
||||
* instead of objects in decode().
|
||||
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
|
||||
* Values which can't be encoded (e.g. resources)
|
||||
* appear as NULL instead of throwing errors.
|
||||
* By default, a deeply-nested resource will
|
||||
* bubble up with an error, so all return values
|
||||
* from encode() should be checked with isError()
|
||||
*/
|
||||
function Services_JSON($use = 0)
|
||||
{
|
||||
$this->use = $use;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-16 char to one UTF-8 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf16 UTF-16 character
|
||||
* @return string UTF-8 character
|
||||
* @access private
|
||||
*/
|
||||
function utf162utf8($utf16)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
|
||||
}
|
||||
|
||||
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
|
||||
|
||||
switch(true) {
|
||||
case ((0x7F & $bytes) == $bytes):
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x7F & $bytes);
|
||||
|
||||
case (0x07FF & $bytes) == $bytes:
|
||||
// return a 2-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xC0 | (($bytes >> 6) & 0x1F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
|
||||
case (0xFFFF & $bytes) == $bytes:
|
||||
// return a 3-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xE0 | (($bytes >> 12) & 0x0F))
|
||||
. chr(0x80 | (($bytes >> 6) & 0x3F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
}
|
||||
|
||||
// ignoring UTF-32 for now, sorry
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-8 char to one UTF-16 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf8 UTF-8 character
|
||||
* @return string UTF-16 character
|
||||
* @access private
|
||||
*/
|
||||
function utf82utf16($utf8)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
||||
}
|
||||
|
||||
switch(strlen($utf8)) {
|
||||
case 1:
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return $utf8;
|
||||
|
||||
case 2:
|
||||
// return a UTF-16 character from a 2-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x07 & (ord($utf8{0}) >> 2))
|
||||
. chr((0xC0 & (ord($utf8{0}) << 6))
|
||||
| (0x3F & ord($utf8{1})));
|
||||
|
||||
case 3:
|
||||
// return a UTF-16 character from a 3-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr((0xF0 & (ord($utf8{0}) << 4))
|
||||
| (0x0F & (ord($utf8{1}) >> 2)))
|
||||
. chr((0xC0 & (ord($utf8{1}) << 6))
|
||||
| (0x7F & ord($utf8{2})));
|
||||
}
|
||||
|
||||
// ignoring UTF-32 for now, sorry
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* encodes an arbitrary variable into JSON format
|
||||
*
|
||||
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
||||
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
||||
* if var is a strng, note that encode() always expects it
|
||||
* to be in ASCII or UTF-8 format!
|
||||
*
|
||||
* @return mixed JSON string representation of input var or an error if a problem occurs
|
||||
* @access public
|
||||
*/
|
||||
function encode($var)
|
||||
{
|
||||
switch (gettype($var)) {
|
||||
case 'boolean':
|
||||
return $var ? 'true' : 'false';
|
||||
|
||||
case 'NULL':
|
||||
return 'null';
|
||||
|
||||
case 'integer':
|
||||
return (int) $var;
|
||||
|
||||
case 'double':
|
||||
case 'float':
|
||||
return (float) $var;
|
||||
|
||||
case 'string':
|
||||
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
|
||||
$ascii = '';
|
||||
$strlen_var = strlen($var);
|
||||
|
||||
/*
|
||||
* Iterate over every character in the string,
|
||||
* escaping with a slash or encoding to UTF-8 where necessary
|
||||
*/
|
||||
for ($c = 0; $c < $strlen_var; ++$c) {
|
||||
|
||||
$ord_var_c = ord($var{$c});
|
||||
|
||||
switch (true) {
|
||||
case $ord_var_c == 0x08:
|
||||
$ascii .= '\b';
|
||||
break;
|
||||
case $ord_var_c == 0x09:
|
||||
$ascii .= '\t';
|
||||
break;
|
||||
case $ord_var_c == 0x0A:
|
||||
$ascii .= '\n';
|
||||
break;
|
||||
case $ord_var_c == 0x0C:
|
||||
$ascii .= '\f';
|
||||
break;
|
||||
case $ord_var_c == 0x0D:
|
||||
$ascii .= '\r';
|
||||
break;
|
||||
|
||||
case $ord_var_c == 0x22:
|
||||
case $ord_var_c == 0x2F:
|
||||
case $ord_var_c == 0x5C:
|
||||
// double quote, slash, slosh
|
||||
$ascii .= '\\'.$var{$c};
|
||||
break;
|
||||
|
||||
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
|
||||
// characters U-00000000 - U-0000007F (same as ASCII)
|
||||
$ascii .= $var{$c};
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xE0) == 0xC0):
|
||||
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
|
||||
$c += 1;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xF0) == 0xE0):
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}));
|
||||
$c += 2;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xF8) == 0xF0):
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}));
|
||||
$c += 3;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xFC) == 0xF8):
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}));
|
||||
$c += 4;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xFE) == 0xFC):
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}),
|
||||
ord($var{$c + 5}));
|
||||
$c += 5;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return '"'.$ascii.'"';
|
||||
|
||||
case 'array':
|
||||
/*
|
||||
* As per JSON spec if any array key is not an integer
|
||||
* we must treat the the whole array as an object. We
|
||||
* also try to catch a sparsely populated associative
|
||||
* array with numeric keys here because some JS engines
|
||||
* will create an array with empty indexes up to
|
||||
* max_index which can cause memory issues and because
|
||||
* the keys, which may be relevant, will be remapped
|
||||
* otherwise.
|
||||
*
|
||||
* As per the ECMA and JSON specification an object may
|
||||
* have any string as a property. Unfortunately due to
|
||||
* a hole in the ECMA specification if the key is a
|
||||
* ECMA reserved word or starts with a digit the
|
||||
* parameter is only accessible using ECMAScript's
|
||||
* bracket notation.
|
||||
*/
|
||||
|
||||
// treat as a JSON object
|
||||
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($var),
|
||||
array_values($var));
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
||||
return '{' . join(',', $properties) . '}';
|
||||
}
|
||||
|
||||
// treat it like a regular array
|
||||
$elements = array_map(array($this, 'encode'), $var);
|
||||
|
||||
foreach($elements as $element) {
|
||||
if(Services_JSON::isError($element)) {
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
||||
return '[' . join(',', $elements) . ']';
|
||||
|
||||
case 'object':
|
||||
$vars = get_object_vars($var);
|
||||
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($vars),
|
||||
array_values($vars));
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
||||
return '{' . join(',', $properties) . '}';
|
||||
|
||||
default:
|
||||
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
|
||||
? 'null'
|
||||
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* array-walking function for use in generating JSON-formatted name-value pairs
|
||||
*
|
||||
* @param string $name name of key to use
|
||||
* @param mixed $value reference to an array element to be encoded
|
||||
*
|
||||
* @return string JSON-formatted name-value pair, like '"name":value'
|
||||
* @access private
|
||||
*/
|
||||
function name_value($name, $value)
|
||||
{
|
||||
$encoded_value = $this->encode($value);
|
||||
|
||||
if(Services_JSON::isError($encoded_value)) {
|
||||
return $encoded_value;
|
||||
}
|
||||
|
||||
return $this->encode(strval($name)) . ':' . $encoded_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* reduce a string by removing leading and trailing comments and whitespace
|
||||
*
|
||||
* @param $str string string value to strip of comments and whitespace
|
||||
*
|
||||
* @return string string value stripped of comments and whitespace
|
||||
* @access private
|
||||
*/
|
||||
function reduce_string($str)
|
||||
{
|
||||
$str = preg_replace(array(
|
||||
|
||||
// eliminate single line comments in '// ...' form
|
||||
'#^\s*//(.+)$#m',
|
||||
|
||||
// eliminate multi-line comments in '/* ... */' form, at start of string
|
||||
'#^\s*/\*(.+)\*/#Us',
|
||||
|
||||
// eliminate multi-line comments in '/* ... */' form, at end of string
|
||||
'#/\*(.+)\*/\s*$#Us'
|
||||
|
||||
), '', $str);
|
||||
|
||||
// eliminate extraneous space
|
||||
return trim($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* decodes a JSON string into appropriate variable
|
||||
*
|
||||
* @param string $str JSON-formatted string
|
||||
*
|
||||
* @return mixed number, boolean, string, array, or object
|
||||
* corresponding to given JSON input string.
|
||||
* See argument 1 to Services_JSON() above for object-output behavior.
|
||||
* Note that decode() always returns strings
|
||||
* in ASCII or UTF-8 format!
|
||||
* @access public
|
||||
*/
|
||||
function decode($str)
|
||||
{
|
||||
$str = $this->reduce_string($str);
|
||||
|
||||
switch (strtolower($str)) {
|
||||
case 'true':
|
||||
return true;
|
||||
|
||||
case 'false':
|
||||
return false;
|
||||
|
||||
case 'null':
|
||||
return null;
|
||||
|
||||
default:
|
||||
$m = array();
|
||||
|
||||
if (is_numeric($str)) {
|
||||
// Lookie-loo, it's a number
|
||||
|
||||
// This would work on its own, but I'm trying to be
|
||||
// good about returning integers where appropriate:
|
||||
// return (float)$str;
|
||||
|
||||
// Return float or int, as appropriate
|
||||
return ((float)$str == (integer)$str)
|
||||
? (integer)$str
|
||||
: (float)$str;
|
||||
|
||||
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
|
||||
// STRINGS RETURNED IN UTF-8 FORMAT
|
||||
$delim = substr($str, 0, 1);
|
||||
$chrs = substr($str, 1, -1);
|
||||
$utf8 = '';
|
||||
$strlen_chrs = strlen($chrs);
|
||||
|
||||
for ($c = 0; $c < $strlen_chrs; ++$c) {
|
||||
|
||||
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
||||
$ord_chrs_c = ord($chrs{$c});
|
||||
|
||||
switch (true) {
|
||||
case $substr_chrs_c_2 == '\b':
|
||||
$utf8 .= chr(0x08);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\t':
|
||||
$utf8 .= chr(0x09);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\n':
|
||||
$utf8 .= chr(0x0A);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\f':
|
||||
$utf8 .= chr(0x0C);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\r':
|
||||
$utf8 .= chr(0x0D);
|
||||
++$c;
|
||||
break;
|
||||
|
||||
case $substr_chrs_c_2 == '\\"':
|
||||
case $substr_chrs_c_2 == '\\\'':
|
||||
case $substr_chrs_c_2 == '\\\\':
|
||||
case $substr_chrs_c_2 == '\\/':
|
||||
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
|
||||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
|
||||
$utf8 .= $chrs{++$c};
|
||||
}
|
||||
break;
|
||||
|
||||
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
|
||||
// single, escaped unicode character
|
||||
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
|
||||
. chr(hexdec(substr($chrs, ($c + 4), 2)));
|
||||
$utf8 .= $this->utf162utf8($utf16);
|
||||
$c += 5;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
|
||||
$utf8 .= $chrs{$c};
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xE0) == 0xC0:
|
||||
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
||||
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 2);
|
||||
++$c;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xF0) == 0xE0:
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 3);
|
||||
$c += 2;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xF8) == 0xF0:
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 4);
|
||||
$c += 3;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xFC) == 0xF8:
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 5);
|
||||
$c += 4;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xFE) == 0xFC:
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 6);
|
||||
$c += 5;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $utf8;
|
||||
|
||||
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
|
||||
// array, or object notation
|
||||
|
||||
if ($str{0} == '[') {
|
||||
$stk = array(SERVICES_JSON_IN_ARR);
|
||||
$arr = array();
|
||||
} else {
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$stk = array(SERVICES_JSON_IN_OBJ);
|
||||
$obj = array();
|
||||
} else {
|
||||
$stk = array(SERVICES_JSON_IN_OBJ);
|
||||
$obj = new stdClass();
|
||||
}
|
||||
}
|
||||
|
||||
array_push($stk, array('what' => SERVICES_JSON_SLICE,
|
||||
'where' => 0,
|
||||
'delim' => false));
|
||||
|
||||
$chrs = substr($str, 1, -1);
|
||||
$chrs = $this->reduce_string($chrs);
|
||||
|
||||
if ($chrs == '') {
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} else {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//print("\nparsing {$chrs}\n");
|
||||
|
||||
$strlen_chrs = strlen($chrs);
|
||||
|
||||
for ($c = 0; $c <= $strlen_chrs; ++$c) {
|
||||
|
||||
$top = end($stk);
|
||||
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
||||
|
||||
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
|
||||
// found a comma that is not inside a string, array, etc.,
|
||||
// OR we've reached the end of the character list
|
||||
$slice = substr($chrs, $top['where'], ($c - $top['where']));
|
||||
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
|
||||
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
// we are in an array, so just push an element onto the stack
|
||||
array_push($arr, $this->decode($slice));
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
// we are in an object, so figure
|
||||
// out the property name and set an
|
||||
// element in an associative array,
|
||||
// for now
|
||||
$parts = array();
|
||||
|
||||
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
|
||||
// "name":value pair
|
||||
$key = $this->decode($parts[1]);
|
||||
$val = $this->decode($parts[2]);
|
||||
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$obj[$key] = $val;
|
||||
} else {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
|
||||
// name:value pair, where name is unquoted
|
||||
$key = $parts[1];
|
||||
$val = $this->decode($parts[2]);
|
||||
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$obj[$key] = $val;
|
||||
} else {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
|
||||
// found a quote, and we are not inside a string
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
|
||||
//print("Found start of string at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == $top['delim']) &&
|
||||
($top['what'] == SERVICES_JSON_IN_STR) &&
|
||||
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
|
||||
// found a quote, we're in a string, and it's not escaped
|
||||
// we know that it's not escaped becase there is _not_ an
|
||||
// odd number of backslashes at the end of the string so far
|
||||
array_pop($stk);
|
||||
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($chrs{$c} == '[') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-bracket, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of array at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
|
||||
// found a right-bracket, and we're in an array
|
||||
array_pop($stk);
|
||||
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($chrs{$c} == '{') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-brace, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of object at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
|
||||
// found a right-brace, and we're in an object
|
||||
array_pop($stk);
|
||||
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($substr_chrs_c_2 == '/*') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a comment start, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
|
||||
$c++;
|
||||
//print("Found start of comment at {$c}\n");
|
||||
|
||||
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
|
||||
// found a comment end, and we're in one now
|
||||
array_pop($stk);
|
||||
$c++;
|
||||
|
||||
for ($i = $top['where']; $i <= $c; ++$i)
|
||||
$chrs = substr_replace($chrs, ' ', $i, 1);
|
||||
|
||||
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Ultimately, this should just call PEAR::isError()
|
||||
*/
|
||||
function isError($data, $code = null)
|
||||
{
|
||||
if (class_exists('pear')) {
|
||||
return PEAR::isError($data, $code);
|
||||
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
|
||||
is_subclass_of($data, 'services_json_error'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('PEAR_Error')) {
|
||||
|
||||
class Services_JSON_Error extends PEAR_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* @todo Ultimately, this class shall be descended from PEAR_Error
|
||||
*/
|
||||
class Services_JSON_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
105
include/ECM/open_flash_chart2/php5-ofc-library/lib/OFC/JSON_Format.php
Executable file
105
include/ECM/open_flash_chart2/php5-ofc-library/lib/OFC/JSON_Format.php
Executable file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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
|
||||
*/
|
||||
|
||||
// Pretty print some JSON
|
||||
function json_format($json)
|
||||
{
|
||||
$tab = " ";
|
||||
$new_json = "";
|
||||
$indent_level = 0;
|
||||
$in_string = false;
|
||||
|
||||
/*
|
||||
commented out by monk.e.boy 22nd May '08
|
||||
because my web server is PHP4, and
|
||||
json_* are PHP5 functions...
|
||||
|
||||
$json_obj = json_decode($json);
|
||||
|
||||
if($json_obj === false)
|
||||
return false;
|
||||
|
||||
$json = json_encode($json_obj);
|
||||
*/
|
||||
$len = strlen($json);
|
||||
|
||||
for($c = 0; $c < $len; $c++)
|
||||
{
|
||||
$char = $json[$c];
|
||||
switch($char)
|
||||
{
|
||||
case '{':
|
||||
case '[':
|
||||
if(!$in_string)
|
||||
{
|
||||
$new_json .= $char . "\n" . str_repeat($tab, $indent_level+1);
|
||||
$indent_level++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_json .= $char;
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
case ']':
|
||||
if(!$in_string)
|
||||
{
|
||||
$indent_level--;
|
||||
$new_json .= "\n" . str_repeat($tab, $indent_level) . $char;
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_json .= $char;
|
||||
}
|
||||
break;
|
||||
case ',':
|
||||
if(!$in_string)
|
||||
{
|
||||
$new_json .= ",\n" . str_repeat($tab, $indent_level);
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_json .= $char;
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
if(!$in_string)
|
||||
{
|
||||
$new_json .= ": ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_json .= $char;
|
||||
}
|
||||
break;
|
||||
case '"':
|
||||
if($c > 0 && $json[$c-1] != '\\')
|
||||
{
|
||||
$in_string = !$in_string;
|
||||
}
|
||||
default:
|
||||
$new_json .= $char;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $new_json;
|
||||
}
|
||||
|
||||
116
include/ECM/open_flash_chart2/php5-ofc-library/lib/OFC/OFC_Chart.php
Executable file
116
include/ECM/open_flash_chart2/php5-ofc-library/lib/OFC/OFC_Chart.php
Executable file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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
|
||||
*/
|
||||
|
||||
if (! function_exists('json_encode'))
|
||||
{
|
||||
require_once('OFC/JSON.php');
|
||||
}
|
||||
|
||||
require_once('OFC/JSON_Format.php');
|
||||
|
||||
require_once('OFC/OFC_Elements.php');
|
||||
|
||||
require_once('OFC/Charts/OFC_Charts_Area.php');
|
||||
require_once('OFC/Charts/OFC_Charts_Bar.php');
|
||||
require_once('OFC/Charts/OFC_Charts_Line.php');
|
||||
require_once('OFC/Charts/OFC_Charts_Pie.php');
|
||||
require_once('OFC/Charts/OFC_Charts_Scatter.php');
|
||||
require_once('OFC/Charts/Area/OFC_Charts_Area_Hollow.php');
|
||||
require_once('OFC/Charts/Bar/OFC_Charts_Bar_Filled.php');
|
||||
require_once('OFC/Charts/Bar/OFC_Charts_Bar_3d.php');
|
||||
require_once('OFC/Charts/Bar/OFC_Charts_Bar_Glass.php');
|
||||
require_once('OFC/Charts/Bar/OFC_Charts_Bar_Horizontal.php');
|
||||
require_once('OFC/Charts/Bar/OFC_Charts_Bar_Sketch.php');
|
||||
require_once('OFC/Charts/Bar/OFC_Charts_Bar_Stack.php');
|
||||
require_once('OFC/Charts/Line/OFC_Charts_Line_Dot.php');
|
||||
require_once('OFC/Charts/Line/OFC_Charts_Line_Hollow.php');
|
||||
|
||||
class OFC_Chart
|
||||
{
|
||||
function OFC_Chart()
|
||||
{
|
||||
$this->title = new OFC_Elements_Title( "Many data lines" );
|
||||
$this->elements = array();
|
||||
}
|
||||
|
||||
function set_title( $t )
|
||||
{
|
||||
$this->title = $t;
|
||||
}
|
||||
|
||||
function set_x_axis( $x )
|
||||
{
|
||||
$this->x_axis = $x;
|
||||
}
|
||||
|
||||
function set_y_axis( $y )
|
||||
{
|
||||
$this->y_axis = $y;
|
||||
}
|
||||
|
||||
function add_y_axis( $y )
|
||||
{
|
||||
$this->y_axis = $y;
|
||||
}
|
||||
|
||||
function set_y_axis_right( $y )
|
||||
{
|
||||
$this->y_axis_right = $y;
|
||||
}
|
||||
|
||||
function add_element( $e )
|
||||
{
|
||||
$this->elements[] = $e;
|
||||
}
|
||||
|
||||
function set_x_legend( $x )
|
||||
{
|
||||
$this->x_legend = $x;
|
||||
}
|
||||
|
||||
function set_y_legend( $y )
|
||||
{
|
||||
$this->y_legend = $y;
|
||||
}
|
||||
|
||||
function set_bg_colour( $colour )
|
||||
{
|
||||
$this->bg_colour = $colour;
|
||||
}
|
||||
|
||||
function toString()
|
||||
{
|
||||
if (function_exists('json_encode'))
|
||||
{
|
||||
return json_encode($this);
|
||||
}
|
||||
else
|
||||
{
|
||||
$json = new Services_JSON();
|
||||
return $json->encode( $this );
|
||||
}
|
||||
}
|
||||
|
||||
function toPrettyString()
|
||||
{
|
||||
return json_format( $this->toString() );
|
||||
}
|
||||
}
|
||||
|
||||
31
include/ECM/open_flash_chart2/php5-ofc-library/lib/OFC/OFC_Elements.php
Executable file
31
include/ECM/open_flash_chart2/php5-ofc-library/lib/OFC/OFC_Elements.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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/Elements/OFC_Elements_Base.php');
|
||||
require_once('OFC/Elements/OFC_Elements_Axis.php');
|
||||
require_once('OFC/Elements/Axis/OFC_Elements_Axis_X.php');
|
||||
require_once('OFC/Elements/Axis/OFC_Elements_Axis_X_Label.php');
|
||||
require_once('OFC/Elements/Axis/OFC_Elements_Axis_X_Label_Set.php');
|
||||
require_once('OFC/Elements/Axis/OFC_Elements_Axis_Y.php');
|
||||
require_once('OFC/Elements/Axis/OFC_Elements_Axis_Y_Right.php');
|
||||
require_once('OFC/Elements/Legend/OFC_Elements_Legend_X.php');
|
||||
require_once('OFC/Elements/Legend/OFC_Elements_Legend_Y.php');
|
||||
require_once('OFC/Elements/OFC_Elements_Title.php');
|
||||
|
||||
127
include/ECM/open_flash_chart2/php5-ofc-library/open-flash-chart-object.php
Executable file
127
include/ECM/open_flash_chart2/php5-ofc-library/open-flash-chart-object.php
Executable file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP Integration of Open Flash Chart
|
||||
* Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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
|
||||
*/
|
||||
|
||||
function open_flash_chart_object_str( $width, $height, $url, $use_swfobject=true, $base='' )
|
||||
{
|
||||
//
|
||||
// return the HTML as a string
|
||||
//
|
||||
return _ofc( $width, $height, $url, $use_swfobject, $base );
|
||||
}
|
||||
|
||||
function open_flash_chart_object( $width, $height, $url, $use_swfobject=true, $base='' )
|
||||
{
|
||||
//
|
||||
// stream the HTML into the page
|
||||
//
|
||||
echo _ofc( $width, $height, $url, $use_swfobject, $base );
|
||||
}
|
||||
|
||||
function _ofc( $width, $height, $url, $use_swfobject, $base )
|
||||
{
|
||||
//
|
||||
// I think we may use swfobject for all browsers,
|
||||
// not JUST for IE...
|
||||
//
|
||||
//$ie = strstr(getenv('HTTP_USER_AGENT'), 'MSIE');
|
||||
|
||||
//
|
||||
// escape the & and stuff:
|
||||
//
|
||||
$url = urlencode($url);
|
||||
|
||||
//
|
||||
// output buffer
|
||||
//
|
||||
$out = array();
|
||||
|
||||
//
|
||||
// check for http or https:
|
||||
//
|
||||
if (isset ($_SERVER['HTTPS']))
|
||||
{
|
||||
if (strtoupper ($_SERVER['HTTPS']) == 'ON')
|
||||
{
|
||||
$protocol = 'https';
|
||||
}
|
||||
else
|
||||
{
|
||||
$protocol = 'http';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$protocol = 'http';
|
||||
}
|
||||
|
||||
//
|
||||
// if there are more than one charts on the
|
||||
// page, give each a different ID
|
||||
//
|
||||
global $open_flash_chart_seqno;
|
||||
$obj_id = 'chart';
|
||||
$div_name = 'flashcontent';
|
||||
|
||||
//$out[] = '<script type="text/javascript" src="'. $base .'js/ofc.js"></script>';
|
||||
|
||||
if( !isset( $open_flash_chart_seqno ) )
|
||||
{
|
||||
$open_flash_chart_seqno = 1;
|
||||
$out[] = '<script type="text/javascript" src="'. $base .'js/swfobject.js"></script>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$open_flash_chart_seqno++;
|
||||
$obj_id .= '_'. $open_flash_chart_seqno;
|
||||
$div_name .= '_'. $open_flash_chart_seqno;
|
||||
}
|
||||
|
||||
if( $use_swfobject )
|
||||
{
|
||||
// Using library for auto-enabling Flash object on IE, disabled-Javascript proof
|
||||
$out[] = '<div id="'. $div_name .'"></div>';
|
||||
$out[] = '<script type="text/javascript">';
|
||||
$out[] = 'var so = new SWFObject("'. $base .'open-flash-chart.swf", "'. $obj_id .'", "'. $width . '", "' . $height . '", "9", "#FFFFFF");';
|
||||
|
||||
$out[] = 'so.addVariable("data-file", "'. $url . '");';
|
||||
|
||||
$out[] = 'so.addParam("allowScriptAccess", "always" );//"sameDomain");';
|
||||
$out[] = 'so.write("'. $div_name .'");';
|
||||
$out[] = '</script>';
|
||||
$out[] = '<noscript>';
|
||||
}
|
||||
|
||||
$out[] = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' . $protocol . '://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
|
||||
$out[] = 'width="' . $width . '" height="' . $height . '" id="ie_'. $obj_id .'" align="middle">';
|
||||
$out[] = '<param name="allowScriptAccess" value="sameDomain" />';
|
||||
$out[] = '<param name="movie" value="'. $base .'open-flash-chart.swf?data='. $url .'" />';
|
||||
$out[] = '<param name="quality" value="high" />';
|
||||
$out[] = '<param name="bgcolor" value="#FFFFFF" />';
|
||||
$out[] = '<embed src="'. $base .'open-flash-chart.swf?data=' . $url .'" quality="high" bgcolor="#FFFFFF" width="'. $width .'" height="'. $height .'" name="'. $obj_id .'" align="middle" allowScriptAccess="sameDomain" ';
|
||||
$out[] = 'type="application/x-shockwave-flash" pluginspage="' . $protocol . '://www.macromedia.com/go/getflashplayer" id="'. $obj_id .'"/>';
|
||||
$out[] = '</object>';
|
||||
|
||||
if ( $use_swfobject ) {
|
||||
$out[] = '</noscript>';
|
||||
}
|
||||
|
||||
return implode("\n",$out);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user