2017 © Pedro Peláez
 

library chartjs

PHP package to parse raw data into ChartJS

image

vichaunter/chartjs

PHP package to parse raw data into ChartJS

  • Friday, June 8, 2018
  • by vichaunter
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

php-chartjs

Usage example

First of all is needed load the js file from cdn, for this you can retrieve like this:, (*1)

        $chartJS = new ChartFactory();
        $jsUrl = $chartJS->getJsFileUrl();

Load at the end of page, before other chart scripts, (*2)

NOTE: you can getJsFileUrl from any new XXXChart(); if you don't need to load from another file in template., (*3)

Then you will generate the chart:, (*4)

        $statsByDate = Customers::getDataList(); //in this case return [total,day]

        $barChart = new BarChart();
        $barChartData = $barChart->getData();
//        $barChartOptions = $barChart->getOptions(); // you can configure colors, sizes, etc.

        $barChartDataset = $barChartData->newDataset();
        foreach($statsByDay as $day){
            $barChartData->addLabel($day['date']);
            $barChartDataset->setLabel('Label for legend for this dataset color')->addData($day['total']);
        }

        $barChartHtmlCanvas = $barChart->getHtmlCanvas();
        $barChartHtmlScript = $barChart->getHtmlScript();

And add canvas in body where chart should appear, and script after previous $chartJS was included in page., (*5)

The Versions

08/06 2018

dev-master

9999999-dev https://www.vichaunter.org

PHP package to parse raw data into ChartJS

  Sources   Download

MIT

The Development Requires

by Avatar vichaunter

php chartjs vichaunter

21/02 2018

0.0.1

0.0.1.0

PHP package to parse raw data into ChartJS

  Sources   Download

MIT

The Development Requires

by Avatar vichaunter

php chartjs vichaunter