|  Download NanoChartThis PHP class builds a simple pie or doughnut chart as an SVG with a text legend. Features
Pass in an associative array of items and their amounts, and NanoChart creates the chart.
Pass in your own colour palette to overide the default colours, or set your own hue value and NanoChart will create a palette.
The legend can be to the right or below the chart (using CSS flexbox row or column).
The output is HTML with inline styles.
 Screenshot
 UsagePrepare an associative array of names and amounts:     $items = [
        'Monday' => 10,
        'Tuesday' => 20,
        'Wednesday' => 30
    ];
 Instantiate NanoChart and pass in the array:     $nanoChart = new NanoChart($items);
 Customise with setters:     $nanoChart->setSize(250); // width and height in pixels
    $nanoChart->setDirection('column'); // CSS flexbox direction options
    $nanoChart->setStyle('doughnut'); // change from a basic pie chart to a doughnut chart
    $nanoChart->setHue(150); // set the hue value for the colour palette
    $nanoChart->setPalette($palette); //pass in a simple array of colours to use for the items
 ExamplesSee examples.php for different ways the class can be used. DependenciesRequires PHP 7.4 or later. LicenseThis project is licensed under the MIT License. AcknowledgmentsFeel free to contribute, report issues, or suggest improvements! |