mfCharts

I've wrote this "library" for my own needs but I've decided to make it completly free under license WTFPL. It's very first version and I don't plan to extend it if I don't need. But maybe it will suits your needs. It's for PHP5 only.

If you will extend it or correct some bug I would be happy if you send it back to me.

I don't have time for writing documentation but it should be easy to see what you can do just look at public methods in classes and examples below.

When developing it was aimed to draw the graph without tons of settings. Everything is determined automatically (legend box position, axis legend...). But if you need set position of box legend for example (or colors, font, etc.) it's possible just see public methods of classes.

If you need help or found some bug let me know but I don't promise I will fix it. I have also other work to do...

Download: PHP Charts [4.8MB]

The size is big because of ttf fonts included in archive. There is also license for used fonts.

Examples

Bar chart

bar chart

<?php
    
require_once('classes/Utilities.php');
    require_once(
'classes/Gradient.php');
    require_once(
'classes/Chart.php');
    require_once(
'classes/BarChart.php');

    
$values=array(
        
"Január" => 6,
        
"Február" => 4,
        
"Marec" => 1,
        
"Apríl" => 5,
        
"Máj" => 2,
        
"Jún" => 2
    
);

    
$graph = new BarChart();
    
    
$graph->set_title('Skúšobný graf');
     
$graph->set_legend_y('Výnosy');
    
$graph->set_legend_x('Mesiac');
    
    
$graph->set_data($values);
    
     
$graph->draw();
    
$graph->display();
?>

Multiple bar chart

multiple bar chart

<?php
    
require_once('classes/Utilities.php');
    require_once(
'classes/Gradient.php');
    require_once(
'classes/Chart.php');
    require_once(
'classes/BarChart.php');
    require_once(
'classes/MultipleBarChart.php');

    
$values=array(
        
"Január" => array(64),
        
"Február" => array(41),
        
"Marec" => array(01),
        
"Apríl" => array(51),
        
"Máj" => array(28),
        
"Jún" => array(26)
    );

    
$legend = array(
        
'Náklady',
        
'Výnosy'
    
);
 
    
$graph = new MultipleBarChart();
    
    
$graph->set_title('Stĺpcový - multi');
    
$graph->set_legend_y('Údaje');
    
$graph->set_legend_x('Mesiac');
    
    
$graph->set_data($values);
     
$graph->set_legend($legend);
    
     
$graph->draw();
    
$graph->display();
?>

Stacked bar chart

Stacked bar chart

<?php
    
require_once('classes/Utilities.php');
    require_once(
'classes/Gradient.php');
    require_once(
'classes/Chart.php');
    require_once(
'classes/BarChart.php');
    require_once(
'classes/StackedBarChart.php');

    
$values=array(
        
"Január" => array(64),
        
"Február" => array(41),
        
"Marec" => array(01),
        
"Apríl" => array(51),
        
"Máj" => array(28),
        
"Jún" => array(26)
    );

    
$legend = array(
        
'Náklady A',
        
'Náklady B'
    
);
 
    
$graph = new StackedBarChart();
    
    
$graph->set_title('Skúšobný graf');
    
$graph->set_legend_y('Náklady');
    
$graph->set_legend_x('Mesiac');
    
    
$graph->set_data($values);
     
$graph->set_legend($legend);
    
     
$graph->draw();
    
$graph->display();
?>

Pie chart

pie chart

<?php
    
require_once('classes/Utilities.php');
    require_once(
'classes/Gradient.php');
    require_once(
'classes/Chart.php');
    require_once(
'classes/PieChart.php');

    
$values=array(
        
"Náklady" => 3,
        
"Výnosy" => 7,
    );
 
    
$graph = new PieChart();
    
    
$graph->set_title('Koláčový graf');
    
    
$graph->set_data($values);
    
     
$graph->draw();
    
$graph->display();
?>

Line chart

line chart

<?php
    
require_once('classes/Utilities.php');
    require_once(
'classes/Gradient.php');
    require_once(
'classes/Chart.php');
    require_once(
'classes/LinePointChart.php');
    
    
$values=array(
        
"Január" => array(64),
        
"Február" => array(41),
        
"Marec" => array(2.51),
        
"Apríl" => array(51),
        
"Máj" => array(28),
        
"Jún" => array(26)
    );

    
$legend = array(
        
'Náklady',
        
'Výnosy'
    
);
    
    
$graph = new LinePointChart();
    
    
$graph->set_title('Čiarový');
    
$graph->set_legend_y('Údaje');
    
$graph->set_legend_x('Mesiac');
    
    
$graph->set_data($values);
     
$graph->set_legend($legend);
    
     
$graph->draw();
    
$graph->display();
?>

Curved line chart

curved line chart

<?php
    
require_once('classes/Utilities.php');
    require_once(
'classes/Gradient.php');
    require_once(
'classes/Chart.php');
    require_once(
'classes/LinePointChart.php');
    require_once(
'classes/CurvedLinePointChart.php');

    
$values=array(
        
"Január" => array(64),
        
"Február" => array(41),
        
"Marec" => array(2.51),
        
"Apríl" => array(52),
        
"Máj" => array(28),
        
"Jún" => array(26)
    );

    
$legend = array(
        
'Náklady',
        
'Výnosy'
    
);
    
    
$graph = new CurvedLinePointChart();
    
    
$graph->set_title('Čiarový - oblý');
    
$graph->set_legend_y('Údaje');
    
$graph->set_legend_x('Mesiac');
    
    
$graph->set_data($values);
     
$graph->set_legend($legend);
    
     
$graph->draw();
    
$graph->display();
?>

Contact form

Please feel free to contact me if you want ask something, offer me cooperation or anything else...





You can also call me at +421 908 284 529 (Slovak Republic).
What I use:

PHP, (X)HTML, Javascript, XML, XSLT, XPath, CSS, Python, MySQL, AJAX, Java, Sencha ExtJs, Aculo Script, MooTools, JQuery, ModX, Kohana PHP framework Apache, XUL, Windows, Linux and more

For more info ask me for my Curriculum Vitae.