2017 © Pedro Peláez
 

package chartjs-php

PHP library for ChartJS 2.0

image

bbsnly/chartjs-php

PHP library for ChartJS 2.0

  • Friday, June 15, 2018
  • by bbsnly
  • Repository
  • 2 Watchers
  • 5 Stars
  • 3,232 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 8 Versions
  • 23 % Grown

The README.md

ChartJS-PHP

Contributor Covenant GitHub Actions Tests Total Downloads Latest Stable Version License, (*1)

This package helps you to generate ChartJS element directly in PHP., (*2)

This package is a powerful tool designed to streamline the process of creating ChartJS elements. ChartJS is a popular JavaScript library used for creating beautiful, responsive, and interactive charts. However, it requires writing JavaScript code, which might not be convenient or efficient in a PHP environment., (*3)

ChartJS-PHP bridges this gap by allowing developers to generate ChartJS elements directly in PHP. This means you can create and manipulate ChartJS charts using PHP code, without needing to write any JavaScript. This not only makes your code cleaner and more maintainable, but also enhances productivity by leveraging the power and simplicity of PHP. Whether you're building a data visualization tool, a dashboard, or any application that requires dynamic charts, ChartJS-PHP can be a valuable addition to your PHP toolkit., (*4)

For the ChartJS-PHP package to work correctly, install the ChartJS library following the guidelines on their official documentation., (*5)

Installation

To install ChartJS-PHP, you can use Composer, a dependency management tool for PHP. Make sure you have Composer installed on your system, and then run the following command in your project directory:, (*6)

composer require bbsnly/chartjs-php

Minimum Requirements:, (*7)

  • PHP version: 8.2 or higher
  • ChartJS version: 2.0 or higher

Usage

To use ChartJS-PHP, you need to create a new instance of the Chart class and set the chart type, data, and options. You can then render the chart to generate the HTML and JavaScript code for the chart., (*8)

In the example below we will create a simple line chart using the Chart class. We will set the chart type to line, add labels and data to the chart, and set the chart options., (*9)

It is also possible to use BarChart, BubbleChart, DoughnutChart, LineChart, PieChart, PolarAreaChart, RadarChart, and ScatterChart classes to create the respective chart types., (*10)

use Bbsnly\ChartJs\Chart;
use Bbsnly\ChartJs\Config\Data;
use Bbsnly\ChartJs\Config\Dataset;
use Bbsnly\ChartJs\Config\Options;

$chart = new Chart;
$chart->type = 'line';

$data = new Data();
$data->labels = ['Red', 'Green', 'Blue'];

$dataset = new Dataset();
$dataset->data = [5, 10, 20];
$data->datasets[] = $dataset->data;

$chart->data($data);

$options = new Options();
$options->responsive = true;
$chart->options($options);

$chart->get(); // Returns the array of chart data
$chart->toJson(); // Returns the JSON representation of the chart data
$chart->toHtml('my_chart'); // Returns the HTML and JavaScript code for the chart

In the example below we will use the toHtml method to generate the HTML and JavaScript code for the chart., (*11)





= $chart->toHtml('my_chart'); ?>

In the example below we will use the toJson method to generate the JSON representation of the chart data., (*12)



Tests

To run the tests, you can use the following command:, (*13)

composer test

Contributing

Please check the Contributing guidelines., (*14)

License

The ChartJS PHP is open-sourced software licensed under the MIT license., (*15)

The Versions

15/06 2018

1.2.x-dev

1.2.9999999.9999999-dev https://github.com/bbsnly/chartjs-php

PHP library for ChartJS 2.0

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Anatoliy Babushka

php chartjs

15/06 2018

1.2.1

1.2.1.0 https://github.com/bbsnly/chartjs-php

PHP library for ChartJS 2.0

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Anatoliy Babushka

php chartjs

15/06 2018

dev-master

9999999-dev https://github.com/bbsnly/chartjs-php

Laravel helper for ChartJS 2.0

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Anatoliy Babushka

laravel php chartjs

15/06 2018

2.1.1

2.1.1.0 https://github.com/bbsnly/chartjs-php

Laravel helper for ChartJS 2.0

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Anatoliy Babushka

laravel php chartjs

12/10 2017

2.1.0

2.1.0.0 https://github.com/bbsnly/chartjs-php

Laravel helper for ChartJS 2.0

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Anatoliy Babushka

laravel php chartjs

12/10 2017

2.0.0

2.0.0.0 https://github.com/bbsnly/chartjs-php

Laravel helper for ChartJS 2.0

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Anatoliy Babushka

laravel php chartjs

07/08 2017

1.2.0

1.2.0.0 https://github.com/bbsnly/chartjs-php

PHP library for ChartJS 2.0

  Sources   Download

MIT

The Development Requires

by Anatoliy Babushka

php chartjs

19/07 2017

1.1.0

1.1.0.0 https://github.com/bbsnly/chartjs-php

PHP library for ChartJS 2.0

  Sources   Download

MIT

The Development Requires

by Anatoliy Babushka

php chartjs