composer update
This commit is contained in:
30
vendor/khill/lavacharts/.github/CONTRIBUTING.md
vendored
Normal file
30
vendor/khill/lavacharts/.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
## Contributing
|
||||
|
||||
First of all, **thank you** for contributing!
|
||||
|
||||
Here are a few guidelines to follow in order to ease code reviews and merging:
|
||||
|
||||
### For the PHP code base
|
||||
|
||||
- follow [PSR-1](http://www.php-fig.org/psr/1/) and [PSR-2](http://www.php-fig.org/psr/2/)
|
||||
- run the test suite
|
||||
- write (or update) unit tests when applicable
|
||||
- write documentation for new features
|
||||
- use [commit messages that make sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
||||
|
||||
One may ask you to [squash your commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) too. This is used to "clean" your pull request before merging it (we don't want commits such as `fix tests`, `fix 2`, `fix 3`, etc.).
|
||||
|
||||
When creating your pull request on GitHub, please write a description which gives the context and/or explains why you are creating it.
|
||||
|
||||
|
||||
### For the Javascript code base
|
||||
|
||||
To get started, you will need to have nodejs installed with npm.
|
||||
|
||||
- From the root of the project, navigate to the javascript directory: `cd javascript`
|
||||
- Then run `npm install` to fetch all the tooling needed for compiling lava.js
|
||||
|
||||
Gulp is used to build the module so you will need to use the tasks:
|
||||
- Use `gulp watch` to monitor the files for changes and rebuild when detected.
|
||||
- Use `gulp build` to initiate a manual dev build.
|
||||
- Use `gulp release` to initiate a manual production build. (Strips comments, removes logging, and minifys the code.)
|
||||
18
vendor/khill/lavacharts/.github/ISSUE_TEMPLATE.md
vendored
Normal file
18
vendor/khill/lavacharts/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#### What Version?
|
||||
> Run `composer show khill/lavacharts` if you don't know
|
||||
|
||||
|
||||
#### Issue
|
||||
> Please describe the issue.
|
||||
|
||||
|
||||
#### Controller Code (chart creation code)
|
||||
```
|
||||
// paste over this
|
||||
```
|
||||
|
||||
|
||||
#### View Code
|
||||
```
|
||||
// paste over this
|
||||
```
|
||||
24
vendor/khill/lavacharts/.gitlab-ci.yml
vendored
Normal file
24
vendor/khill/lavacharts/.gitlab-ci.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Select image from https://hub.docker.com/_/php/
|
||||
image: php:5.6
|
||||
|
||||
# Select what we should cache
|
||||
cache:
|
||||
paths:
|
||||
- vendor/
|
||||
|
||||
before_script:
|
||||
- apt-get update -yqq
|
||||
- apt-get install git unzip nodejs -yqq
|
||||
- curl -sS https://getcomposer.org/installer | php
|
||||
#- echo 'date.timezone = "America/Los_Angeles"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||
- mkdir -p build/logs
|
||||
- php composer.phar install --no-progress --no-interaction --prefer-dist
|
||||
- npm install --no-progress --production
|
||||
|
||||
after_script:
|
||||
- php ./vendor/bin/coveralls
|
||||
|
||||
test:
|
||||
script:
|
||||
- php composer.phar run test
|
||||
- npm run test
|
||||
226
vendor/khill/lavacharts/CHANGELOG.md
vendored
Normal file
226
vendor/khill/lavacharts/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
- 3.1.9
|
||||
- Fixing bug where using `setOptions` instead of the constructor skipped the processing of `png` and `material` attributes.
|
||||
|
||||
- 3.1.8
|
||||
- Production build of the Lava.js module.
|
||||
|
||||
- 3.1.7
|
||||
- Added the tag lavacharts to the config publishing.
|
||||
Use `php artisan vendor:publish --tag=lavacharts`
|
||||
If that does not work, try to clear the cache with `php artisan config:clear` and re-publish with `--force`.
|
||||
|
||||
- 3.1.6
|
||||
- The event callback within lava.js was modified to pass back the chart and the datatable so users can interact with either during an event. This solves issue [#203](https://github.com/kevinkhill/lavacharts/issues/203)
|
||||
|
||||
- 3.1.5
|
||||
- Adding DonutChart alias class back
|
||||
|
||||
- 3.1.4
|
||||
- Chart's should resize properly on page resize.
|
||||
|
||||
- 3.1.3
|
||||
- Adding support for date columns to be null which enables support for Gantt charts to have linked sections.
|
||||
- Adding JavascriptDate class that mimics the way the Javascript Date object is created. (I wanted to be able to copy and paste google's examples into addRows)
|
||||
|
||||
- 3.1.1 & 3.1.2
|
||||
- Adding back and repairing the Symfony Bundle
|
||||
|
||||
- 3.1.0
|
||||
- Public Release
|
||||
|
||||
- 3.1.0-beta2
|
||||
- Adjusting elementId precedence to prevent backwards compatability breaks and enable new features. The order of precedence goes as follows:
|
||||
- An elementId string passed to the render method will override an elementId set to the chart.
|
||||
- It is recommended to move all of the elementId strings on `render()` methods into the constructor, as an option: `['elementId' => 'render-to-div']`
|
||||
- Setting the elementId as an option during creation is preferred, to enable the use of the new feature, `renderAll()`, that will output all defined charts to the page.
|
||||
|
||||
- 3.1.0-beta1
|
||||
- Adding setLocale() method for changing language of charts.
|
||||
|
||||
- 3.1.0-alpha
|
||||
- Adding more supported chart types
|
||||
- AnnotationChart
|
||||
- BubbleChart
|
||||
- CandlestickChart
|
||||
- HistogramChart
|
||||
- SankeyChart
|
||||
- SteppedAreaChart
|
||||
- TimelineChart
|
||||
- TreemapChart
|
||||
- Adding DataFactory with arrayToDataTable() method to try and automatically
|
||||
create columns and rows based on an array of data with labels. This mimics how
|
||||
Google's javascript version of the method works for creating DataTables more
|
||||
efficiently. Currently only works with strings and numbers.
|
||||
- Adding DataTable() method to the DataFactory as a shortcut to chaining methods.
|
||||
- The method has three signatures:
|
||||
- No params for an empty, default timezone DataTable
|
||||
- String param for setting the timezone
|
||||
- Array of columns and array of rows as 1st and 2nd for a complete DataTable in
|
||||
one method call. (The third parameter can also be used to set the timezone.)
|
||||
- [DataFactory Examples](https://gist.github.com/kevinkhill/0c7c5f6211c7fd8f9658)
|
||||
- Massive overhaul of lava.js module.
|
||||
- Refactored and using browserify to compile
|
||||
- Added `lava.ready()` method for wrapping any lava.js interaction. When given a function
|
||||
it will be called after all charts have rendered onto the page. Useful for delaying ajax requests
|
||||
until the chart is ready.
|
||||
- Added the ability to render directly as PNGs instead of SVGs
|
||||
- Just pass into the options `['png' => true]`
|
||||
- Created examples for each chart, available to view locally using the built in PHP server.
|
||||
- Navigate to the Examples folder in the lavacharts package folder. If you installed with Composer, then it
|
||||
should be at `$PROJECT_ROOT/vendor/khill/lavacharts/tests/Examples`
|
||||
- Use the given config and router to start the examples page `php -S 127.0.0.1:8000 -c php.ini router.php`
|
||||
- All exceptions now extend LavaException if the user wants to have a catch all
|
||||
- Utils class removed, broken into traits, and applied to classes that needed the methods
|
||||
|
||||
- 3.0.4
|
||||
- Fixing bug where TreeMap was not in list of chartClasses
|
||||
|
||||
- 3.0.3
|
||||
- Events Bugfix
|
||||
|
||||
- 3.0.2
|
||||
- Blade template extension bug fixes
|
||||
- Combining the `customize` method into the constructor to provide
|
||||
restriction free option setting without the extra method call.
|
||||
|
||||
- 3.0.1
|
||||
- Bug fixes
|
||||
|
||||
- 3.0.0
|
||||
- Dropping support for PHP 5.3
|
||||
- Minimum version PHP 5.4+
|
||||
- Added Dashboards
|
||||
- ChartWrappers
|
||||
- ControlWrappers
|
||||
- Added filters for Dashboard ControlWrappers
|
||||
- Category
|
||||
- ChartRange
|
||||
- DateRange
|
||||
- NumberRange
|
||||
- String
|
||||
- Chart Improvements
|
||||
- Assign DataTable and options via constructor.
|
||||
- Refactored all ConfigObject creation into the classes, no more manually instantiation.
|
||||
- Removed Event classes in favor of associative array definitions of events.
|
||||
- DataTable Improvements
|
||||
- Added support for csv file read/write and Laravel collection parsing into DataTables,
|
||||
just add the separate package to composer "khill/datatableplus":"dev-master".
|
||||
DataTablePlus extends the DataTable to add the extra functions and Lavacharts will seamlessly
|
||||
create DataTablePluses over DataTables if available via composer.
|
||||
- Added ScatterChart & TableChart
|
||||
- Added Format#formatColumn method to format datatable columns.
|
||||
- Added new formats.
|
||||
- ArrowFormat
|
||||
- BarFormat
|
||||
- lava.js has been refactored:
|
||||
- lava.get() replaced with:
|
||||
- getChart(label, callback) -> callback(Google chartObj, Lava chartObj)
|
||||
- Google chart object allows for using google's documented chart methods
|
||||
- Lava chart object contains all relevant info about the chart
|
||||
- chart, data, options, formats etc...
|
||||
- getDashboard(label, callback) -> callback(Google dashboardObj, Lava dashboardObj)
|
||||
- Google dashboard object allows for using google's documented dashboard methods
|
||||
- Lava dashboard object contains all relevant info about the dashboard
|
||||
- dashboard, control bindings, chart wrapper, data, options, etc...
|
||||
- lava.ready() used to wrap other lava.js interaction.
|
||||
- Called after all of the google jsapi is loaded and the charts are rendered.
|
||||
|
||||
- 2.5.7
|
||||
- AJAX data loading bugfixes
|
||||
|
||||
- 2.5.6
|
||||
- Fixes for AJAX chart loading
|
||||
|
||||
- 2.5.5
|
||||
- Blade extensions fix
|
||||
|
||||
- 2.5.4
|
||||
- Fixed namespace bug
|
||||
|
||||
- 2.5.3
|
||||
- Added column roles
|
||||
|
||||
- 2.5.2
|
||||
- AddedTimeOfDay columns
|
||||
|
||||
- 2.5.1
|
||||
- Lava.js bug fixes
|
||||
|
||||
- 2.5.0
|
||||
- Ajax chart loading
|
||||
|
||||
- 2.4.2
|
||||
- Added Lava#exists() method for checking if a chart exists
|
||||
|
||||
- 2.4.1
|
||||
- Added focusTarget to Line and Area charts
|
||||
|
||||
- 2.4.0
|
||||
- BarCharts added
|
||||
- Cleaned up code to PSR2
|
||||
- Changed from PSR0 -> PSR4
|
||||
|
||||
- 2.3.0
|
||||
- Added jsapi() method for manual script placement.
|
||||
|
||||
- 2.2.1
|
||||
- Timezone fixes
|
||||
Now they can be set with the constructor when creating a DataTable.
|
||||
|
||||
- 2.2.0
|
||||
- Gauge Chart support
|
||||
|
||||
- 2.1.0
|
||||
- Calendar Chart support
|
||||
|
||||
- 2.0.5
|
||||
- Updated Carbon
|
||||
- Laravel 5 compatibility
|
||||
|
||||
- 2.0.4
|
||||
- Multiple chart bug fixes
|
||||
|
||||
- 2.0.3
|
||||
- Fixing event bugs
|
||||
|
||||
- 2.0.2
|
||||
- Responsive charts
|
||||
|
||||
- 2.0.1
|
||||
- Multiple chart support
|
||||
|
||||
- 2.0.0
|
||||
- Its Here!
|
||||
|
||||
- 2.0.0-beta1
|
||||
- Passed 75% test coverage
|
||||
- Added new options to TextStyle
|
||||
- Bold
|
||||
- Italic
|
||||
|
||||
- 2.0.0-alpha4
|
||||
- Added Events
|
||||
- select
|
||||
- onmouseover
|
||||
- onmouseout
|
||||
|
||||
- 2.0.0-alpha3
|
||||
- Added DataTable column formatters
|
||||
- DateFormat
|
||||
- NumberFormat
|
||||
|
||||
- 2.0.0-alpha2
|
||||
- Added render method in favor of outputInto method
|
||||
- Added blade template extensions for seamless chart rendering
|
||||
- Moar tests!
|
||||
|
||||
- 2.0.0-alpha1
|
||||
- Refactored the main Lavacharts class to not be static anymore (yay!)
|
||||
- Moved the creation of the javascript into it's own class
|
||||
- Added a new class "Volcano" to store all the charts.
|
||||
- Modified the charts to not statically call the Lavacharts functions
|
||||
- DataTables are no longer magic, but applied via method chaining
|
||||
- Added render method in favor of outputInto method
|
||||
- Added blade template extensions as aliases to the render method
|
||||
- Tests tests tests!
|
||||
- Using phpcs to bring all the code up to PSR2 standards
|
||||
14
vendor/khill/lavacharts/CONTRIBUTORS.md
vendored
Normal file
14
vendor/khill/lavacharts/CONTRIBUTORS.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# Contributors
|
||||
|
||||
Thank you for finding bugs, helping me fix them, pull requests, issues and anything else.
|
||||
|
||||
- [deringer](https://github.com/deringer)
|
||||
- [MicahKV](micah138@yahoo.com)
|
||||
- [rajivseelam](https://github.com/rajivseelam)
|
||||
- [SendDerek](https://github.com/SendDerek)
|
||||
- [stevebauman](https://github.com/stevebauman)
|
||||
- [Stonos](https://github.com/Stonos)
|
||||
- [tobias-kuendig](https://github.com/tobias-kuendig)
|
||||
- [twify93](https://github.com/twify93)
|
||||
|
||||
If your name is not on this list and needs to be, I'm sorry! Please add it in a pull request and I will merge it in.
|
||||
23
vendor/khill/lavacharts/LICENSE
vendored
Normal file
23
vendor/khill/lavacharts/LICENSE
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Lavacharts - A PHP wrapper library for the Google Chart API
|
||||
|
||||
Copyright (c) 2017 Kevin Hill
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
244
vendor/khill/lavacharts/README.md
vendored
Normal file
244
vendor/khill/lavacharts/README.md
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
# Lavacharts 3.1.10
|
||||
|
||||
[](https://packagist.org/packages/khill/lavacharts)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
[](https://php.net/)
|
||||
[](https://gitter.im/kevinkhill/lavacharts?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
[](https://www.paypal.me/kevinkhill/)
|
||||
|
||||
Lavacharts is a graphing / chart library for PHP5.4+ that wraps the Google Chart API.
|
||||
|
||||
Stable:
|
||||
[](https://github.com/kevinkhill/lavacharts/releases)
|
||||
[](https://travis-ci.org/kevinkhill/lavacharts)
|
||||
[](https://coveralls.io/r/kevinkhill/lavacharts?branch=3.1)
|
||||
|
||||
Dev:
|
||||
[](https://github.com/kevinkhill/lavacharts/tree/master)
|
||||
[](https://travis-ci.org/kevinkhill/lavacharts)
|
||||
[](https://coveralls.io/r/kevinkhill/lavacharts?branch=master)
|
||||
|
||||
|
||||
## Package Features
|
||||
- **Updated!** Laravel 5.5+ auto-discovery
|
||||
- Any option for customizing charts that Google supports, Lavacharts should as well. Just use the chart constructor to assign any customization options you wish!
|
||||
- Visit [Google's Chart Gallery](https://developers.google.com/chart/interactive/docs/gallery) for details on available options
|
||||
- Custom JavaScript module for interacting with charts client-side
|
||||
- AJAX data reloading
|
||||
- Fetching charts
|
||||
- Events integration
|
||||
- Column Formatters & Roles
|
||||
- Blade template extensions for Laravel
|
||||
- Twig template extensions for Symfony
|
||||
- [Carbon](https://github.com/briannesbitt/Carbon) support for date/datetime/timeofday columns
|
||||
- Now supporting **22** Charts!
|
||||
- Annotation, Area, Bar, Bubble, Calendar, Candlestick, Column, Combo, Gantt, Gauge, Geo, Histogram, Line, Org, Pie, Sankey, Scatter, SteppedArea, Table, Timeline, TreeMap, and WordTree!
|
||||
|
||||
|
||||
### For complete documentation, please visit [lavacharts.com](http://lavacharts.com/)
|
||||
|
||||
#### Upgrade guide: [Migrating from 2.5.x to 3.0.x](https://github.com/kevinkhill/lavacharts/wiki/Upgrading-from-2.5-to-3.0)
|
||||
#### For contributing, a handy guide [can be found here](https://github.com/kevinkhill/lavacharts/blob/master/.github/CONTRIBUTING.md)
|
||||
|
||||
---
|
||||
|
||||
## Installing
|
||||
In your project's main `composer.json` file, add this line to the requirements:
|
||||
```json
|
||||
"khill/lavacharts": "^3.1"
|
||||
```
|
||||
|
||||
Run Composer to install Lavacharts:
|
||||
```bash
|
||||
$ composer update
|
||||
```
|
||||
|
||||
## Framework Agnostic
|
||||
If you are using Lavacharts with Silex, Lumen or your own Composer project, that's no problem! Just make sure to:
|
||||
`require 'vendor/autoload.php';` within you project and create an instance of Lavacharts: `$lava = new Khill\Lavacharts\Lavacharts;`
|
||||
|
||||
|
||||
## Laravel
|
||||
To integrate Lavacharts into Laravel, a ServiceProvider has been included.
|
||||
|
||||
|
||||
### Laravel ~5.5
|
||||
Thanks to the fantastic new [Package Auto-Discovery](https://laravel-news.com/package-auto-discovery) feature added in 5.5, you're ready to go, no registration required :+1:
|
||||
|
||||
#### Configuration
|
||||
To modify the default configuration of Lavacharts, datetime formats for datatables or adding your maps api key...
|
||||
Publish the configuration with `php artisan vendor:publish --tag=lavacharts`
|
||||
|
||||
### Laravel ~5.4
|
||||
Register Lavacharts in your app by adding these lines to the respective arrays found in `config/app.php`:
|
||||
```php
|
||||
<?php
|
||||
// config/app.php
|
||||
|
||||
// ...
|
||||
'providers' => [
|
||||
// ...
|
||||
|
||||
Khill\Lavacharts\Laravel\LavachartsServiceProvider::class,
|
||||
],
|
||||
|
||||
// ...
|
||||
'aliases' => [
|
||||
// ...
|
||||
|
||||
'Lava' => Khill\Lavacharts\Laravel\LavachartsFacade::class,
|
||||
]
|
||||
```
|
||||
#### Configuration
|
||||
To modify the default configuration of Lavacharts, datetime formats for datatables or adding your maps api key...
|
||||
Publish the configuration with `php artisan vendor:publish --tag=lavacharts`
|
||||
|
||||
|
||||
### Laravel ~4
|
||||
Register Lavacharts in your app by adding these lines to the respective arrays found in `app/config/app.php`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// app/config/app.php
|
||||
|
||||
// ...
|
||||
'providers' => array(
|
||||
// ...
|
||||
|
||||
"Khill\Lavacharts\Laravel\LavachartsServiceProvider",
|
||||
),
|
||||
|
||||
// ...
|
||||
'aliases' => array(
|
||||
// ...
|
||||
|
||||
'Lava' => "Khill\Lavacharts\Laravel\LavachartsFacade",
|
||||
)
|
||||
```
|
||||
#### Configuration
|
||||
To modify the default configuration of Lavacharts, datetime formats for datatables or adding your maps api key...
|
||||
Publish the configuration with `php artisan config:publish khill/lavacharts`
|
||||
|
||||
|
||||
## Symfony
|
||||
The package also includes a Bundle for Symfony to enable Lavacharts as a service that can be pulled from the Container.
|
||||
|
||||
### Add Bundle
|
||||
Add the bundle to the registerBundles method in the AppKernel, found at `app/AppKernel.php`:
|
||||
```php
|
||||
<?php
|
||||
// app/AppKernel.php
|
||||
|
||||
class AppKernel extends Kernel
|
||||
{
|
||||
// ..
|
||||
|
||||
public function registerBundles()
|
||||
{
|
||||
$bundles = array(
|
||||
// ...
|
||||
|
||||
new Khill\Lavacharts\Symfony\Bundle\LavachartsBundle(),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
### Import Config
|
||||
Add the service definition to the `app/config/config.yml` file
|
||||
```yaml
|
||||
imports:
|
||||
# ...
|
||||
- { resource: "@LavachartsBundle/Resources/config/services.yml"
|
||||
```
|
||||
|
||||
|
||||
# Usage
|
||||
The creation of charts is separated into two parts:
|
||||
First, within a route or controller, you define the chart, the data table, and the customization of the output.
|
||||
|
||||
Second, within a view, you use one line and the library will output all the necessary JavaScript code for you.
|
||||
|
||||
## Basic Example
|
||||
Here is an example of the simplest chart you can create: A line chart with one dataset and a title, no configuration.
|
||||
|
||||
### Controller
|
||||
Setting up your first chart.
|
||||
|
||||
#### Data
|
||||
```php
|
||||
$data = $lava->DataTable();
|
||||
|
||||
$data->addDateColumn('Day of Month')
|
||||
->addNumberColumn('Projected')
|
||||
->addNumberColumn('Official');
|
||||
|
||||
// Random Data For Example
|
||||
for ($a = 1; $a < 30; $a++) {
|
||||
$rowData = [
|
||||
"2017-4-$a", rand(800,1000), rand(800,1000)
|
||||
];
|
||||
|
||||
$data->addRow($rowData);
|
||||
}
|
||||
```
|
||||
|
||||
Arrays work for datatables as well...
|
||||
```php
|
||||
$data->addColumns([
|
||||
['date', 'Day of Month'],
|
||||
['number', 'Projected'],
|
||||
['number', 'Official']
|
||||
]);
|
||||
```
|
||||
|
||||
Or you can `use \Khill\Lavacharts\DataTables\DataFactory` [to create DataTables in another way](https://gist.github.com/kevinkhill/0c7c5f6211c7fd8f9658)
|
||||
|
||||
#### Chart Options
|
||||
Customize your chart, with any options found in Google's documentation. Break objects down into arrays and pass to the chart.
|
||||
```php
|
||||
$lava->LineChart('Stocks', $data, [
|
||||
'title' => 'Stock Market Trends',
|
||||
'animation' => [
|
||||
'startup' => true,
|
||||
'easing' => 'inAndOut'
|
||||
],
|
||||
'colors' => ['blue', '#F4C1D8']
|
||||
]);
|
||||
```
|
||||
|
||||
#### Output ID
|
||||
The chart will needs to be output into a div on the page, so an html ID for a div is needed.
|
||||
Here is where you want your chart `<div id="stocks-div"></div>`
|
||||
- If no options for the chart are set, then the third parameter is the id of the output:
|
||||
```php
|
||||
$lava->LineChart('Stocks', $data, 'stocks-div');
|
||||
```
|
||||
- If there are options set for the chart, then the id may be included in the options:
|
||||
```php
|
||||
$lava->LineChart('Stocks', $data, [
|
||||
'elementId' => 'stocks-div'
|
||||
'title' => 'Stock Market Trends'
|
||||
]);
|
||||
```
|
||||
- The 4th parameter will also work:
|
||||
```php
|
||||
$lava->LineChart('Stocks', $data, [
|
||||
'title' => 'Stock Market Trends'
|
||||
], 'stocks-div');
|
||||
```
|
||||
|
||||
|
||||
## View
|
||||
Pass the main Lavacharts instance to the view, because all of the defined charts are stored within, and render!
|
||||
```php
|
||||
<?= $lava->render('LineChart', 'Stocks', 'stocks-div'); ?>
|
||||
```
|
||||
|
||||
Or if you have multiple charts, you can condense theh view code withL
|
||||
```php
|
||||
<?= $lava->renderAll(); ?>
|
||||
```
|
||||
|
||||
|
||||
# Changelog
|
||||
The complete changelog can be found [here](https://github.com/kevinkhill/lavacharts/wiki/Changelog)
|
||||
78
vendor/khill/lavacharts/composer.json
vendored
Normal file
78
vendor/khill/lavacharts/composer.json
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"name": "khill/lavacharts",
|
||||
"description": "PHP wrapper library for the Google Chart API",
|
||||
"keywords": [
|
||||
"charts",
|
||||
"graphs",
|
||||
"google",
|
||||
"laravel",
|
||||
"symfony"
|
||||
],
|
||||
"homepage": "http://lavacharts.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kevin Hill",
|
||||
"email": "kevinkhill@gmail.com",
|
||||
"role": "Creator"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"docs": "http://lavacharts.com",
|
||||
"email": "kevinkhill@gmail.com",
|
||||
"forum": "https://gitter.im/kevinkhill/lavacharts",
|
||||
"wiki": "https://github.com/kevinkhill/lavacharts/wiki",
|
||||
"source": "https://github.com/kevinkhill/lavacharts",
|
||||
"issues": "https://github.com/kevinkhill/lavacharts/issues"
|
||||
},
|
||||
"suggest": {
|
||||
"khill/datatableplus": "Adds extra features to DataTables such as csv and laravel collection parsing."
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"nesbot/carbon": "~1.14"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Khill\\Lavacharts\\": "src/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.8",
|
||||
"mockery/mockery": "~0.9",
|
||||
"squizlabs/php_codesniffer": "~2.5",
|
||||
"satooshi/php-coveralls": "~1.0",
|
||||
"codeclimate/php-test-reporter": "~0.3"
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Khill\\Lavacharts\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phpunit -c phpunit.xml",
|
||||
"cs": "phpcs --standard=PSR2 src tests",
|
||||
"cbf" : "phpcbf --standard=PSR2 src tests",
|
||||
"version": "php -r \"require(__DIR__.\\\"/src/Lavacharts.php\\\");echo \\Khill\\Lavacharts\\Lavacharts::VERSION;\"",
|
||||
"lavajs:release" : "gulp --cwd javascript release && git add javascript/dist/lava.js && git commit -m 'Releasing new build of the lava.js module' && git push",
|
||||
"lavajs:gulp" : "gulp --cwd javascript",
|
||||
"lavajs:pull" : "git subtree --prefix=javascript pull lavajs master",
|
||||
"lavajs:push" : "git subtree --prefix=javascript push lavajs master"
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Khill\\Lavacharts\\Laravel\\LavachartsServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Lava": "Khill\\Lavacharts\\Laravel\\LavachartsFacade"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "5.4"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable"
|
||||
}
|
||||
2097
vendor/khill/lavacharts/composer.lock
generated
vendored
Normal file
2097
vendor/khill/lavacharts/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
vendor/khill/lavacharts/javascript/dist/lava.js
vendored
Normal file
4
vendor/khill/lavacharts/javascript/dist/lava.js
vendored
Normal file
File diff suppressed because one or more lines are too long
17
vendor/khill/lavacharts/javascript/karma.conf.js
vendored
Normal file
17
vendor/khill/lavacharts/javascript/karma.conf.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
frameworks: ['jasmine','sinon'],
|
||||
files: [
|
||||
'./node_modules/jasmine-sinon/lib/jasmine-sinon.js',
|
||||
'./dist/lava.js',
|
||||
'./tests/lava.spec.js'
|
||||
],
|
||||
singleRun: false,
|
||||
reporters: ['dots'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_ERROR,
|
||||
autoWatch: true,
|
||||
browsers: [(process.env.TRAVIS ? 'PhantomJS' : 'Chrome')]
|
||||
});
|
||||
};
|
||||
19
vendor/khill/lavacharts/javascript/phantomjs/compare.js
vendored
Normal file
19
vendor/khill/lavacharts/javascript/phantomjs/compare.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/* jshint undef: true */
|
||||
/* globals module, require, phantom, window */
|
||||
"use strict";
|
||||
|
||||
var resemble = require('node-resemble-js');
|
||||
|
||||
var rendersDir = './javascript/phantomjs/renders/';
|
||||
var args = process.argv;
|
||||
var chart = args[2];
|
||||
|
||||
resemble(rendersDir + chart + '.png').compareTo(rendersDir + chart + '.png').onComplete(function (data) {
|
||||
//console.log(data);
|
||||
|
||||
if (Number(data.misMatchPercentage) <= 0.01) {
|
||||
console.log('Pass!');
|
||||
} else {
|
||||
console.log('Fail!');
|
||||
}
|
||||
});
|
||||
33
vendor/khill/lavacharts/javascript/phantomjs/render.js
vendored
Normal file
33
vendor/khill/lavacharts/javascript/phantomjs/render.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/* jshint undef: true */
|
||||
/* globals module, require, phantom, window */
|
||||
"use strict";
|
||||
|
||||
var page = require('webpage').create();
|
||||
var args = require('system').args;
|
||||
|
||||
var renderOutputDir = './javascript/phantomjs/renders';
|
||||
var url = 'http://127.0.0.1:5000/';
|
||||
var chart = args[1];
|
||||
|
||||
page.onConsoleMessage = function(msg) {
|
||||
console.log(msg);
|
||||
};
|
||||
|
||||
page.open(url + chart, function (status) {
|
||||
if (status !== "success") {
|
||||
console.log('Error loading page.');
|
||||
} else {
|
||||
console.log('Page loaded, waiting on chart to render.');
|
||||
|
||||
page.onCallback = function (data) {
|
||||
page.render(renderOutputDir + '/' + chart + '.png');
|
||||
|
||||
console.log('Saved to disk.');
|
||||
|
||||
phantom.exit();
|
||||
|
||||
//console.log('CALLBACK: ' + JSON.stringify(data));
|
||||
// Prints 'CALLBACK: { "hello": "world" }'
|
||||
};
|
||||
}
|
||||
});
|
||||
44
vendor/khill/lavacharts/javascript/src/lava.entry.js
vendored
Normal file
44
vendor/khill/lavacharts/javascript/src/lava.entry.js
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/* jshint undef: true, unused: true */
|
||||
/* globals window, require */
|
||||
|
||||
/**
|
||||
* Lava.js entry point for Browserify
|
||||
*/
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var window = this;
|
||||
var debounced = null;
|
||||
var debounceTimeout = 250;
|
||||
var bind = require('lodash').bind;
|
||||
var ready = require('document-ready');
|
||||
var addResizeEvent = require('./lava/Utils').addResizeEvent;
|
||||
|
||||
window.lava = require('./lava/Lava.js');
|
||||
|
||||
/**
|
||||
* Once the window is ready...
|
||||
*/
|
||||
ready(function() {
|
||||
/**
|
||||
* Adding the resize event listener for redrawing charts.
|
||||
*/
|
||||
addResizeEvent(function (event) {
|
||||
var redraw = bind(event.target.lava.redrawCharts, window.lava);
|
||||
|
||||
console.log('Window resized, redrawing charts');
|
||||
|
||||
clearTimeout(debounced);
|
||||
|
||||
debounced = setTimeout(redraw, debounceTimeout);
|
||||
});
|
||||
|
||||
/**
|
||||
* Let's go!
|
||||
*/
|
||||
|
||||
if (window.lava.options.auto_run === true) {
|
||||
window.lava.run();
|
||||
}
|
||||
});
|
||||
}.apply(window));
|
||||
162
vendor/khill/lavacharts/javascript/src/lava/Chart.js
vendored
Normal file
162
vendor/khill/lavacharts/javascript/src/lava/Chart.js
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
/* jshint undef: true */
|
||||
/* globals document, google, require, module */
|
||||
|
||||
/**
|
||||
* Chart class used for storing all the needed configuration for rendering.
|
||||
*
|
||||
* @typedef {Function} Chart
|
||||
* @property {string} label - Label for the chart.
|
||||
* @property {string} type - Type of chart.
|
||||
* @property {Object} element - Html element in which to render the chart.
|
||||
* @property {Object} chart - Google chart object.
|
||||
* @property {string} package - Type of Google chart package to load.
|
||||
* @property {boolean} pngOutput - Should the chart be displayed as a PNG.
|
||||
* @property {Object} data - Datatable for the chart.
|
||||
* @property {Object} options - Configuration options for the chart.
|
||||
* @property {Array} formats - Formatters to apply to the chart data.
|
||||
* @property {Object} promises - Promises used in the rendering chain.
|
||||
* @property {Function} init - Initializes the chart.
|
||||
* @property {Function} configure - Configures the chart.
|
||||
* @property {Function} render - Renders the chart.
|
||||
* @property {Function} uuid - Creates identification string for the chart.
|
||||
* @property {Object} _errors - Collection of errors to be thrown.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Chart module
|
||||
*
|
||||
* @class Chart
|
||||
* @module lava/Chart
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @license MIT
|
||||
*/
|
||||
module.exports = (function() {
|
||||
'use strict';
|
||||
|
||||
var Q = require('q');
|
||||
|
||||
/**
|
||||
* Chart Class
|
||||
*
|
||||
* This is the javascript version of a lavachart with methods for interacting with
|
||||
* the google chart and the PHP lavachart output.
|
||||
*
|
||||
* @param {string} type
|
||||
* @param {string} label
|
||||
* @constructor
|
||||
*/
|
||||
function Chart (type, label) {
|
||||
this.label = label;
|
||||
this.type = type;
|
||||
this.element = null;
|
||||
this.chart = null;
|
||||
this.package = null;
|
||||
this.pngOutput = false;
|
||||
this.data = {};
|
||||
this.options = {};
|
||||
this.formats = [];
|
||||
this.promises = {
|
||||
configure: Q.defer(),
|
||||
rendered: Q.defer()
|
||||
};
|
||||
this.init = function(){};
|
||||
this.configure = function(){};
|
||||
this.render = function(){};
|
||||
this.uuid = function() {
|
||||
return this.type+'::'+this.label;
|
||||
};
|
||||
this._errors = require('./Errors.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data for the chart by creating a new DataTable
|
||||
*
|
||||
* @public
|
||||
* @external "google.visualization.DataTable"
|
||||
* @see {@link https://developers.google.com/chart/interactive/docs/reference#DataTable|DataTable Class}
|
||||
* @param {object} data Json representation of a DataTable
|
||||
* @param {Array.<Array>} data.cols Array of column definitions
|
||||
* @param {Array.<Array>} data.rows Array of row definitions
|
||||
*/
|
||||
Chart.prototype.setData = function (data) {
|
||||
this.data = new google.visualization.DataTable(data);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the options for the chart.
|
||||
*
|
||||
* @public
|
||||
* @param {object} options
|
||||
*/
|
||||
Chart.prototype.setOptions = function (options) {
|
||||
this.options = options;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets whether the chart is to be rendered as PNG or SVG
|
||||
*
|
||||
* @public
|
||||
* @param {string|int} png
|
||||
*/
|
||||
Chart.prototype.setPngOutput = function (png) {
|
||||
this.pngOutput = Boolean(typeof png == 'undefined' ? false : png);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the ID of the output element for the Dashboard.
|
||||
*
|
||||
* @public
|
||||
* @param {string} elemId
|
||||
* @throws ElementIdNotFound
|
||||
*/
|
||||
Chart.prototype.setElement = function (elemId) {
|
||||
this.element = document.getElementById(elemId);
|
||||
|
||||
if (! this.element) {
|
||||
throw new this._errors.ElementIdNotFound(elemId);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Redraws the chart.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
Chart.prototype.redraw = function() {
|
||||
this.chart.draw(this.data, this.options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws the chart as a PNG instead of the standard SVG
|
||||
*
|
||||
* @public
|
||||
* @external "chart.getImageURI"
|
||||
* @see {@link https://developers.google.com/chart/interactive/docs/printing|Printing PNG Charts}
|
||||
*/
|
||||
Chart.prototype.drawPng = function() {
|
||||
var img = document.createElement('img');
|
||||
img.src = this.chart.getImageURI();
|
||||
|
||||
this.element.innerHTML = '';
|
||||
this.element.appendChild(img);
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats columns of the DataTable.
|
||||
*
|
||||
* @public
|
||||
* @param {Array.<Object>} formatArr Array of format definitions
|
||||
*/
|
||||
Chart.prototype.applyFormats = function (formatArr) {
|
||||
for(var a=0; a < formatArr.length; a++) {
|
||||
var formatJson = formatArr[a];
|
||||
var formatter = new google.visualization[formatJson.type](formatJson.config);
|
||||
|
||||
formatter.format(this.data, formatJson.index);
|
||||
}
|
||||
};
|
||||
|
||||
return Chart;
|
||||
|
||||
}());
|
||||
74
vendor/khill/lavacharts/javascript/src/lava/Dashboard.js
vendored
Normal file
74
vendor/khill/lavacharts/javascript/src/lava/Dashboard.js
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/* jshint undef: true */
|
||||
/* globals document, google, require, module */
|
||||
|
||||
/**
|
||||
* Dashboard module
|
||||
*
|
||||
* @class Dashboard
|
||||
* @module lava/Dashboard
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @license MIT
|
||||
*/
|
||||
module.exports = (function() {
|
||||
'use strict';
|
||||
|
||||
var Q = require('q');
|
||||
|
||||
/**
|
||||
* Dashboard Class
|
||||
*
|
||||
* This is the javascript version of a dashboard with methods for interacting with
|
||||
* the google chart and the PHP lavachart output.
|
||||
*
|
||||
* @param {String} label
|
||||
* @constructor
|
||||
*/
|
||||
function Dashboard (label) {
|
||||
this.label = label;
|
||||
this.type = 'Dashboard';
|
||||
this.element = null;
|
||||
this.data = null;
|
||||
this.bindings = [];
|
||||
this.dashboard = null;
|
||||
this.deferred = Q.defer();
|
||||
this.init = function(){};
|
||||
this.configure = function(){};
|
||||
this.render = function(){};
|
||||
this.uuid = function() {
|
||||
return this.type+'::'+this.label;
|
||||
};
|
||||
this._errors = require('./Errors.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data for the chart by creating a new DataTable
|
||||
*
|
||||
* @external "google.visualization.DataTable"
|
||||
* @see {@link https://developers.google.com/chart/interactive/docs/reference#DataTable|DataTable}
|
||||
* @param {Object} data Json representation of a DataTable
|
||||
* @param {Array.<Array>} data.cols Array of column definitions
|
||||
* @param {Array.<Array>} data.rows Array of row definitions
|
||||
*/
|
||||
Dashboard.prototype.setData = function (data) {
|
||||
this.data = new google.visualization.DataTable(data);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the ID of the output element for the Dashboard.
|
||||
*
|
||||
* @public
|
||||
* @param {string} elemId
|
||||
* @throws ElementIdNotFound
|
||||
*/
|
||||
Dashboard.prototype.setElement = function (elemId) {
|
||||
this.element = document.getElementById(elemId);
|
||||
|
||||
if (! this.element) {
|
||||
throw new this._errors.ElementIdNotFound(elemId);
|
||||
}
|
||||
};
|
||||
|
||||
return Dashboard;
|
||||
|
||||
}());
|
||||
82
vendor/khill/lavacharts/javascript/src/lava/Errors.js
vendored
Normal file
82
vendor/khill/lavacharts/javascript/src/lava/Errors.js
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/* jshint undef: true */
|
||||
/* globals module, require */
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Errors module
|
||||
*
|
||||
* @module lava/Errors
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @license MIT
|
||||
*/
|
||||
var LavachartsError = function (message) {
|
||||
this.name = 'LavachartsError';
|
||||
this.message = (message || '');
|
||||
};
|
||||
LavachartsError.prototype = Error.prototype;
|
||||
|
||||
/**
|
||||
* InvalidCallback Error
|
||||
*
|
||||
* thrown when when anything but a function is given as a callback
|
||||
* @type {function}
|
||||
*/
|
||||
var InvalidCallback = function (callback) {
|
||||
this.name = 'InvalidCallback';
|
||||
this.message = '[Lavacharts] ' + typeof callback + ' is not a valid callback.';
|
||||
};
|
||||
InvalidCallback.prototype = LavachartsError.prototype;
|
||||
module.exports.InvalidCallback = InvalidCallback;
|
||||
|
||||
/**
|
||||
* InvalidLabel Error
|
||||
*
|
||||
* Thrown when when anything but a string is given as a label.
|
||||
*
|
||||
* @type {function}
|
||||
*/
|
||||
module.exports.InvalidLabel = function (label) {
|
||||
this.name = 'InvalidLabel';
|
||||
this.message = '[Lavacharts] "' + typeof label + '" is not a valid label.';
|
||||
};
|
||||
module.exports.InvalidLabel.prototype = Error.prototype;
|
||||
|
||||
/**
|
||||
* ElementIdNotFound Error
|
||||
*
|
||||
* Thrown when when anything but a string is given as a label.
|
||||
*
|
||||
* @type {function}
|
||||
*/
|
||||
module.exports.ElementIdNotFound = function (elemId) {
|
||||
this.name = 'ElementIdNotFound';
|
||||
this.message = '[Lavacharts] DOM node #' + elemId + ' was not found.';
|
||||
};
|
||||
module.exports.ElementIdNotFound.prototype = Error.prototype;
|
||||
|
||||
/**
|
||||
* ChartNotFound Error
|
||||
*
|
||||
* Thrown when when the getChart() method cannot find a chart with the given label.
|
||||
*
|
||||
* @type {function}
|
||||
*/
|
||||
module.exports.ChartNotFound = function (label) {
|
||||
this.name = 'ChartNotFound';
|
||||
this.message = '[Lavacharts] Chart with label "' + label + '" was not found.';
|
||||
};
|
||||
module.exports.ChartNotFound.prototype = Error.prototype;
|
||||
|
||||
/**
|
||||
* DashboardNotFound Error
|
||||
*
|
||||
* Thrown when when the getDashboard() method cannot find a chart with the given label.
|
||||
*
|
||||
* @type {function}
|
||||
*/
|
||||
module.exports.DashboardNotFound = function (label) {
|
||||
this.name = 'DashboardNotFound';
|
||||
this.message = '[Lavacharts] Dashboard with label "' + label + '" was not found.';
|
||||
};
|
||||
module.exports.DashboardNotFound.prototype = Error.prototype;
|
||||
540
vendor/khill/lavacharts/javascript/src/lava/Lava.js
vendored
Normal file
540
vendor/khill/lavacharts/javascript/src/lava/Lava.js
vendored
Normal file
@@ -0,0 +1,540 @@
|
||||
/* jshint undef: true, unused: true */
|
||||
/* globals window, document, console, google, module, require */
|
||||
|
||||
/**
|
||||
* lava.js module
|
||||
*
|
||||
* @module lava/Lava
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
module.exports = (function() {
|
||||
'use strict';
|
||||
|
||||
var Q = require('q');
|
||||
// var Promise = require('bluebird');
|
||||
var _ = require('lodash');
|
||||
var util = require('util');
|
||||
var EventEmitter = require('events');
|
||||
|
||||
function Lava() {
|
||||
/**
|
||||
* Defining the Chart class within the module.
|
||||
*
|
||||
* @type {Chart}
|
||||
*/
|
||||
this.Chart = require('./Chart.js');
|
||||
|
||||
/**
|
||||
* Defining the Dashboard class within the module.
|
||||
*
|
||||
* @type {Dashboard}
|
||||
*/
|
||||
this.Dashboard = require('./Dashboard.js');
|
||||
|
||||
/**
|
||||
* Urls to Google's static loader
|
||||
*
|
||||
* @type {string}
|
||||
* @public
|
||||
*/
|
||||
this.gstaticUrl = 'https://www.gstatic.com/charts/loader.js';
|
||||
|
||||
/**
|
||||
* JSON object of config items.
|
||||
*
|
||||
* @type {Object}
|
||||
* @private
|
||||
*/
|
||||
this.options = (function () {
|
||||
if (typeof OPTIONS_JSON !== 'object') {
|
||||
return {};
|
||||
}
|
||||
|
||||
return OPTIONS_JSON;
|
||||
}());
|
||||
|
||||
/**
|
||||
* Array of charts stored in the module.
|
||||
*
|
||||
* @type {Array.<Chart>}
|
||||
* @private
|
||||
*/
|
||||
this._charts = [];
|
||||
|
||||
/**
|
||||
* Array of dashboards stored in the module.
|
||||
*
|
||||
* @type {Array.<Dashboard>}
|
||||
* @private
|
||||
*/
|
||||
this._dashboards = [];
|
||||
|
||||
/**
|
||||
* Ready callback to be called when the module is finished running.
|
||||
*
|
||||
* @callback _readyCallback
|
||||
* @private
|
||||
*/
|
||||
this._readyCallback = _.noop();
|
||||
|
||||
/**
|
||||
* Error definitions for the module.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
this._errors = require('./Errors.js');
|
||||
|
||||
/**
|
||||
* Apply the EventEmitter methods to Lava
|
||||
*/
|
||||
EventEmitter.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from the EventEmitter
|
||||
*/
|
||||
util.inherits(Lava, EventEmitter);
|
||||
|
||||
/**
|
||||
* Initialize the Lava.js module by attaching the event listeners
|
||||
* and calling the charts' and dashboards' init methods
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
Lava.prototype.init = function () {
|
||||
console.log('[lava.js] Initializing');
|
||||
|
||||
var $lava = this;
|
||||
var readyCount = 0;
|
||||
|
||||
this.on('ready', function (renderable) {
|
||||
console.log('[lava.js] ' + renderable.uuid() + ' -> ready');
|
||||
|
||||
readyCount++;
|
||||
|
||||
if (readyCount === $lava._getRenderables().length) {
|
||||
console.log('[lava.js] Loading Google');
|
||||
|
||||
$lava._loadGoogle().then(function() {
|
||||
return $lava._mapRenderables(function (renderable) {
|
||||
console.log('[lava.js] ' + renderable.uuid() + ' -> configuring');
|
||||
|
||||
return renderable.configure();
|
||||
});
|
||||
}).then(function() {
|
||||
return $lava._mapRenderables(function (renderable) {
|
||||
console.log('[lava.js] ' + renderable.uuid() + ' -> rendering');
|
||||
|
||||
return renderable.render();
|
||||
});
|
||||
}).then(function() {
|
||||
console.log('[lava.js] Ready, firing ready callback');
|
||||
|
||||
$lava._readyCallback();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs the Lava.js module by calling all the renderables' init methods
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
Lava.prototype.run = function () {
|
||||
this.init();
|
||||
|
||||
this._forEachRenderable(function (renderable) {
|
||||
console.log('[lava.js] ' + renderable.uuid() + ' -> initializing');
|
||||
|
||||
renderable.init();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores a renderable lava object within the module.
|
||||
*
|
||||
* @param {Chart|Dashboard} renderable
|
||||
*/
|
||||
Lava.prototype.store = function (renderable) {
|
||||
if (renderable instanceof this.Chart) {
|
||||
this.storeChart(renderable);
|
||||
}
|
||||
|
||||
if (renderable instanceof this.Dashboard) {
|
||||
this.storeDashboard(renderable);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Assigns a callback for when the charts are ready to be interacted with.
|
||||
*
|
||||
* This is used to wrap calls to lava.loadData() or lava.loadOptions()
|
||||
* to protect against accessing charts that aren't loaded yet
|
||||
*
|
||||
* @public
|
||||
* @param {Function} callback
|
||||
*/
|
||||
Lava.prototype.ready = function (callback) {
|
||||
if (typeof callback !== 'function') {
|
||||
throw new this._errors.InvalidCallback(callback);
|
||||
}
|
||||
|
||||
this._readyCallback = callback;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event wrapper for chart events.
|
||||
*
|
||||
*
|
||||
* Used internally when events are applied so the user event function has
|
||||
* access to the chart within the event callback.
|
||||
*
|
||||
* @param {Object} event
|
||||
* @param {Object} lavachart
|
||||
* @param {Function} callback
|
||||
* @return {Function}
|
||||
*/
|
||||
Lava.prototype.event = function (event, lavachart, callback) {
|
||||
if (typeof callback !== 'function') {
|
||||
throw new this._errors.InvalidCallback(callback);
|
||||
}
|
||||
|
||||
return callback(event, lavachart.chart, lavachart.data);
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads new data into the chart and redraws.
|
||||
*
|
||||
*
|
||||
* Used with an AJAX call to a PHP method returning DataTable->toJson(),
|
||||
* a chart can be dynamically update in page, without reloads.
|
||||
*
|
||||
* @public
|
||||
* @param {string} label
|
||||
* @param {string} json
|
||||
* @param {Function} callback
|
||||
*/
|
||||
Lava.prototype.loadData = function (label, json, callback) {
|
||||
if (typeof callback === 'undefined') {
|
||||
callback = _.noop;
|
||||
}
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
throw new this._errors.InvalidCallback(callback);
|
||||
}
|
||||
|
||||
this.getChart(label, function (chart) {
|
||||
if (typeof json.data !== 'undefined') {
|
||||
chart.setData(json.data);
|
||||
} else {
|
||||
chart.setData(json);
|
||||
}
|
||||
|
||||
if (typeof json.formats !== 'undefined') {
|
||||
chart.applyFormats(json.formats);
|
||||
}
|
||||
|
||||
chart.redraw();
|
||||
|
||||
callback(chart);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads new options into a chart and redraws.
|
||||
*
|
||||
*
|
||||
* Used with an AJAX call, or javascript events, to load a new array of options into a chart.
|
||||
* This can be used to update a chart dynamically, without reloads.
|
||||
*
|
||||
* @public
|
||||
* @param {string} label
|
||||
* @param {string} json
|
||||
* @param {Function} callback
|
||||
*/
|
||||
Lava.prototype.loadOptions = function (label, json, callback) {
|
||||
if (typeof callback === 'undefined') {
|
||||
callback = callback || _.noop;
|
||||
}
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
throw new this._errors.InvalidCallback(callback);
|
||||
}
|
||||
|
||||
this.getChart(label, function (chart) {
|
||||
chart.setOptions(json);
|
||||
|
||||
chart.redraw();
|
||||
|
||||
callback(chart);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Redraws all of the registered charts on screen.
|
||||
*
|
||||
* This method is attached to the window resize event with a 300ms debounce
|
||||
* to make the charts responsive to the browser resizing.
|
||||
*/
|
||||
Lava.prototype.redrawCharts = function() {
|
||||
this._forEachRenderable(function (renderable) {
|
||||
console.log('[lava.js] ' + renderable.uuid() + ' -> redrawing');
|
||||
|
||||
var redraw = _.bind(renderable.redraw, renderable);
|
||||
|
||||
redraw();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new Chart.
|
||||
*
|
||||
* @public
|
||||
* @param {string} type Type of chart to create
|
||||
* @param {string} label Label for the chart
|
||||
* @return {Chart}
|
||||
*/
|
||||
Lava.prototype.createChart = function (type, label) {
|
||||
return new this.Chart(type, label);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores a chart within the module.
|
||||
*
|
||||
* @public
|
||||
* @param {Chart} chart
|
||||
*/
|
||||
Lava.prototype.storeChart = function (chart) {
|
||||
this._charts.push(chart);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the LavaChart javascript objects
|
||||
*
|
||||
*
|
||||
* The LavaChart object holds all the user defined properties such as data, options, formats,
|
||||
* the GoogleChart object, and relative methods for internal use.
|
||||
*
|
||||
* The GoogleChart object is available as ".chart" from the returned LavaChart.
|
||||
* It can be used to access any of the available methods such as
|
||||
* getImageURI() or getChartLayoutInterface().
|
||||
* See https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#methods
|
||||
* for some examples relative to LineCharts.
|
||||
*
|
||||
* @public
|
||||
* @param {string} label
|
||||
* @param {Function} callback
|
||||
* @throws InvalidLabel
|
||||
* @throws InvalidCallback
|
||||
* @throws ChartNotFound
|
||||
*/
|
||||
Lava.prototype.getChart = function (label, callback) {
|
||||
if (typeof label !== 'string') {
|
||||
throw new this._errors.InvalidLabel(label);
|
||||
}
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
throw new this._errors.InvalidCallback(callback);
|
||||
}
|
||||
|
||||
var chart = _.find(this._charts, {label: label});
|
||||
|
||||
if (!chart) {
|
||||
throw new this._errors.ChartNotFound(label);
|
||||
}
|
||||
|
||||
callback(chart);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new Dashboard with a given label.
|
||||
*
|
||||
* @public
|
||||
* @param {string} label
|
||||
* @return {Dashboard}
|
||||
*/
|
||||
Lava.prototype.createDashboard = function (label) {
|
||||
return new this.Dashboard(label);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores a dashboard within the module.
|
||||
*
|
||||
* @public
|
||||
* @param {Dashboard} dash
|
||||
*/
|
||||
Lava.prototype.storeDashboard = function (dash) {
|
||||
this._dashboards.push(dash);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve a Dashboard from Lava.js
|
||||
*
|
||||
* @public
|
||||
* @param {string} label Dashboard label
|
||||
* @param {Function} callback Callback function
|
||||
* @throws InvalidLabel
|
||||
* @throws InvalidCallback
|
||||
* @throws DashboardNotFound
|
||||
*/
|
||||
Lava.prototype.getDashboard = function (label, callback) {
|
||||
if (typeof label !== 'string') {
|
||||
throw new this._errors.InvalidLabel(label);
|
||||
}
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
throw new this._errors.InvalidCallback(callback);
|
||||
}
|
||||
|
||||
var dash = _.find(this._dashboards, {label: label});
|
||||
|
||||
if (dash instanceof this.Dashboard === false) {
|
||||
throw new this._errors.DashboardNotFound(label);
|
||||
}
|
||||
|
||||
callback(dash);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an array with the charts and dashboards.
|
||||
*
|
||||
* @private
|
||||
* @return {Array}
|
||||
*/
|
||||
Lava.prototype._getRenderables = function () {
|
||||
return _.concat(this._charts, this._dashboards);
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies the callback to each of the charts and dashboards.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} callback
|
||||
*/
|
||||
Lava.prototype._forEachRenderable = function (callback) {
|
||||
_.forEach(this._getRenderables(), callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies the callback and builds an array of return values
|
||||
* for each of the charts and dashboards.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} callback
|
||||
* @return {Array}
|
||||
*/
|
||||
Lava.prototype._mapRenderables = function (callback) {
|
||||
return _.map(this._getRenderables(), callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an array of the google packages to load.
|
||||
*
|
||||
* @private
|
||||
* @return {Array}
|
||||
*/
|
||||
Lava.prototype._getPackages = function () {
|
||||
return _.union(
|
||||
_.map(this._charts, 'package'),
|
||||
_.flatten(_.map(this._dashboards, 'packages'))
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if Google's Static Loader is in page.
|
||||
*
|
||||
* @private
|
||||
* @returns {boolean}
|
||||
*/
|
||||
Lava.prototype._googleIsLoaded = function () {
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
var loaded = false;
|
||||
|
||||
for (var i = scripts.length; i--;) {
|
||||
if (scripts[i].src === this.gstaticUrl) {
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
return loaded;
|
||||
};
|
||||
|
||||
/**
|
||||
* Load the Google Static Loader and resolve the promise when ready.
|
||||
*
|
||||
* @private
|
||||
* @returns {Promise}
|
||||
*/
|
||||
Lava.prototype._loadGoogle = function () {
|
||||
var $lava = this;
|
||||
var deferred = Q.defer();
|
||||
var script = this._createScriptTag(deferred);
|
||||
|
||||
if (this._googleIsLoaded()) {
|
||||
console.log('[lava.js] Static loader found, initializing window.google');
|
||||
|
||||
$lava._googleChartLoader(deferred);
|
||||
} else {
|
||||
console.log('[lava.js] Static loader not found, appending to head');
|
||||
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new script tag for the Google Static Loader.
|
||||
*
|
||||
* @private
|
||||
* @param {Promise} deferred
|
||||
* @returns {Element}
|
||||
*/
|
||||
Lava.prototype._createScriptTag = function (deferred) {
|
||||
var script = document.createElement('script');
|
||||
var $lava = this;
|
||||
|
||||
script.type = 'text/javascript';
|
||||
script.async = true;
|
||||
script.src = this.gstaticUrl;
|
||||
script.onload = script.onreadystatechange = function (event) {
|
||||
event = event || window.event;
|
||||
|
||||
if (event.type === 'load' || (/loaded|complete/.test(this.readyState))) {
|
||||
this.onload = this.onreadystatechange = null;
|
||||
|
||||
$lava._googleChartLoader(deferred);
|
||||
}
|
||||
};
|
||||
|
||||
return script;
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs the Google chart loader and resolves the promise.
|
||||
*
|
||||
* @param {Promise} deferred
|
||||
* @private
|
||||
*/
|
||||
Lava.prototype._googleChartLoader = function (deferred) {
|
||||
var config = {
|
||||
packages: this._getPackages(),
|
||||
language: this.options.locale
|
||||
};
|
||||
|
||||
if (this.options.maps_api_key !== '') {
|
||||
config.mapsApiKey = this.options.maps_api_key;
|
||||
}
|
||||
|
||||
console.log('[lava.js] Google loaded with options:', config);
|
||||
|
||||
google.charts.load('current', config);
|
||||
|
||||
google.charts.setOnLoadCallback(deferred.resolve);
|
||||
};
|
||||
|
||||
return new Lava();
|
||||
}());
|
||||
22
vendor/khill/lavacharts/javascript/src/lava/Utils.js
vendored
Normal file
22
vendor/khill/lavacharts/javascript/src/lava/Utils.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/* jshint undef: true, unused: true */
|
||||
/* globals exports, window */
|
||||
|
||||
/**
|
||||
* Slightly modified event attachment handler.
|
||||
*
|
||||
* Credit to Alex V.
|
||||
*
|
||||
* @link https://stackoverflow.com/users/327934/alex-v
|
||||
* @link http://stackoverflow.com/a/3150139
|
||||
* @param {Function} callback
|
||||
*/
|
||||
exports.addResizeEvent = function (callback) {
|
||||
if (window === null || typeof(window) === 'undefined') return;
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener('resize', callback, false);
|
||||
} else if (window.attachEvent) {
|
||||
window.attachEvent('onresize', callback);
|
||||
} else {
|
||||
window['onresize'] = callback;
|
||||
}
|
||||
};
|
||||
43
vendor/khill/lavacharts/javascript/templates/chart.tmpl.js
vendored
Normal file
43
vendor/khill/lavacharts/javascript/templates/chart.tmpl.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/* jshint undef: true, unused: true */
|
||||
/* globals lava, google */
|
||||
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var $chart = lava.createChart('<chartType>', '<chartLabel>');
|
||||
|
||||
$chart.init = function() {
|
||||
$chart.package = '<chartPackage>';
|
||||
$chart.setElement('<elemId>');
|
||||
$chart.setPngOutput(<pngOutput>);
|
||||
|
||||
$chart.configure = function () {
|
||||
$chart.render = function (data) {
|
||||
$chart.setData(<chartData>);
|
||||
|
||||
$chart.options = <chartOptions>;
|
||||
|
||||
$chart.chart = new <chartClass>($chart.element);
|
||||
|
||||
<formats>
|
||||
<events>
|
||||
|
||||
$chart.chart.draw($chart.data, $chart.options);
|
||||
|
||||
if ($chart.pngOutput === true) {
|
||||
$chart.drawPng();
|
||||
}
|
||||
|
||||
$chart.promises.rendered.resolve();
|
||||
return $chart.promises.rendered.promise;
|
||||
};
|
||||
|
||||
$chart.promises.configure.resolve();
|
||||
return $chart.promises.configure.promise;
|
||||
};
|
||||
|
||||
lava.emit('ready', $chart);
|
||||
};
|
||||
|
||||
lava.store($chart);
|
||||
})();
|
||||
34
vendor/khill/lavacharts/javascript/templates/dashboard.tmpl.js
vendored
Normal file
34
vendor/khill/lavacharts/javascript/templates/dashboard.tmpl.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/* jshint undef: true, unused: true */
|
||||
/* globals lava, google */
|
||||
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var $dash = lava.createDashboard('<label>');
|
||||
|
||||
$dash.init = function () {
|
||||
$dash.setElement('<elemId>');
|
||||
$dash.packages = <packages>;
|
||||
|
||||
$dash.configure = function () {
|
||||
$dash.render = function (data) {
|
||||
$dash.dashboard = new <class>($dash.element);
|
||||
|
||||
$dash.setData(<chartData>);
|
||||
|
||||
<bindings>
|
||||
|
||||
$dash.dashboard.draw($dash.data);
|
||||
|
||||
lava.emit('rendered', $dash);
|
||||
};
|
||||
|
||||
$dash.deferred.resolve();
|
||||
return $dash.deferred.promise;
|
||||
};
|
||||
|
||||
lava.emit('ready', $dash);
|
||||
};
|
||||
|
||||
lava.store($dash);
|
||||
})();
|
||||
56
vendor/khill/lavacharts/phpunit.xml
vendored
Normal file
56
vendor/khill/lavacharts/phpunit.xml
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
syntaxCheck="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="core">
|
||||
<file>tests/LavachartsTest.php</file>
|
||||
<file>tests/VolcanoTest.php</file>
|
||||
</testsuite>
|
||||
<testsuite name="charts">
|
||||
<directory>tests/Charts/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="dashboards">
|
||||
<directory>tests/Dashboards/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="datatables">
|
||||
<directory>tests/DataTables/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="javascript">
|
||||
<directory>tests/Javascript/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="values">
|
||||
<directory>tests/Values/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<blacklist>
|
||||
<directory>vendor/</directory>
|
||||
<directory>tests/</directory>
|
||||
<directory>src/Laravel/</directory>
|
||||
<directory>src/Symfony/</directory>
|
||||
</blacklist>
|
||||
</filter>
|
||||
|
||||
<logging>
|
||||
<log type="coverage-clover"
|
||||
target="build/logs/clover.xml"
|
||||
charset="UTF-8"
|
||||
highlight="false"
|
||||
lowUpperBound="35"
|
||||
highLowerBound="70" />
|
||||
<log type="testdox-html"
|
||||
target="build/logs/testdox.html" />
|
||||
</logging>
|
||||
|
||||
<listeners>
|
||||
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
|
||||
</listeners>
|
||||
</phpunit>
|
||||
164
vendor/khill/lavacharts/src/Builders/ChartBuilder.php
vendored
Normal file
164
vendor/khill/lavacharts/src/Builders/ChartBuilder.php
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Builders;
|
||||
|
||||
use Khill\Lavacharts\Charts\ChartFactory;
|
||||
use Khill\Lavacharts\DataTables\DataTable;
|
||||
use Khill\Lavacharts\Exceptions\InvalidChartType;
|
||||
|
||||
/**
|
||||
* Class ChartBuilder
|
||||
*
|
||||
* This class is used to build charts by setting the properties, instead of trying to cover
|
||||
* everything in the constructor.
|
||||
*
|
||||
* @package Khill\Lavacharts\Builders
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ChartBuilder extends GenericBuilder
|
||||
{
|
||||
/**
|
||||
* Type of chart to create.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = null;
|
||||
|
||||
/**
|
||||
* Datatable for the chart.
|
||||
*
|
||||
* @var \Khill\Lavacharts\DataTables\DataTable
|
||||
*/
|
||||
protected $datatable = null;
|
||||
|
||||
/**
|
||||
* Options for the chart.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* The chart's png output override.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $pngOutput = false;
|
||||
|
||||
/**
|
||||
* The chart's material output override.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $materialOutput = false;
|
||||
|
||||
/**
|
||||
* Set the type of chart to create.
|
||||
*
|
||||
* @param string $type Type of chart.
|
||||
* @return self
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidChartType description
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
if (ChartFactory::isValidChart($type) === false) {
|
||||
throw new InvalidChartType($type);
|
||||
}
|
||||
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the DataTable for the chart.
|
||||
*
|
||||
* @param \Khill\Lavacharts\DataTables\DataTable $datatable
|
||||
* @return self
|
||||
*/
|
||||
public function setDatatable(DataTable $datatable = null)
|
||||
{
|
||||
$this->datatable = $datatable;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the options for the chart.
|
||||
*
|
||||
* @param array $options
|
||||
* @return self
|
||||
*/
|
||||
public function setOptions($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the charts output override.
|
||||
*
|
||||
* @param bool $png
|
||||
* @return self
|
||||
*/
|
||||
public function setPngOutput($png)
|
||||
{
|
||||
$this->pngOutput = (is_bool($png) ? $png : false);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the charts output override.
|
||||
*
|
||||
* @param bool $material
|
||||
* @return self
|
||||
*/
|
||||
public function setMaterialOutput($material)
|
||||
{
|
||||
$this->materialOutput = (is_bool($material) ? $material : false);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the chart from the assigned values.
|
||||
*
|
||||
* @return \Khill\Lavacharts\Charts\Chart
|
||||
*/
|
||||
public function getChart()
|
||||
{
|
||||
$chart = '\\Khill\\Lavacharts\\Charts\\' . $this->type;
|
||||
|
||||
/** @var \Khill\Lavacharts\Charts\Chart $newChart */
|
||||
$newChart = new $chart(
|
||||
$this->label,
|
||||
$this->datatable,
|
||||
$this->options
|
||||
);
|
||||
|
||||
if (array_key_exists('elementId', $this->options)) {
|
||||
$newChart->setElementId($this->options['elementId']);
|
||||
}
|
||||
|
||||
if (isset($this->elementId)) {
|
||||
$newChart->setElementId($this->elementId);
|
||||
}
|
||||
|
||||
if (method_exists($newChart, 'setPngOutput')) {
|
||||
$newChart->setPngOutput($this->pngOutput);
|
||||
}
|
||||
|
||||
if (method_exists($newChart, 'setMaterialOutput')) {
|
||||
$newChart->setMaterialOutput($this->materialOutput);
|
||||
}
|
||||
|
||||
return $newChart;
|
||||
}
|
||||
}
|
||||
79
vendor/khill/lavacharts/src/Builders/DashboardBuilder.php
vendored
Normal file
79
vendor/khill/lavacharts/src/Builders/DashboardBuilder.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Builders;
|
||||
|
||||
use \Khill\Lavacharts\Dashboards\Dashboard;
|
||||
use \Khill\Lavacharts\DataTables\DataTable;
|
||||
|
||||
/**
|
||||
* Class DashboardBuilder
|
||||
*
|
||||
* This class is used to build dashboards by setting the properties, instead of trying to cover
|
||||
* everything in the constructor.
|
||||
*
|
||||
* @package Khill\Lavacharts\Builders
|
||||
* @since 3.0.3
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class DashboardBuilder extends GenericBuilder
|
||||
{
|
||||
/**
|
||||
* Datatable for the chart.
|
||||
*
|
||||
* @var \Khill\Lavacharts\DataTables\DataTable
|
||||
*/
|
||||
protected $datatable = null;
|
||||
|
||||
/**
|
||||
* Bindings to use for the dashboard.
|
||||
*
|
||||
* @var \Khill\Lavacharts\Dashboards\Bindings\Binding[]
|
||||
*/
|
||||
protected $bindings = [];
|
||||
|
||||
/**
|
||||
* Set the bindings for the Dashboard.
|
||||
*
|
||||
* @param \Khill\Lavacharts\Dashboards\Bindings\Binding[] $bindings Array of bindings
|
||||
* @return $this
|
||||
*/
|
||||
public function setBindings(array $bindings)
|
||||
{
|
||||
$this->bindings = $bindings;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the DataTable for the dashboard
|
||||
*
|
||||
* @param \Khill\Lavacharts\DataTables\DataTable $datatable
|
||||
* @return $this
|
||||
*/
|
||||
public function setDataTable(DataTable $datatable)
|
||||
{
|
||||
$this->datatable = $datatable;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the built Dashboard.
|
||||
*
|
||||
* @return \Khill\Lavacharts\Dashboards\Dashboard
|
||||
*/
|
||||
public function getDashboard()
|
||||
{
|
||||
$dash = new Dashboard(
|
||||
$this->label,
|
||||
$this->datatable,
|
||||
$this->elementId
|
||||
);
|
||||
|
||||
return $dash->setBindings($this->bindings);
|
||||
}
|
||||
}
|
||||
64
vendor/khill/lavacharts/src/Builders/GenericBuilder.php
vendored
Normal file
64
vendor/khill/lavacharts/src/Builders/GenericBuilder.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Builders;
|
||||
|
||||
use Khill\Lavacharts\Values\Label;
|
||||
use Khill\Lavacharts\Values\ElementId;
|
||||
|
||||
/**
|
||||
* Class GenericBuilder
|
||||
*
|
||||
* This class will provide some common methods to the other builders.
|
||||
*
|
||||
* @package Khill\Lavacharts\Builders
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class GenericBuilder
|
||||
{
|
||||
/**
|
||||
* The chart's unique label.
|
||||
*
|
||||
* @var \Khill\Lavacharts\Values\Label
|
||||
*/
|
||||
protected $label = null;
|
||||
|
||||
/**
|
||||
* The chart's unique elementId.
|
||||
*
|
||||
* @var \Khill\Lavacharts\Values\ElementId
|
||||
*/
|
||||
protected $elementId = null;
|
||||
|
||||
/**
|
||||
* Creates and sets the label for the chart.
|
||||
*
|
||||
* @param string|\Khill\Lavacharts\Values\Label $label
|
||||
* @return self
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidLabel
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = new Label($label);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and sets the elementId for the chart.
|
||||
*
|
||||
* @param string|\Khill\Lavacharts\Values\ElementId $elementId
|
||||
* @return self
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidElementId
|
||||
*/
|
||||
public function setElementId($elementId)
|
||||
{
|
||||
$this->elementId = new ElementId($elementId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
vendor/khill/lavacharts/src/Charts/AnnotationChart.php
vendored
Normal file
43
vendor/khill/lavacharts/src/Charts/AnnotationChart.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* AnnotationChart Class
|
||||
*
|
||||
* Annotation charts are interactive time series line charts that support annotations.
|
||||
* Unlike the annotated timeline, which uses Flash, annotation charts are SVG/VML and
|
||||
* should be preferred whenever possible.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.0.5
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class AnnotationChart extends Chart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'AnnotationChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'annotationchart';
|
||||
}
|
||||
46
vendor/khill/lavacharts/src/Charts/AreaChart.php
vendored
Executable file
46
vendor/khill/lavacharts/src/Charts/AreaChart.php
vendored
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* AreaChart Class
|
||||
*
|
||||
* An area chart that is rendered within the browser using SVG or VML. Displays
|
||||
* tips when hovering over points.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 1.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class AreaChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'AreaChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
}
|
||||
78
vendor/khill/lavacharts/src/Charts/BarChart.php
vendored
Executable file
78
vendor/khill/lavacharts/src/Charts/BarChart.php
vendored
Executable file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
use \Khill\Lavacharts\Support\Traits\MaterialRenderableTrait as MaterialRenderable;
|
||||
|
||||
/**
|
||||
* BarChart Class
|
||||
*
|
||||
* A vertical bar chart that is rendered within the browser using SVG or VML.
|
||||
* Displays tips when hovering over bars. For a horizontal version of this
|
||||
* chart, see the Bar Chart.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 2.3.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class BarChart extends Chart
|
||||
{
|
||||
use PngRenderable, MaterialRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'BarChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
|
||||
/**
|
||||
* Returns the chart visualization class.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function getJsPackage()
|
||||
{
|
||||
if ($this->material) {
|
||||
return 'bar';
|
||||
} else {
|
||||
return static::VISUALIZATION_PACKAGE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart visualization package.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
if ($this->material) {
|
||||
return 'google.charts.Bar';
|
||||
} else {
|
||||
return 'google.visualization.' . static::TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
47
vendor/khill/lavacharts/src/Charts/BubbleChart.php
vendored
Normal file
47
vendor/khill/lavacharts/src/Charts/BubbleChart.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* BubbleChart Class
|
||||
*
|
||||
* A bubble chart is used to visualize a data set with two to four dimensions.
|
||||
* The first two dimensions are visualized as coordinates, the third as color
|
||||
* and the fourth as size.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class BubbleChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'BubbleChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
}
|
||||
54
vendor/khill/lavacharts/src/Charts/CalendarChart.php
vendored
Normal file
54
vendor/khill/lavacharts/src/Charts/CalendarChart.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* CalendarChart Class
|
||||
*
|
||||
* A calendar chart is a visualization used to show activity over the course of a long span of time,
|
||||
* such as months or years. They're best used when you want to illustrate how some quantity varies
|
||||
* depending on the day of the week, or how it trends over time.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 2.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class CalendarChart extends Chart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'CalendarChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1.1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'calendar';
|
||||
|
||||
/**
|
||||
* Returns the google javascript package name.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.Calendar';
|
||||
}
|
||||
}
|
||||
47
vendor/khill/lavacharts/src/Charts/CandlestickChart.php
vendored
Normal file
47
vendor/khill/lavacharts/src/Charts/CandlestickChart.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* CandlestickChart Class
|
||||
*
|
||||
* A bubble chart is used to visualize a data set with two to four dimensions.
|
||||
* The first two dimensions are visualized as coordinates, the third as color
|
||||
* and the fourth as size.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class CandlestickChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'CandlestickChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
}
|
||||
197
vendor/khill/lavacharts/src/Charts/Chart.php
vendored
Executable file
197
vendor/khill/lavacharts/src/Charts/Chart.php
vendored
Executable file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use Khill\Lavacharts\Support\Customizable;
|
||||
use Khill\Lavacharts\DataTables\DataTable;
|
||||
use Khill\Lavacharts\Values\ElementId;
|
||||
use Khill\Lavacharts\Values\Label;
|
||||
use Khill\Lavacharts\Support\Traits\ElementIdTrait as HasElementId;
|
||||
use Khill\Lavacharts\Support\Traits\DataTableTrait as HasDataTable;
|
||||
use Khill\Lavacharts\Support\Traits\RenderableTrait as IsRenderable;
|
||||
use Khill\Lavacharts\Support\Contracts\JsonableInterface as Jsonable;
|
||||
use Khill\Lavacharts\Support\Contracts\WrappableInterface as Wrappable;
|
||||
use Khill\Lavacharts\Support\Contracts\RenderableInterface as Renderable;
|
||||
use Khill\Lavacharts\Support\Contracts\VisualizationInterface as Visualization;
|
||||
|
||||
/**
|
||||
* Class Chart
|
||||
*
|
||||
* Parent to all charts which has common properties and methods
|
||||
* used between all the different charts.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Chart extends Customizable implements Renderable, Wrappable, Jsonable, Visualization
|
||||
{
|
||||
use HasDataTable, IsRenderable;
|
||||
|
||||
/**
|
||||
* Type of wrappable class
|
||||
*/
|
||||
const WRAP_TYPE = 'chartType';
|
||||
|
||||
/**
|
||||
* Builds a new chart with the given label.
|
||||
*
|
||||
* @param \Khill\Lavacharts\Values\Label $chartLabel Identifying label for the chart.
|
||||
* @param \Khill\Lavacharts\DataTables\DataTable $datatable DataTable used for the chart.
|
||||
* @param array $options Options fot the chart.
|
||||
*/
|
||||
public function __construct(Label $chartLabel, DataTable $datatable = null, array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
|
||||
$this->label = $chartLabel;
|
||||
$this->datatable = $datatable;
|
||||
|
||||
$this->setExtendedAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set extended chart attributes from the assigned options, if present.
|
||||
*
|
||||
* @since 3.1.9
|
||||
*/
|
||||
protected function setExtendedAttributes()
|
||||
{
|
||||
if (array_key_exists('elementId', $this->options)) {
|
||||
$this->setElementId($this->options['elementId']);
|
||||
|
||||
unset($this->options['elementId']);
|
||||
}
|
||||
|
||||
if (method_exists($this, 'setPngOutput') &&
|
||||
array_key_exists('png', $this->options))
|
||||
{
|
||||
$this->setPngOutput($this->options['png']);
|
||||
|
||||
unset($this->options['png']);
|
||||
}
|
||||
|
||||
if (method_exists($this, 'setMaterialOutput') &&
|
||||
array_key_exists('material', $this->options))
|
||||
{
|
||||
$this->setMaterialOutput($this->options['material']);
|
||||
|
||||
unset($this->options['material']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the chart type.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return static::TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Filter wrap type.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getWrapType()
|
||||
{
|
||||
return static::WRAP_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart version.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return static::VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart visualization class.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getJsPackage()
|
||||
{
|
||||
return static::VISUALIZATION_PACKAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart visualization package.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.' . static::TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a JSON representation of the chart, which would be the customizations.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toJson()
|
||||
{
|
||||
return json_encode($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the events if any have been assigned to the chart.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return array
|
||||
*/
|
||||
public function getEvents()
|
||||
{
|
||||
return $this['events'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if any events have been assigned to the chart.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEvents()
|
||||
{
|
||||
return isset($this['events']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets any configuration option, with no checks for type / validity
|
||||
*
|
||||
*
|
||||
* This is method was added in 2.5 as a bandaid to remove the handcuffs from
|
||||
* users who want to add options that Google has added, that I have not.
|
||||
* I didn't intend to restrict the user to only select options, as the
|
||||
* goal was to type isNonEmpty and validate. This method can be used to set
|
||||
* any option, just pass in arrays with key value pairs for any setting.
|
||||
*
|
||||
* If the setting is an object, per the google docs, then use multi-dimensional
|
||||
* arrays and they will be converted upon rendering.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param array $options Array of customization options for the chart
|
||||
* @return \Khill\Lavacharts\Charts\Chart
|
||||
*/
|
||||
public function customize(array $options)
|
||||
{
|
||||
$this->setOptions($options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
154
vendor/khill/lavacharts/src/Charts/ChartFactory.php
vendored
Normal file
154
vendor/khill/lavacharts/src/Charts/ChartFactory.php
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Builders\ChartBuilder;
|
||||
use Khill\Lavacharts\DataTables\DataTable;
|
||||
use \Khill\Lavacharts\Exceptions\InvalidDataTable;
|
||||
|
||||
/**
|
||||
* ChartFactory Class
|
||||
*
|
||||
* Used for creating new charts and removing the need for the main Lavacharts
|
||||
* class to handle the creation.
|
||||
*
|
||||
*
|
||||
* @category Class
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ChartFactory
|
||||
{
|
||||
/**
|
||||
* Instance of the ChartBuilder for, well, building charts.
|
||||
*
|
||||
* @var \Khill\Lavacharts\Builders\ChartBuilder
|
||||
*/
|
||||
private $chartBuilder;
|
||||
|
||||
/**
|
||||
* Types of charts that can be created.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $CHART_TYPES = [
|
||||
'AreaChart',
|
||||
'AnnotationChart',
|
||||
'BarChart',
|
||||
'BubbleChart',
|
||||
'CalendarChart',
|
||||
'CandlestickChart',
|
||||
'ColumnChart',
|
||||
'ComboChart',
|
||||
'DonutChart',
|
||||
'GanttChart',
|
||||
'GaugeChart',
|
||||
'GeoChart',
|
||||
'HistogramChart',
|
||||
'LineChart',
|
||||
'PieChart',
|
||||
'SankeyChart',
|
||||
'ScatterChart',
|
||||
'SteppedAreaChart',
|
||||
'TableChart',
|
||||
'TimelineChart',
|
||||
'TreeMapChart',
|
||||
'WordTreeChart',
|
||||
];
|
||||
|
||||
/**
|
||||
* ChartFactory constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->chartBuilder = new ChartBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChartFactory constructor.
|
||||
*/
|
||||
public static function build($type, $args)
|
||||
{
|
||||
return (new self)->create($type, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new chart from type with DataTable and config passed
|
||||
* from the main Lavacharts class.
|
||||
*
|
||||
* @param string $type Type of chart to create.
|
||||
* @param array $args Passed arguments from __call in Lavacharts.
|
||||
* @return \Khill\Lavacharts\Charts\Chart
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidChartType
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidDataTable
|
||||
*/
|
||||
public function create($type, $args)
|
||||
{
|
||||
if ($args[1] !== null && $args[1] instanceof DataTable === false) {
|
||||
throw new InvalidDataTable;
|
||||
}
|
||||
|
||||
$this->chartBuilder->setType($type)
|
||||
->setLabel($args[0])
|
||||
->setDatatable($args[1]);
|
||||
|
||||
if (isset($args[2])) {
|
||||
if (is_string($args[2])) {
|
||||
$this->chartBuilder->setElementId($args[2]);
|
||||
}
|
||||
|
||||
if (is_array($args[2])) {
|
||||
if (array_key_exists('elementId', $args[2])) {
|
||||
$this->chartBuilder->setElementId($args[2]['elementId']);
|
||||
unset($args[2]['elementId']);
|
||||
}
|
||||
|
||||
if (array_key_exists('png', $args[2])) {
|
||||
$this->chartBuilder->setPngOutput($args[2]['png']);
|
||||
unset($args[2]['png']);
|
||||
}
|
||||
|
||||
if (array_key_exists('material', $args[2])) {
|
||||
$this->chartBuilder->setMaterialOutput($args[2]['material']);
|
||||
unset($args[2]['material']);
|
||||
}
|
||||
|
||||
$this->chartBuilder->setOptions($args[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($args[3])) {
|
||||
$this->chartBuilder->setElementId($args[3]);
|
||||
}
|
||||
|
||||
return $this->chartBuilder->getChart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of supported chart types.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return array
|
||||
*/
|
||||
public static function getChartTypes()
|
||||
{
|
||||
return static::$CHART_TYPES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of supported chart types.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $type Type of chart to check.
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValidChart($type)
|
||||
{
|
||||
return in_array($type, self::$CHART_TYPES, true);
|
||||
}
|
||||
}
|
||||
47
vendor/khill/lavacharts/src/Charts/ColumnChart.php
vendored
Executable file
47
vendor/khill/lavacharts/src/Charts/ColumnChart.php
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* ColumnChart Class
|
||||
*
|
||||
* A vertical bar chart that is rendered within the browser using SVG or VML.
|
||||
* Displays tips when hovering over bars. For a horizontal version of this
|
||||
* chart, see the Bar Chart.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 1.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ColumnChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'ColumnChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
}
|
||||
49
vendor/khill/lavacharts/src/Charts/ComboChart.php
vendored
Executable file
49
vendor/khill/lavacharts/src/Charts/ComboChart.php
vendored
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* ComboChart Class
|
||||
*
|
||||
* A chart that lets you render each series as a different marker type from the following list:
|
||||
* line, area, bars, candlesticks and stepped area.
|
||||
*
|
||||
* To assign a default marker type for series, specify the seriesType property.
|
||||
* Use the series property to specify properties of each series individually.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 2.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ComboChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'ComboChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
}
|
||||
38
vendor/khill/lavacharts/src/Charts/DonutChart.php
vendored
Normal file
38
vendor/khill/lavacharts/src/Charts/DonutChart.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* DonutChart Class
|
||||
*
|
||||
* A pie chart, with a hole in the center, that is rendered within the browser using SVG or VML.
|
||||
* Displays tooltips when hovering over slices.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.1.5
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class DonutChart extends PieChart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'DonutChart';
|
||||
|
||||
/**
|
||||
* Returns the chart visualization package.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.PieChart';
|
||||
}
|
||||
}
|
||||
57
vendor/khill/lavacharts/src/Charts/GanttChart.php
vendored
Normal file
57
vendor/khill/lavacharts/src/Charts/GanttChart.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* GanttChart Class
|
||||
*
|
||||
* A Gantt chart is a type of chart that illustrates the breakdown of a
|
||||
* project into its component tasks. Google Gantt charts illustrate the
|
||||
* start, end, and duration of tasks within a project, as well as any
|
||||
* dependencies a task may have. Google Gantt charts are rendered in
|
||||
* the browser using SVG. Like all Google charts, Gantt charts display
|
||||
* tooltips when the user hovers over the data.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.0.5
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class GanttChart extends Chart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'GanttChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'gantt';
|
||||
|
||||
/**
|
||||
* Returns the google javascript package name.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.Gantt';
|
||||
}
|
||||
}
|
||||
52
vendor/khill/lavacharts/src/Charts/GaugeChart.php
vendored
Executable file
52
vendor/khill/lavacharts/src/Charts/GaugeChart.php
vendored
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* GaugeChart Class
|
||||
*
|
||||
* A gauge with a dial, rendered within the browser using SVG or VML.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 2.2.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class GaugeChart extends Chart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'GaugeChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'gauge';
|
||||
|
||||
/**
|
||||
* Returns the google javascript package name.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.Gauge';
|
||||
}
|
||||
}
|
||||
49
vendor/khill/lavacharts/src/Charts/GeoChart.php
vendored
Normal file
49
vendor/khill/lavacharts/src/Charts/GeoChart.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* GeoChart Class
|
||||
*
|
||||
* A Geochart is a map of a country, a continent, or a region with two modes:
|
||||
* - The region mode colorizes whole regions, such as countries, provinces,
|
||||
* or states.
|
||||
* - The marker mode marks designated regions using bubbles that are scaled
|
||||
* according to a value that you specify.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 1.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class GeoChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'GeoChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'geochart';
|
||||
}
|
||||
64
vendor/khill/lavacharts/src/Charts/HistogramChart.php
vendored
Normal file
64
vendor/khill/lavacharts/src/Charts/HistogramChart.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* HistogramChart Class
|
||||
*
|
||||
* A histogram is a chart that groups numeric data into bins,
|
||||
* displaying the bins as segmented columns. They're used to
|
||||
* depict the distribution of a dataset: how often values fall
|
||||
* into ranges.
|
||||
*
|
||||
* Google Charts automatically chooses the number of bins for you.
|
||||
* All bins are equal width and have a height proportional to the
|
||||
* number of data points in the bin. In other respects, histograms
|
||||
* are similar to column charts.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class HistogramChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'HistogramChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
|
||||
/**
|
||||
* Returns the google javascript package name.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.Histogram';
|
||||
}
|
||||
}
|
||||
77
vendor/khill/lavacharts/src/Charts/LineChart.php
vendored
Executable file
77
vendor/khill/lavacharts/src/Charts/LineChart.php
vendored
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
use \Khill\Lavacharts\Support\Traits\MaterialRenderableTrait as MaterialRenderable;
|
||||
|
||||
/**
|
||||
* LineChart Class
|
||||
*
|
||||
* A line chart that is rendered within the browser using SVG or VML. Displays
|
||||
* tips when hovering over points.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 1.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class LineChart extends Chart
|
||||
{
|
||||
use PngRenderable, MaterialRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'LineChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
|
||||
/**
|
||||
* Returns the chart visualization class.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function getJsPackage()
|
||||
{
|
||||
if ($this->material) {
|
||||
return 'line';
|
||||
} else {
|
||||
return static::VISUALIZATION_PACKAGE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart visualization package.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
if ($this->material) {
|
||||
return 'google.charts.Line';
|
||||
} else {
|
||||
return 'google.visualization.' . static::TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
47
vendor/khill/lavacharts/src/Charts/OrgChart.php
vendored
Normal file
47
vendor/khill/lavacharts/src/Charts/OrgChart.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use Khill\Lavacharts\Support\Traits\PngOutputTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* OrgChart Class
|
||||
*
|
||||
* Org charts are diagrams of a hierarchy of nodes, commonly used to
|
||||
* portray superior/subordinate relationships in an organization.
|
||||
* A family tree is a type of org chart.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.0.5
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class OrgChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'OrgChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'orgchart';
|
||||
}
|
||||
46
vendor/khill/lavacharts/src/Charts/PieChart.php
vendored
Normal file
46
vendor/khill/lavacharts/src/Charts/PieChart.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* PieChart Class
|
||||
*
|
||||
* A pie chart that is rendered within the browser using SVG or VML. Displays
|
||||
* tooltips when hovering over slices.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 1.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class PieChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'PieChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
}
|
||||
59
vendor/khill/lavacharts/src/Charts/SankeyChart.php
vendored
Normal file
59
vendor/khill/lavacharts/src/Charts/SankeyChart.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* SankeyChart Class
|
||||
*
|
||||
* A sankey diagram is a visualization used to depict a flow from one set
|
||||
* of values to another. The things being connected are called nodes and
|
||||
* the connections are called links.
|
||||
*
|
||||
* Sankeys are best used when you want to show a many-to-many mapping
|
||||
* between two domains (e.g., universities and majors) or multiple paths
|
||||
* through a set of stages (for instance, Google Analytics uses sankeys
|
||||
* to show how traffic flows from pages to other pages on your web site).
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.0.5
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class SankeyChart extends Chart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'SankeyChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'sankey';
|
||||
|
||||
/**
|
||||
* Returns the google javascript package name.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.Sankey';
|
||||
}
|
||||
}
|
||||
80
vendor/khill/lavacharts/src/Charts/ScatterChart.php
vendored
Normal file
80
vendor/khill/lavacharts/src/Charts/ScatterChart.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
use \Khill\Lavacharts\Support\Traits\MaterialRenderableTrait as MaterialRenderable;
|
||||
|
||||
/**
|
||||
* ScatterChart Class
|
||||
*
|
||||
* A chart that lets you render each series as a different marker type from the following list:
|
||||
* line, area, bars, candlesticks and stepped area.
|
||||
*
|
||||
* To assign a default marker type for series, specify the seriesType property.
|
||||
* Use the series property to specify properties of each series individually.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ScatterChart extends Chart
|
||||
{
|
||||
use PngRenderable, MaterialRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'ScatterChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
|
||||
/**
|
||||
* Returns the chart visualization class.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function getJsPackage()
|
||||
{
|
||||
if ($this->material) {
|
||||
return 'scatter';
|
||||
} else {
|
||||
return static::VISUALIZATION_PACKAGE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart visualization package.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
if ($this->material) {
|
||||
return 'google.charts.Scatter';
|
||||
} else {
|
||||
return 'google.visualization.' . static::TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
vendor/khill/lavacharts/src/Charts/SteppedAreaChart.php
vendored
Normal file
45
vendor/khill/lavacharts/src/Charts/SteppedAreaChart.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
use \Khill\Lavacharts\Support\Traits\PngRenderableTrait as PngRenderable;
|
||||
|
||||
/**
|
||||
* SteppedAreaChart Class
|
||||
*
|
||||
* A stacking, stair like version of the AreaChart.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class SteppedAreaChart extends Chart
|
||||
{
|
||||
use PngRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'SteppedAreaChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'corechart';
|
||||
}
|
||||
54
vendor/khill/lavacharts/src/Charts/TableChart.php
vendored
Normal file
54
vendor/khill/lavacharts/src/Charts/TableChart.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* Table Chart Class
|
||||
*
|
||||
* A table chart is rendered within the browser. Displays a data from a DataTable in an easily sortable form.
|
||||
* Can be searched by rendering as a wrapper and binding to a control within a dashboard.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.0.0
|
||||
* @author Peter Draznik <peter.draznik@38thStreetStudios.com>
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, 38th Street Studios
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class TableChart extends Chart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'TableChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'table';
|
||||
|
||||
/**
|
||||
* Returns the google javascript package name.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.Table';
|
||||
}
|
||||
}
|
||||
56
vendor/khill/lavacharts/src/Charts/TimelineChart.php
vendored
Normal file
56
vendor/khill/lavacharts/src/Charts/TimelineChart.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* TimelineChart Class
|
||||
*
|
||||
*
|
||||
* A timeline is a chart that depicts how a set of resources are used over time.
|
||||
* If you're managing a software project and want to illustrate who is doing what
|
||||
* and when, or if you're organizing a conference and need to schedule meeting
|
||||
* rooms, a timeline is often a reasonable visualization choice.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.0.5
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class TimelineChart extends Chart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'TimelineChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'timeline';
|
||||
|
||||
/**
|
||||
* Returns the google javascript package name.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.Timeline';
|
||||
}
|
||||
}
|
||||
65
vendor/khill/lavacharts/src/Charts/TreeMapChart.php
vendored
Normal file
65
vendor/khill/lavacharts/src/Charts/TreeMapChart.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* TreeMap Chart Class
|
||||
*
|
||||
*
|
||||
* A visual representation of a data tree, where each node can have zero or more
|
||||
* children, and one parent (except for the root, which has no parents). Each
|
||||
* node is displayed as a rectangle, sized and colored according to values that
|
||||
* you assign. Sizes and colors are valued relative to all other nodes in the
|
||||
* graph. You can specify how many levels to display simultaneously, and
|
||||
* optionally to display deeper levels in a hinted fashion. If a node is a leaf
|
||||
* node, you can specify a size and color; if it is not a leaf, it will be
|
||||
* displayed as a bounding box for leaf nodes. The default behavior is to move
|
||||
* down the tree when a user left-clicks a node, and to move back up the tree
|
||||
* when a user right-clicks the graph.
|
||||
*
|
||||
* The total size of the graph is determined by the size of the containing
|
||||
* element that you insert in your page. If you have leaf nodes with names too
|
||||
* long to show, the name will be truncated with an ellipsis (...).
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class TreeMapChart extends Chart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'TreeMapChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'treemap';
|
||||
|
||||
/**
|
||||
* Returns the google javascript package name.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.TreeMap';
|
||||
}
|
||||
}
|
||||
65
vendor/khill/lavacharts/src/Charts/WordTreeChart.php
vendored
Normal file
65
vendor/khill/lavacharts/src/Charts/WordTreeChart.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Charts;
|
||||
|
||||
/**
|
||||
* WordTreeChart Class
|
||||
*
|
||||
*
|
||||
* A visual representation of a data tree, where each node can have zero or more
|
||||
* children, and one parent (except for the root, which has no parents). Each
|
||||
* node is displayed as a rectangle, sized and colored according to values that
|
||||
* you assign. Sizes and colors are valued relative to all other nodes in the
|
||||
* graph. You can specify how many levels to display simultaneously, and
|
||||
* optionally to display deeper levels in a hinted fashion. If a node is a leaf
|
||||
* node, you can specify a size and color; if it is not a leaf, it will be
|
||||
* displayed as a bounding box for leaf nodes. The default behavior is to move
|
||||
* down the tree when a user left-clicks a node, and to move back up the tree
|
||||
* when a user right-clicks the graph.
|
||||
*
|
||||
* The total size of the graph is determined by the size of the containing
|
||||
* element that you insert in your page. If you have leaf nodes with names too
|
||||
* long to show, the name will be truncated with an ellipsis (...).
|
||||
*
|
||||
* @package Khill\Lavacharts\Charts
|
||||
* @since 3.0.5
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class WordTreeChart extends Chart
|
||||
{
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'WordTreeChart';
|
||||
|
||||
/**
|
||||
* Javascript chart version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript chart package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'wordtree';
|
||||
|
||||
/**
|
||||
* Returns the google javascript package name.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.WordTree';
|
||||
}
|
||||
}
|
||||
89
vendor/khill/lavacharts/src/Dashboards/Bindings/Binding.php
vendored
Normal file
89
vendor/khill/lavacharts/src/Dashboards/Bindings/Binding.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Bindings;
|
||||
|
||||
/**
|
||||
* Parent Binding Class
|
||||
*
|
||||
* Binds a ControlWrapper to a ChartWrapper to use in dashboards.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Bindings
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Binding
|
||||
{
|
||||
/**
|
||||
* Array of ControlWrappers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $controlWrappers;
|
||||
|
||||
/**
|
||||
* Array of ChartWrappers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $chartWrappers;
|
||||
|
||||
/**
|
||||
* Assigns the wrappers and creates the new Binding.
|
||||
*
|
||||
* @param array $chartWrappers
|
||||
* @param array $controlWrappers
|
||||
*/
|
||||
public function __construct(array $controlWrappers, array $chartWrappers)
|
||||
{
|
||||
$this->chartWrappers = $chartWrappers;
|
||||
$this->controlWrappers = $controlWrappers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ChartWrappers
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getChartWrappers()
|
||||
{
|
||||
return $this->chartWrappers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the a specific ChartWrap
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param int $index Which chart wrap to retrieve
|
||||
* @return array
|
||||
*/
|
||||
public function getChartWrap($index)
|
||||
{
|
||||
return $this->chartWrappers[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ControlWrappers
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getControlWrappers()
|
||||
{
|
||||
return $this->controlWrappers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the a specific ControlWrap
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param int $index Which control wrap to retrieve
|
||||
* @return array
|
||||
*/
|
||||
public function getControlWrap($index)
|
||||
{
|
||||
return $this->controlWrappers[$index];
|
||||
}
|
||||
}
|
||||
52
vendor/khill/lavacharts/src/Dashboards/Bindings/BindingFactory.php
vendored
Normal file
52
vendor/khill/lavacharts/src/Dashboards/Bindings/BindingFactory.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Bindings;
|
||||
|
||||
use \Khill\Lavacharts\Dashboards\Wrappers\ChartWrapper;
|
||||
use \Khill\Lavacharts\Dashboards\Wrappers\ControlWrapper;
|
||||
use \Khill\Lavacharts\Exceptions\InvalidBindings;
|
||||
|
||||
/**
|
||||
* BindingFactory Class
|
||||
*
|
||||
* Creates new bindings for dashboards.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Bindings
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class BindingFactory
|
||||
{
|
||||
/**
|
||||
* Create a new Binding for the dashboard.
|
||||
*
|
||||
* @param mixed $controlWraps One or array of many ControlWrappers
|
||||
* @param mixed $chartWraps One or array of many ChartWrappers
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidBindings
|
||||
* @return \Khill\Lavacharts\Dashboards\Bindings\Binding
|
||||
*/
|
||||
public function create($controlWraps, $chartWraps)
|
||||
{
|
||||
if ($controlWraps instanceof ControlWrapper && $chartWraps instanceof ChartWrapper) {
|
||||
return new OneToOne($controlWraps, $chartWraps);
|
||||
}
|
||||
|
||||
if ($controlWraps instanceof ControlWrapper && is_array($chartWraps)) {
|
||||
return new OneToMany($controlWraps, $chartWraps);
|
||||
}
|
||||
|
||||
if (is_array($controlWraps) && $chartWraps instanceof ChartWrapper) {
|
||||
return new ManyToOne($controlWraps, $chartWraps);
|
||||
}
|
||||
|
||||
if (is_array($chartWraps) && is_array($controlWraps)) {
|
||||
return new ManyToMany($controlWraps, $chartWraps);
|
||||
}
|
||||
|
||||
throw new InvalidBindings;
|
||||
}
|
||||
}
|
||||
37
vendor/khill/lavacharts/src/Dashboards/Bindings/ManyToMany.php
vendored
Normal file
37
vendor/khill/lavacharts/src/Dashboards/Bindings/ManyToMany.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Bindings;
|
||||
|
||||
/**
|
||||
* ManyToMany Binding Class
|
||||
*
|
||||
* Binds multiple ControlWrappers to a multiple ChartWrapper for use in dashboards.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Bindings
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ManyToMany extends Binding
|
||||
{
|
||||
/**
|
||||
* Type of binding.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'ManyToMany';
|
||||
|
||||
/**
|
||||
* Creates the new Binding.
|
||||
*
|
||||
* @param array $chartWrappers
|
||||
* @param array $controlWrappers
|
||||
*/
|
||||
public function __construct(array $controlWrappers, array $chartWrappers)
|
||||
{
|
||||
parent::__construct($controlWrappers, $chartWrappers);
|
||||
}
|
||||
}
|
||||
39
vendor/khill/lavacharts/src/Dashboards/Bindings/ManyToOne.php
vendored
Normal file
39
vendor/khill/lavacharts/src/Dashboards/Bindings/ManyToOne.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Bindings;
|
||||
|
||||
use Khill\Lavacharts\Dashboards\Wrappers\ChartWrapper;
|
||||
|
||||
/**
|
||||
* ManyToOne Binding Class
|
||||
*
|
||||
* Binds multiple ControlWrappers to a single ChartWrapper for use in dashboards.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Bindings
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ManyToOne extends Binding
|
||||
{
|
||||
/**
|
||||
* Type of binding.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'ManyToOne';
|
||||
|
||||
/**
|
||||
* Creates the new Binding.
|
||||
*
|
||||
* @param array $controlWrappers
|
||||
* @param \Khill\Lavacharts\Dashboards\Wrappers\ChartWrapper $chartWrapper
|
||||
*/
|
||||
public function __construct(array $controlWrappers, ChartWrapper $chartWrapper)
|
||||
{
|
||||
parent::__construct($controlWrappers, [$chartWrapper]);
|
||||
}
|
||||
}
|
||||
39
vendor/khill/lavacharts/src/Dashboards/Bindings/OneToMany.php
vendored
Normal file
39
vendor/khill/lavacharts/src/Dashboards/Bindings/OneToMany.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Bindings;
|
||||
|
||||
use Khill\Lavacharts\Dashboards\Wrappers\ControlWrapper;
|
||||
|
||||
/**
|
||||
* OneToMany Binding Class
|
||||
*
|
||||
* Binds a single ControlWrapper to multiple ChartWrappers for use in dashboards.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Bindings
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class OneToMany extends Binding
|
||||
{
|
||||
/**
|
||||
* Type of binding.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'OneToMany';
|
||||
|
||||
/**
|
||||
* Creates the new Binding.
|
||||
*
|
||||
* @param \Khill\Lavacharts\Dashboards\Wrappers\ControlWrapper $controlWrapper
|
||||
* @param array $chartWrappers
|
||||
*/
|
||||
public function __construct(ControlWrapper $controlWrapper, array $chartWrappers)
|
||||
{
|
||||
parent::__construct([$controlWrapper], $chartWrappers);
|
||||
}
|
||||
}
|
||||
40
vendor/khill/lavacharts/src/Dashboards/Bindings/OneToOne.php
vendored
Normal file
40
vendor/khill/lavacharts/src/Dashboards/Bindings/OneToOne.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Bindings;
|
||||
|
||||
use Khill\Lavacharts\Dashboards\Wrappers\ChartWrapper;
|
||||
use Khill\Lavacharts\Dashboards\Wrappers\ControlWrapper;
|
||||
|
||||
/**
|
||||
* Binding Class
|
||||
*
|
||||
* Binds a single ControlWrapper to a single ChartWrapper for use in dashboards.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Bindings
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class OneToOne extends Binding
|
||||
{
|
||||
/**
|
||||
* Type of binding.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'OneToOne';
|
||||
|
||||
/**
|
||||
* Creates the new Binding.
|
||||
*
|
||||
* @param \Khill\Lavacharts\Dashboards\Wrappers\ControlWrapper $controlWrapper
|
||||
* @param \Khill\Lavacharts\Dashboards\Wrappers\ChartWrapper $chartWrapper
|
||||
*/
|
||||
public function __construct(ControlWrapper $controlWrapper, ChartWrapper $chartWrapper)
|
||||
{
|
||||
parent::__construct([$controlWrapper], [$chartWrapper]);
|
||||
}
|
||||
}
|
||||
193
vendor/khill/lavacharts/src/Dashboards/Dashboard.php
vendored
Normal file
193
vendor/khill/lavacharts/src/Dashboards/Dashboard.php
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards;
|
||||
|
||||
use \Khill\Lavacharts\Values\Label;
|
||||
use \Khill\Lavacharts\Values\ElementId;
|
||||
use \Khill\Lavacharts\DataTables\DataTable;
|
||||
use \Khill\Lavacharts\Dashboards\Bindings\BindingFactory;
|
||||
use \Khill\Lavacharts\Support\Traits\DataTableTrait as HasDataTable;
|
||||
use \Khill\Lavacharts\Support\Traits\RenderableTrait as IsRenderable;
|
||||
use \Khill\Lavacharts\Support\Contracts\DataTableInterface as DataTables;
|
||||
use \Khill\Lavacharts\Support\Contracts\RenderableInterface as Renderable;
|
||||
use \Khill\Lavacharts\Support\Contracts\VisualizationInterface as Visualization;
|
||||
|
||||
/**
|
||||
* Class Dashboard
|
||||
*
|
||||
* This class is for creating interactive charts that have controls and filters.
|
||||
*
|
||||
* The dashboard takes filters, wrapped as controls, and charts to create a dynamic
|
||||
* display of data.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Dashboard implements DataTables, Renderable, Visualization
|
||||
{
|
||||
use HasDataTable, IsRenderable;
|
||||
|
||||
/**
|
||||
* Javascript chart type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'Dashboard';
|
||||
|
||||
/**
|
||||
* Google's dashboard version
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1';
|
||||
|
||||
/**
|
||||
* Javascript package.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VISUALIZATION_PACKAGE = 'controls';
|
||||
|
||||
/**
|
||||
* Binding Factory for creating new bindings
|
||||
*
|
||||
* @var \Khill\Lavacharts\Dashboards\Bindings\BindingFactory
|
||||
*/
|
||||
private $bindingFactory;
|
||||
|
||||
/**
|
||||
* Array of Binding objects, mapping controls to charts.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $bindings = [];
|
||||
|
||||
/**
|
||||
* Builds a new Dashboard
|
||||
*
|
||||
* If passed an array of bindings, they will be applied upon creation.
|
||||
*
|
||||
* @param \Khill\Lavacharts\Values\Label $label Label for the Dashboard
|
||||
* @param \Khill\Lavacharts\DataTables\DataTable $datatable
|
||||
* @param \Khill\Lavacharts\Values\ElementId $elementId Element Id for the Dashboard
|
||||
*/
|
||||
public function __construct(
|
||||
Label $label,
|
||||
DataTable $datatable,
|
||||
ElementId $elementId = null
|
||||
)
|
||||
{
|
||||
$this->bindingFactory = new BindingFactory;
|
||||
|
||||
$this->label = $label;
|
||||
$this->datatable = $datatable;
|
||||
$this->elementId = $elementId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chart type.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return static::TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the javascript visualization package name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJsPackage()
|
||||
{
|
||||
return static::VISUALIZATION_PACKAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the javascript visualization class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.Dashboard';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the dashboard's bound charts from the wrappers.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBoundCharts()
|
||||
{
|
||||
$charts = [];
|
||||
|
||||
foreach ($this->bindings as $binding) {
|
||||
foreach ($binding->getChartWrappers() as $chartWrapper) {
|
||||
$chart = $chartWrapper->unwrap();
|
||||
|
||||
$charts[] = $chart;
|
||||
}
|
||||
}
|
||||
|
||||
return $charts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds ControlWrappers to ChartWrappers in the dashboard.
|
||||
*
|
||||
* - A OneToOne binding is created if single wrappers are passed.
|
||||
* - If a single ControlWrapper is passed with an array of ChartWrappers,
|
||||
* a OneToMany binding is created.
|
||||
* - If an array of ControlWrappers is passed with one ChartWrapper, then
|
||||
* a ManyToOne binding is created.
|
||||
* - If an array of ControlWrappers is passed with and array of ChartWrappers, then
|
||||
* a ManyToMany binding is created.
|
||||
*
|
||||
* @param \Khill\Lavacharts\Dashboards\Wrappers\ControlWrapper|array $controlWraps
|
||||
* @param \Khill\Lavacharts\Dashboards\Wrappers\ChartWrapper|array $chartWraps
|
||||
* @return \Khill\Lavacharts\Dashboards\Dashboard
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidBindings
|
||||
*/
|
||||
public function bind($controlWraps, $chartWraps)
|
||||
{
|
||||
$this->bindings[] = $this->bindingFactory->create($controlWraps, $chartWraps);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch add an array of bindings.
|
||||
*
|
||||
* This method can set all bindings at once instead of chaining multiple bind methods.
|
||||
*
|
||||
* @param array $bindings
|
||||
* @return \Khill\Lavacharts\Dashboards\Dashboard
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidBindings
|
||||
*/
|
||||
public function setBindings(array $bindings)
|
||||
{
|
||||
$this->bindings = array_map(function ($bindingPair) {
|
||||
return $this->bindingFactory->create($bindingPair[0], $bindingPair[1]);
|
||||
}, $bindings);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the dashboard's bindings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBindings()
|
||||
{
|
||||
return $this->bindings;
|
||||
}
|
||||
}
|
||||
77
vendor/khill/lavacharts/src/Dashboards/DashboardFactory.php
vendored
Normal file
77
vendor/khill/lavacharts/src/Dashboards/DashboardFactory.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards;
|
||||
|
||||
use \Khill\Lavacharts\Builders\DashboardBuilder;
|
||||
|
||||
/**
|
||||
* DashboardFactory Class
|
||||
*
|
||||
* Used for creating new dashboards and removing the need for the main Lavacharts
|
||||
* class to handle the creation.
|
||||
*
|
||||
*
|
||||
* @category Class
|
||||
* @package Khill\Lavacharts\Dashboards
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class DashboardFactory
|
||||
{
|
||||
/**
|
||||
* Instance of the DashboardBuilder
|
||||
*
|
||||
* @var \Khill\Lavacharts\Builders\DashboardBuilder
|
||||
*/
|
||||
private $dashBuilder;
|
||||
|
||||
/**
|
||||
* DashboardFactory constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->dashBuilder = new DashboardBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and stores Dashboards
|
||||
*
|
||||
* If the Dashboard is found in the Volcano, then it is returned.
|
||||
* Otherwise, a new dashboard is created and stored in the Volcano.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $args Array of arguments from Lavacharts
|
||||
* @return \Khill\Lavacharts\Dashboards\Dashboard
|
||||
*/
|
||||
public function create($args)
|
||||
{
|
||||
$this->dashBuilder->setLabel($args[0]);
|
||||
$this->dashBuilder->setDataTable($args[1]);
|
||||
|
||||
if (isset($args[2])) {
|
||||
if (is_string($args[2])) {
|
||||
$this->dashBuilder->setElementId($args[2]);
|
||||
}
|
||||
|
||||
if (is_array($args[2])) {
|
||||
$this->dashBuilder->setBindings($args[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($args[3])) {
|
||||
if (is_string($args[3])) {
|
||||
$this->dashBuilder->setElementId($args[3]);
|
||||
}
|
||||
|
||||
if (is_array($args[3])) {
|
||||
$this->dashBuilder->setBindings($args[3]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->dashBuilder->getDashboard();
|
||||
}
|
||||
}
|
||||
27
vendor/khill/lavacharts/src/Dashboards/Filters/CategoryFilter.php
vendored
Normal file
27
vendor/khill/lavacharts/src/Dashboards/Filters/CategoryFilter.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Filters;
|
||||
|
||||
/**
|
||||
* Category Filter Class
|
||||
*
|
||||
* A picker to choose one or more between a set of defined values.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Filters
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @see https://developers.google.com/chart/interactive/docs/gallery/controls#googlevisualizationcategoryfilter
|
||||
*/
|
||||
class CategoryFilter extends Filter
|
||||
{
|
||||
/**
|
||||
* Type of Filter.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'CategoryFilter';
|
||||
}
|
||||
28
vendor/khill/lavacharts/src/Dashboards/Filters/ChartRangeFilter.php
vendored
Normal file
28
vendor/khill/lavacharts/src/Dashboards/Filters/ChartRangeFilter.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Filters;
|
||||
|
||||
/**
|
||||
* Chart Range Filter Class
|
||||
*
|
||||
* A slider with two thumbs superimposed onto a chart, to select a range of values
|
||||
* from the continuous axis of the chart.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Filters
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @see https://developers.google.com/chart/interactive/docs/gallery/controls#googlevisualizationchartrangefilter
|
||||
*/
|
||||
class ChartRangeFilter extends Filter
|
||||
{
|
||||
/**
|
||||
* Type of Filter.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'ChartRangeFilter';
|
||||
}
|
||||
28
vendor/khill/lavacharts/src/Dashboards/Filters/DateRangeFilter.php
vendored
Normal file
28
vendor/khill/lavacharts/src/Dashboards/Filters/DateRangeFilter.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Filters;
|
||||
|
||||
/**
|
||||
* Class DateRangeFilter
|
||||
*
|
||||
* Filter through a range of dates.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Filters
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @see https://developers.google.com/chart/interactive/docs/gallery/controls#googlevisualizationdaterangefilter
|
||||
*/
|
||||
class DateRangeFilter extends Filter
|
||||
{
|
||||
/**
|
||||
* Type of Filter.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'DateRangeFilter';
|
||||
}
|
||||
78
vendor/khill/lavacharts/src/Dashboards/Filters/Filter.php
vendored
Normal file
78
vendor/khill/lavacharts/src/Dashboards/Filters/Filter.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Filters;
|
||||
|
||||
use Khill\Lavacharts\Exceptions\InvalidFilterType;
|
||||
use Khill\Lavacharts\Exceptions\InvalidParamType;
|
||||
use Khill\Lavacharts\Support\Customizable;
|
||||
use Khill\Lavacharts\Support\Contracts\WrappableInterface as Wrappable;
|
||||
|
||||
/**
|
||||
* Filter Parent Class
|
||||
*
|
||||
* The base class for the individual filter objects, providing common
|
||||
* functions to the child objects.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Filters
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Filter extends Customizable implements Wrappable
|
||||
{
|
||||
/**
|
||||
* Type of wrapped class
|
||||
*/
|
||||
const WRAP_TYPE = 'controlType';
|
||||
|
||||
/**
|
||||
* Builds a new Filter Object.
|
||||
* Takes either a column label or a column index to filter. The options object will be
|
||||
* created internally, so no need to set defaults. The child filter objects will set them.
|
||||
*
|
||||
* @param string|int $cLabelOrIndex
|
||||
* @param array $options Array of options to set.
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidParamType
|
||||
*/
|
||||
public function __construct($cLabelOrIndex, array $options = [])
|
||||
{
|
||||
switch (gettype($cLabelOrIndex)) {
|
||||
case 'string':
|
||||
$options = array_merge($options, ['filterColumnLabel' => $cLabelOrIndex]);
|
||||
break;
|
||||
case 'integer':
|
||||
$options = array_merge($options, ['filterColumnIndex' => $cLabelOrIndex]);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidParamType($cLabelOrIndex, 'string | int');
|
||||
break;
|
||||
}
|
||||
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Filter type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return static::TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Filter wrap type.
|
||||
*
|
||||
* @since 3.0.5
|
||||
* @return string
|
||||
*/
|
||||
public function getWrapType()
|
||||
{
|
||||
return static::WRAP_TYPE;
|
||||
}
|
||||
}
|
||||
80
vendor/khill/lavacharts/src/Dashboards/Filters/FilterFactory.php
vendored
Normal file
80
vendor/khill/lavacharts/src/Dashboards/Filters/FilterFactory.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Filters;
|
||||
|
||||
use \Khill\Lavacharts\Exceptions\InvalidConfigValue;
|
||||
use \Khill\Lavacharts\Exceptions\InvalidFilter;
|
||||
use Khill\Lavacharts\Exceptions\InvalidFilterType;
|
||||
use Khill\Lavacharts\Exceptions\InvalidParamType;
|
||||
|
||||
/**
|
||||
* FilterFactory creates new filters for use in a dashboard.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Filters
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class FilterFactory
|
||||
{
|
||||
/**
|
||||
* Valid filter types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $FILTER_TYPES = [
|
||||
'Category',
|
||||
'ChartRange',
|
||||
'DateRange',
|
||||
'NumberRange',
|
||||
'String'
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new Filter.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string|int $columnLabelOrIndex
|
||||
* @param array $config
|
||||
* @return \Khill\Lavacharts\Dashboards\Filters\Filter
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidFilterType
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidParamType
|
||||
*/
|
||||
public static function create($type, $columnLabelOrIndex, array $config = [])
|
||||
{
|
||||
if (is_string($type)) {
|
||||
$type = str_replace('Filter', '', $type);
|
||||
}
|
||||
|
||||
if (in_array($type, self::$FILTER_TYPES, true) === false) {
|
||||
throw new InvalidFilterType($type);
|
||||
}
|
||||
|
||||
if (is_string($columnLabelOrIndex) === false && is_int($columnLabelOrIndex) === false) {
|
||||
throw new InvalidParamType($columnLabelOrIndex, 'string | int');
|
||||
}
|
||||
|
||||
$filter = self::makeNamespace($type);
|
||||
|
||||
return new $filter($columnLabelOrIndex, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the namespace to create a new filter.
|
||||
*
|
||||
* @param string $filter
|
||||
* @return string
|
||||
*/
|
||||
private static function makeNamespace($filter)
|
||||
{
|
||||
if (strpos($filter, 'range') !== false) {
|
||||
$filter = ucfirst(str_replace('range', 'Range', $filter));
|
||||
}
|
||||
|
||||
return __NAMESPACE__ . '\\' . $filter . 'Filter';
|
||||
}
|
||||
}
|
||||
25
vendor/khill/lavacharts/src/Dashboards/Filters/NumberRangeFilter.php
vendored
Normal file
25
vendor/khill/lavacharts/src/Dashboards/Filters/NumberRangeFilter.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Filters;
|
||||
|
||||
/**
|
||||
* Class NumberRangeFilter
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Filters
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @see https://developers.google.com/chart/interactive/docs/gallery/controls#--googlevisualizationnumberrangefilter
|
||||
*/
|
||||
class NumberRangeFilter extends Filter
|
||||
{
|
||||
/**
|
||||
* Type of Filter.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'NumberRangeFilter';
|
||||
}
|
||||
25
vendor/khill/lavacharts/src/Dashboards/Filters/StringFilter.php
vendored
Normal file
25
vendor/khill/lavacharts/src/Dashboards/Filters/StringFilter.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Filters;
|
||||
|
||||
/**
|
||||
* Class StringFilter
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Filters
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @see https://developers.google.com/chart/interactive/docs/gallery/controls#googlevisualizationstringfilter
|
||||
*/
|
||||
class StringFilter extends Filter
|
||||
{
|
||||
/**
|
||||
* Type of Filter.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'StringFilter';
|
||||
}
|
||||
42
vendor/khill/lavacharts/src/Dashboards/Wrappers/ChartWrapper.php
vendored
Normal file
42
vendor/khill/lavacharts/src/Dashboards/Wrappers/ChartWrapper.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Wrappers;
|
||||
|
||||
use Khill\Lavacharts\Charts\Chart;
|
||||
use Khill\Lavacharts\Values\ElementId;
|
||||
|
||||
/**
|
||||
* Class ChartWrapper
|
||||
*
|
||||
* Used for wrapping charts to use in dashboards.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Wrappers
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ChartWrapper extends Wrapper
|
||||
{
|
||||
/**
|
||||
* Type of wrapper.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'ChartWrapper';
|
||||
|
||||
/**
|
||||
* Builds a ChartWrapper object.
|
||||
*
|
||||
* @param \Khill\Lavacharts\Charts\Chart $chart
|
||||
* @param \Khill\Lavacharts\Values\ElementId $containerId
|
||||
*/
|
||||
public function __construct(Chart $chart, ElementId $containerId)
|
||||
{
|
||||
$chart->setRenderable(false);
|
||||
|
||||
parent::__construct($chart, $containerId);
|
||||
}
|
||||
}
|
||||
40
vendor/khill/lavacharts/src/Dashboards/Wrappers/ControlWrapper.php
vendored
Normal file
40
vendor/khill/lavacharts/src/Dashboards/Wrappers/ControlWrapper.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Wrappers;
|
||||
|
||||
use Khill\Lavacharts\Values\ElementId;
|
||||
use Khill\Lavacharts\Dashboards\Filters\Filter;
|
||||
|
||||
/**
|
||||
* ControlWrapper Class
|
||||
*
|
||||
* Used for building controls for dashboards.
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Wrappers
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ControlWrapper extends Wrapper
|
||||
{
|
||||
/**
|
||||
* Type of wrapper.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'ControlWrapper';
|
||||
|
||||
/**
|
||||
* Builds a ControlWrapper object.
|
||||
*
|
||||
* @param \Khill\Lavacharts\Dashboards\Filters\Filter $filter
|
||||
* @param \Khill\Lavacharts\Values\ElementId $containerId
|
||||
*/
|
||||
public function __construct(Filter $filter, ElementId $containerId)
|
||||
{
|
||||
parent::__construct($filter, $containerId);
|
||||
}
|
||||
}
|
||||
108
vendor/khill/lavacharts/src/Dashboards/Wrappers/Wrapper.php
vendored
Normal file
108
vendor/khill/lavacharts/src/Dashboards/Wrappers/Wrapper.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Dashboards\Wrappers;
|
||||
|
||||
use Khill\Lavacharts\Values\ElementId;
|
||||
use Khill\Lavacharts\Support\Traits\ElementIdTrait as HasElementId;
|
||||
use Khill\Lavacharts\Support\Contracts\WrappableInterface as Wrappable;
|
||||
use Khill\Lavacharts\Support\Contracts\JsonableInterface as Jsonable;
|
||||
use Khill\Lavacharts\Support\Contracts\JsClassInterface as JsClass;
|
||||
|
||||
/**
|
||||
* Class Wrapper
|
||||
*
|
||||
* The control and chart wrappers extend this for common methods.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\Dashboards\Wrappers
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Wrapper implements \JsonSerializable, Jsonable, JsClass
|
||||
{
|
||||
use HasElementId;
|
||||
|
||||
/**
|
||||
* The contents of the wrap, either Chart or Filter.
|
||||
*
|
||||
* @var \Khill\Lavacharts\Support\Contracts\WrappableInterface
|
||||
*/
|
||||
protected $contents;
|
||||
|
||||
/**
|
||||
* The renderable's unique elementId.
|
||||
*
|
||||
* @var \Khill\Lavacharts\Values\ElementId
|
||||
*/
|
||||
protected $elementId;
|
||||
|
||||
/**
|
||||
* Builds a new Wrapper object.
|
||||
*
|
||||
* @param \Khill\Lavacharts\Support\Contracts\WrappableInterface $itemToWrap
|
||||
* @param \Khill\Lavacharts\Values\ElementId $elementId
|
||||
*/
|
||||
public function __construct(Wrappable $itemToWrap, ElementId $elementId)
|
||||
{
|
||||
$this->contents = $itemToWrap;
|
||||
$this->elementId = $elementId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unwraps and returns the wrapped object.
|
||||
*
|
||||
* @return \Khill\Lavacharts\Support\Contracts\WrappableInterface
|
||||
*/
|
||||
public function unwrap()
|
||||
{
|
||||
return $this->contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom serialization of the Wrapper.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'options' => $this->contents,
|
||||
'containerId' => (string) $this->elementId,
|
||||
$this->contents->getWrapType() => $this->contents->getType()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JSON serialized version of the Wrapper.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toJson()
|
||||
{
|
||||
return json_encode($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a javascript string of the visualization class for the Wrapper.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.' . static::TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a javascript string with the constructor for the Wrapper.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJsConstructor()
|
||||
{
|
||||
return sprintf('new %s(%s)', $this->getJsClass(), $this->toJson());
|
||||
}
|
||||
}
|
||||
151
vendor/khill/lavacharts/src/DataTables/Cells/Cell.php
vendored
Normal file
151
vendor/khill/lavacharts/src/DataTables/Cells/Cell.php
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Cells;
|
||||
|
||||
use Khill\Lavacharts\Exceptions\InvalidParamType;
|
||||
use Khill\Lavacharts\Support\Customizable;
|
||||
|
||||
/**
|
||||
* DataCell Object
|
||||
*
|
||||
* Holds the information for a data point
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Cells
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Cell extends Customizable
|
||||
{
|
||||
/**
|
||||
* The cell value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $v;
|
||||
|
||||
/**
|
||||
* A string version of the v value. (Optional)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $f;
|
||||
|
||||
/**
|
||||
* An array that is a map of custom values applied to the cell. (Optional)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $p;
|
||||
|
||||
/**
|
||||
* Defines a Cell for a DataTable
|
||||
*
|
||||
* Each cell in the table holds a value. Cells optionally can take a
|
||||
* "formatted" version of the data; this is a string version of the data,
|
||||
* formatted for display by a visualization. A visualization can (but is
|
||||
* not required to) use the formatted version for display, but will always
|
||||
* use the data itself for any sorting or calculations that it makes (such
|
||||
* as determining where on a graph to place a point). An example might be
|
||||
* assigning the values "low" "medium", and "high" as formatted values to
|
||||
* numeric cell values of 1, 2, and 3.
|
||||
*
|
||||
*
|
||||
* @param string $v The cell value
|
||||
* @param string $f A string version of the v value
|
||||
* @param array|string $p A map of custom values applied to the cell
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidParamType
|
||||
*/
|
||||
public function __construct($v, $f = '', array $p = [])
|
||||
{
|
||||
if (is_string($f) === false) {
|
||||
throw new InvalidParamType($f, 'string');
|
||||
}
|
||||
|
||||
$this->v = $v;
|
||||
$this->f = $f;
|
||||
|
||||
parent::__construct($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping the 'p' attribute of the cell to it's options.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $attr
|
||||
* @return array
|
||||
*/
|
||||
public function __get($attr)
|
||||
{
|
||||
if ($attr == 'p') {
|
||||
return $this->getOptions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowing the 'p' attribute to be checked for options by using the hasOptions method.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $attr
|
||||
* @return bool
|
||||
*/
|
||||
function __isset($attr)
|
||||
{
|
||||
if ($attr == 'p') {
|
||||
return $this->hasOptions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string format of the value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormat()
|
||||
{
|
||||
return $this->f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the custom values of the cell.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomValues()
|
||||
{
|
||||
return $this->f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom serialization of the Cell
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$json = ['v' => $this->v];
|
||||
|
||||
if ( ! empty($this->f)) {
|
||||
$json['f'] = $this->f;
|
||||
}
|
||||
|
||||
if ( ! empty($this->options)) {
|
||||
$json['p'] = $this->getOptions();
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
130
vendor/khill/lavacharts/src/DataTables/Cells/DateCell.php
vendored
Normal file
130
vendor/khill/lavacharts/src/DataTables/Cells/DateCell.php
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Cells;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Exceptions\CarbonParseError;
|
||||
use Khill\Lavacharts\Exceptions\InvalidDateTimeFormat;
|
||||
use Khill\Lavacharts\Exceptions\InvalidDateTimeString;
|
||||
use Khill\Lavacharts\Exceptions\InvalidStringValue;
|
||||
use Khill\Lavacharts\Values\StringValue;
|
||||
|
||||
/**
|
||||
* DateCell Class
|
||||
*
|
||||
* Wrapper object to implement JsonSerializable on the Carbon object.
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Cells
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class DateCell extends Cell
|
||||
{
|
||||
/**
|
||||
* Creates a new DateCell object from a Carbon object.
|
||||
*
|
||||
* @param \Carbon\Carbon $carbon
|
||||
* @param string $format
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(Carbon $carbon = null, $format = '', array $options = [])
|
||||
{
|
||||
parent::__construct($carbon, $format, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a datetime string with or without a datetime format.
|
||||
*
|
||||
* Uses Carbon to create the values for the DateCell.
|
||||
*
|
||||
*
|
||||
* @param string $dateTimeString
|
||||
* @param string $dateTimeFormat
|
||||
* @return \Khill\Lavacharts\DataTables\Cells\Cell
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidDateTimeFormat
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidDateTimeString
|
||||
*/
|
||||
public static function parseString($dateTimeString, $dateTimeFormat = '')
|
||||
{
|
||||
if ($dateTimeString === null) {
|
||||
return new DateCell();
|
||||
}
|
||||
|
||||
if (StringValue::isNonEmpty($dateTimeString) === false) {
|
||||
throw new InvalidDateTimeString($dateTimeString);
|
||||
}
|
||||
|
||||
if (StringValue::isNonEmpty($dateTimeFormat)) {
|
||||
try {
|
||||
return self::createFromFormat($dateTimeFormat, $dateTimeString);
|
||||
} catch (\Exception $e) {
|
||||
throw new InvalidDateTimeFormat($dateTimeFormat);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$carbon = Carbon::parse($dateTimeString);
|
||||
|
||||
return new DateCell($carbon);
|
||||
} catch (\Exception $e) {
|
||||
throw new InvalidDateTimeString($dateTimeString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DateCell from a datetime string and a format.
|
||||
*
|
||||
* Carbon is used to validate the input.
|
||||
*
|
||||
* @param string $format
|
||||
* @param string $datetime
|
||||
* @return \Khill\Lavacharts\DataTables\Cells\DateCell
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidDateTimeFormat
|
||||
*/
|
||||
public static function createFromFormat($format, $datetime)
|
||||
{
|
||||
try {
|
||||
$carbon = Carbon::createFromFormat($format, $datetime);
|
||||
|
||||
return new self($carbon);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
throw new InvalidDateTimeFormat($format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom string output of the Carbon date.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if ($this->v === null) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'Date(%d,%d,%d,%d,%d,%d)',
|
||||
isset($this->v->year) ? $this->v->year : 'null',
|
||||
isset($this->v->month) ? $this->v->month - 1 : 'null', //silly javascript
|
||||
isset($this->v->day) ? $this->v->day : 'null',
|
||||
isset($this->v->hour) ? $this->v->hour : 'null',
|
||||
isset($this->v->minute) ? $this->v->minute : 'null',
|
||||
isset($this->v->second) ? $this->v->second : 'null'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom serialization of the Carbon date.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return ['v' => (string) $this];
|
||||
}
|
||||
}
|
||||
31
vendor/khill/lavacharts/src/DataTables/Cells/NullCell.php
vendored
Normal file
31
vendor/khill/lavacharts/src/DataTables/Cells/NullCell.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Cells;
|
||||
|
||||
use Khill\Lavacharts\Exceptions\InvalidParamType;
|
||||
use Khill\Lavacharts\Support\Customizable;
|
||||
|
||||
/**
|
||||
* DataCell Object
|
||||
*
|
||||
* Holds the information for a data point
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Cells
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class NullCell extends Cell
|
||||
{
|
||||
/**
|
||||
* Create a new NullCell
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(null);
|
||||
}
|
||||
}
|
||||
|
||||
147
vendor/khill/lavacharts/src/DataTables/Columns/Column.php
vendored
Normal file
147
vendor/khill/lavacharts/src/DataTables/Columns/Column.php
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Columns;
|
||||
|
||||
use Khill\Lavacharts\DataTables\Formats\Format;
|
||||
use Khill\Lavacharts\Support\Customizable;
|
||||
use Khill\Lavacharts\Values\Role;
|
||||
|
||||
/**
|
||||
* Column Object
|
||||
*
|
||||
* The Column object is used to define the different columns for a DataTable.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Columns
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Column extends Customizable
|
||||
{
|
||||
/**
|
||||
* Column type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Column label.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = '';
|
||||
|
||||
/**
|
||||
* Column formatter.
|
||||
*
|
||||
* @var \Khill\Lavacharts\DataTables\Formats\Format
|
||||
*/
|
||||
protected $format = null;
|
||||
|
||||
/**
|
||||
* Column role.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $role = null;
|
||||
|
||||
/**
|
||||
* Creates a new Column with the defined label.
|
||||
*
|
||||
* @param string $type Column type.
|
||||
* @param string $label Column label (optional).
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format Column format(optional).
|
||||
* @param \Khill\Lavacharts\Values\Role $role Column role (optional).
|
||||
* @param array $options Column options (optional).
|
||||
*/
|
||||
public function __construct($type, $label = '', Format $format = null, Role $role = null, array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
|
||||
$this->type = $type;
|
||||
$this->label = $label;
|
||||
$this->format = $format;
|
||||
$this->role = $role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of column.
|
||||
*
|
||||
* @return string Column type.
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column label.
|
||||
*
|
||||
* @return string Column label.
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column formatter.
|
||||
*
|
||||
* @return \Khill\Lavacharts\DataTables\Formats\Format
|
||||
*/
|
||||
public function getFormat()
|
||||
{
|
||||
return $this->format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status of if the column is formatted.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isFormatted()
|
||||
{
|
||||
return ($this->format instanceof Format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column role.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRole()
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom json serialization of the column.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$values = [
|
||||
'type' => $this->type
|
||||
];
|
||||
|
||||
if (is_string($this->label) && !empty($this->label)) {
|
||||
$values['label'] = $this->label;
|
||||
}
|
||||
|
||||
if ($this->role instanceof Role) {
|
||||
$values['p'] = ['role' => (string) $this->role];
|
||||
|
||||
if ($this->hasOptions()) {
|
||||
$values['p'] = array_merge($values['p'], $this->getOptions());
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
136
vendor/khill/lavacharts/src/DataTables/Columns/ColumnBuilder.php
vendored
Normal file
136
vendor/khill/lavacharts/src/DataTables/Columns/ColumnBuilder.php
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Columns;
|
||||
|
||||
use Khill\Lavacharts\DataTables\Formats\Format;
|
||||
use Khill\Lavacharts\Exceptions\InvalidColumnRole;
|
||||
use Khill\Lavacharts\Exceptions\InvalidColumnType;
|
||||
use Khill\Lavacharts\Support\Customizable;
|
||||
use Khill\Lavacharts\Values\Role;
|
||||
use Khill\Lavacharts\Values\StringValue;
|
||||
|
||||
/**
|
||||
* Column Object
|
||||
*
|
||||
* The Column object is used to define the different columns for a DataTable.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Columns
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ColumnBuilder
|
||||
{
|
||||
/**
|
||||
* Column type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* Column label.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $label = '';
|
||||
|
||||
/**
|
||||
* Column formatter.
|
||||
*
|
||||
* @var \Khill\Lavacharts\DataTables\Formats\Format
|
||||
*/
|
||||
private $format = null;
|
||||
|
||||
/**
|
||||
* Column role.
|
||||
*
|
||||
* @var \Khill\Lavacharts\Values\Role
|
||||
*/
|
||||
private $role = null;
|
||||
|
||||
/**
|
||||
* Column options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $options = [];
|
||||
|
||||
/**
|
||||
* Sets the type of column.
|
||||
*
|
||||
* @param string $type
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
if (StringValue::isNonEmpty($type) === false) {
|
||||
throw new InvalidColumnType($type);
|
||||
}
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the column label.
|
||||
*
|
||||
* @param string $label
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the column formatter.
|
||||
*
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format
|
||||
*/
|
||||
public function setFormat(Format $format = null)
|
||||
{
|
||||
$this->format = $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the column role.
|
||||
*
|
||||
* @param string $role
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnRole
|
||||
*/
|
||||
public function setRole($role)
|
||||
{
|
||||
if (StringValue::isNonEmpty($role)) {
|
||||
$this->role = new Role($role);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the column options.
|
||||
*
|
||||
* @param array $options
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new column instance with the set values.
|
||||
*
|
||||
* @return \Khill\Lavacharts\DataTables\Columns\Column
|
||||
*/
|
||||
public function getResult()
|
||||
{
|
||||
return new Column(
|
||||
$this->type,
|
||||
$this->label,
|
||||
$this->format,
|
||||
$this->role,
|
||||
$this->options
|
||||
);
|
||||
}
|
||||
}
|
||||
104
vendor/khill/lavacharts/src/DataTables/Columns/ColumnFactory.php
vendored
Normal file
104
vendor/khill/lavacharts/src/DataTables/Columns/ColumnFactory.php
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Columns;
|
||||
|
||||
use Khill\Lavacharts\Values\Role;
|
||||
use Khill\Lavacharts\Values\StringValue;
|
||||
use Khill\Lavacharts\DataTables\Formats\Format;
|
||||
use Khill\Lavacharts\Exceptions\InvalidColumnType;
|
||||
use Khill\Lavacharts\Exceptions\InvalidColumnRole;
|
||||
|
||||
/**
|
||||
* ColumnFactory Class
|
||||
*
|
||||
* The ColumnFactory creates new columns for DataTables. The only mandatory parameter is
|
||||
* the type of column to create, all others are optional.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Columns
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class ColumnFactory
|
||||
{
|
||||
/**
|
||||
* Valid column types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $types = [
|
||||
'role',
|
||||
'string',
|
||||
'number',
|
||||
'boolean',
|
||||
'date',
|
||||
'datetime',
|
||||
'timeofday'
|
||||
];
|
||||
|
||||
/**
|
||||
* Creates a new column object.
|
||||
*
|
||||
* @access public
|
||||
* @since 3.0.0
|
||||
* @param string $type Type of column to create.
|
||||
* @param string $label A label for the column.
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format Column formatter for the data.
|
||||
* @param string $role A role for the column to play.
|
||||
* @param array $options Column options.
|
||||
* @return \Khill\Lavacharts\DataTables\Columns\Column
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnRole
|
||||
*/
|
||||
public function create(
|
||||
$type,
|
||||
$label = '',
|
||||
Format $format = null,
|
||||
$role = '',
|
||||
array $options = []
|
||||
) {
|
||||
self::isValidType($type);
|
||||
|
||||
$builder = new ColumnBuilder();
|
||||
$builder->setType($type);
|
||||
$builder->setLabel($label);
|
||||
$builder->setFormat($format);
|
||||
$builder->setRole($role);
|
||||
$builder->setOptions($options);
|
||||
|
||||
return $builder->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Column with the same values, while applying the Format.
|
||||
*
|
||||
* @param \Khill\Lavacharts\DataTables\Columns\Column $column
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format
|
||||
* @return \Khill\Lavacharts\DataTables\Columns\Column
|
||||
*/
|
||||
public function applyFormat(Column $column, Format $format = null)
|
||||
{
|
||||
return $this->create(
|
||||
$column->getType(),
|
||||
$column->getLabel(),
|
||||
$format,
|
||||
$column->getRole()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given type is a valid column type
|
||||
*
|
||||
* @param string $type
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
|
||||
*/
|
||||
public static function isValidType($type)
|
||||
{
|
||||
if (in_array($type, self::$types, true) === false) {
|
||||
throw new InvalidColumnType($type, self::$types);
|
||||
}
|
||||
}
|
||||
}
|
||||
212
vendor/khill/lavacharts/src/DataTables/DataFactory.php
vendored
Normal file
212
vendor/khill/lavacharts/src/DataTables/DataFactory.php
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables;
|
||||
|
||||
use Khill\Lavacharts\DataTables\Cells\Cell;
|
||||
use Khill\Lavacharts\Exceptions\InvalidJson;
|
||||
|
||||
/**
|
||||
* Class DataFactory
|
||||
*
|
||||
* The DataFactory is used to create new DataTables and DataCells in many different
|
||||
* ways.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables
|
||||
* @since 3.1.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class DataFactory
|
||||
{
|
||||
/**
|
||||
* Creates a new DataTable
|
||||
*
|
||||
* This method will create an empty DataTable, with a timezone if
|
||||
* passed a string as the first parameter or with no timezone if passed nothing.
|
||||
*
|
||||
* If the first parameter is an array, then the array will be attempted to be
|
||||
* used as columns for a new DataTable.
|
||||
*
|
||||
* If given an array for the second parameter, then it will be interpreted as
|
||||
* row definitions.
|
||||
*
|
||||
* @param mixed $columns Array of columns or timezone
|
||||
* @param array $rows Array of rows
|
||||
* @param string $timezone Timezone to use while using Carbon
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
*/
|
||||
public static function DataTable($columns = null, array $rows = [], $timezone = null)
|
||||
{
|
||||
if ($columns === null || gettype($columns) === 'string') {
|
||||
$timezone = $columns;
|
||||
}
|
||||
|
||||
$datatable = self::emptyDataTable($timezone);
|
||||
|
||||
if (is_array($columns)) {
|
||||
$datatable->addColumns($columns);
|
||||
}
|
||||
|
||||
if (is_array($rows)) {
|
||||
$datatable->addRows($rows);
|
||||
} else if ($rows instanceof \Closure) {
|
||||
$datatable->addRows($rows());
|
||||
}
|
||||
|
||||
return $datatable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new, empty DataTable.
|
||||
*
|
||||
* This method will create an empty DataTable, with or without a timezone.
|
||||
*
|
||||
* @param string $timezone Timezone to use while using Carbon
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
*/
|
||||
private static function emptyDataTable($timezone)
|
||||
{
|
||||
$datatable = '\Khill\Lavacharts\DataTablePlus\DataTablePlus';
|
||||
|
||||
if (class_exists($datatable) === false) {
|
||||
$datatable = '\Khill\Lavacharts\DataTables\DataTable';
|
||||
}
|
||||
|
||||
return new $datatable($timezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an array to create a full DataTable.
|
||||
*
|
||||
* Replicating the functionality of Google's javascript version
|
||||
* of automatic datatable creation from an array of column headings
|
||||
* and data.
|
||||
* Passing true as the second parameter will bypass column labeling
|
||||
* and treat the first row as data.
|
||||
*
|
||||
* @param array $tableArray Array of arrays containing column labels and data.
|
||||
* @param bool $firstRowIsData If true, the first row is treated as data, not column labels.
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
*/
|
||||
public static function arrayToDataTable($tableArray, $firstRowIsData = false)
|
||||
{
|
||||
$datatable = new DataTable();
|
||||
$columnCount = count($tableArray[0]);
|
||||
|
||||
if ($firstRowIsData === false) {
|
||||
$columnLabels = array_shift($tableArray);
|
||||
}
|
||||
|
||||
$rowCount = count($tableArray);
|
||||
|
||||
for ($i = 0; $i < $columnCount; $i++) {
|
||||
$columnType = gettype($tableArray[0][$i]);
|
||||
|
||||
while ($columnType === null) {
|
||||
$columnType = gettype($tableArray[rand(1, $rowCount)][$i]);
|
||||
}
|
||||
|
||||
switch ($columnType) {
|
||||
case 'integer':
|
||||
case 'float':
|
||||
case 'double':
|
||||
$column = ['number'];
|
||||
break;
|
||||
|
||||
case 'string':
|
||||
default:
|
||||
$column = ['string'];
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($columnLabels[$i])) {
|
||||
$column[] = $columnLabels[$i];
|
||||
}
|
||||
|
||||
$datatable->addColumn($column);
|
||||
}
|
||||
|
||||
$datatable->addRows($tableArray);
|
||||
|
||||
return $datatable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a string of JSON data into a DataTable.
|
||||
*
|
||||
* Most google examples can be passed to this method with some tweaks.
|
||||
* PHP requires that only double quotes are used on identifiers.
|
||||
* For example:
|
||||
* - {label: 'Team'} would be invalid
|
||||
* - {"label": "Team"} would be accepted.
|
||||
*
|
||||
* @param string $jsonString JSON string to decode
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidJson
|
||||
*/
|
||||
public static function createFromJson($jsonString)
|
||||
{
|
||||
$decodedJson = json_decode($jsonString, true);
|
||||
|
||||
if ($decodedJson === null) {
|
||||
throw new InvalidJson;
|
||||
}
|
||||
|
||||
$datatable = new DataTable();
|
||||
|
||||
foreach ($decodedJson['cols'] as $column) {
|
||||
if (isset($column['label'])) {
|
||||
$label = $column['label'];
|
||||
} else {
|
||||
$label = '';
|
||||
}
|
||||
|
||||
$datatable->addColumn($column['type'], $label);
|
||||
}
|
||||
|
||||
foreach ($decodedJson['rows'] as $row) {
|
||||
$rowData = [];
|
||||
|
||||
foreach ($row['c'] as $cell) {
|
||||
$rowData[] = $cell['v'];
|
||||
}
|
||||
|
||||
$datatable->addRow($rowData);
|
||||
}
|
||||
|
||||
return $datatable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DataCell for a value in a Row
|
||||
*
|
||||
* v: The cell value. The data type should match the column data type.
|
||||
* If null, the whole object should be empty and have neither v nor f properties.
|
||||
*
|
||||
* f: [Optional] A string version of the v value, formatted for display. The
|
||||
* values should match, so if you specify Date(2008, 0, 1) for v, you should
|
||||
* specify "January 1, 2008" or some such string for this property. This value
|
||||
* is not checked against the v value. The visualization will not use this value
|
||||
* for calculation, only as a label for display. If omitted, a string version
|
||||
* of v will be used.
|
||||
*
|
||||
* p: [Optional] An object that is a map of custom values applied to the cell.
|
||||
* These values can be of any JavaScript type. If your visualization supports
|
||||
* any cell-level properties, it will describe them; otherwise, this property
|
||||
* will be ignored. Example: p:{style: 'border: 1px solid green;'}.
|
||||
*
|
||||
*
|
||||
* @param mixed $v Value of the Cell
|
||||
* @param string $f Formatted version of the cell, as a string
|
||||
* @param array $p Cell specific customization options
|
||||
* @return \Khill\Lavacharts\DataTables\Cells\Cell
|
||||
*/
|
||||
public static function cell($v, $f = '', $p = [])
|
||||
{
|
||||
return new Cell($v, $f, $p);
|
||||
}
|
||||
}
|
||||
766
vendor/khill/lavacharts/src/DataTables/DataTable.php
vendored
Normal file
766
vendor/khill/lavacharts/src/DataTables/DataTable.php
vendored
Normal file
@@ -0,0 +1,766 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables;
|
||||
|
||||
use DateTimeZone;
|
||||
use JsonSerializable;
|
||||
use Khill\Lavacharts\DataTables\Formats\Format;
|
||||
use Khill\Lavacharts\DataTables\Rows\Row;
|
||||
use Khill\Lavacharts\DataTables\Columns\ColumnFactory;
|
||||
use Khill\Lavacharts\Exceptions\InvalidColumnDefinition;
|
||||
use Khill\Lavacharts\Exceptions\InvalidColumnIndex;
|
||||
use Khill\Lavacharts\Exceptions\InvalidColumnRole;
|
||||
use Khill\Lavacharts\Exceptions\InvalidConfigValue;
|
||||
use Khill\Lavacharts\Exceptions\InvalidDateTimeFormat;
|
||||
use Khill\Lavacharts\Exceptions\InvalidTimeZone;
|
||||
use Khill\Lavacharts\Support\Contracts\JsonableInterface as Jsonable;
|
||||
use Khill\Lavacharts\Values\Role;
|
||||
use Khill\Lavacharts\Values\StringValue;
|
||||
|
||||
/**
|
||||
* The DataTable object is used to hold the data passed into a visualization.
|
||||
*
|
||||
* A DataTable is a basic two-dimensional table. All data in each column must
|
||||
* have the same data type. Each column has a descriptor that includes its data
|
||||
* type, a label for that column (which might be displayed by a visualization),
|
||||
* and an ID, which can be used to refer to a specific column (as an alternative
|
||||
* to using column indexes). The DataTable object also supports a map of
|
||||
* arbitrary properties assigned to a specific value, a row, a column, or the
|
||||
* whole DataTable. Visualizations can use these to support additional features;
|
||||
* for example, the Table visualization uses custom properties to let you assign
|
||||
* arbitrary class names or styles to individual cells.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables
|
||||
* @since 1.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class DataTable implements Jsonable, JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Timezone for dealing with datetime and Carbon objects.
|
||||
*
|
||||
* @var \Khill\Lavacharts\DataTables\Columns\ColumnFactory
|
||||
*/
|
||||
protected $columnFactory;
|
||||
|
||||
/**
|
||||
* RowFactory for the DataTable
|
||||
*
|
||||
* @var \Khill\Lavacharts\DataTables\Rows\RowFactory
|
||||
*/
|
||||
protected $rowFactory;
|
||||
|
||||
/**
|
||||
* Array of the DataTable's column objects.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cols = [];
|
||||
|
||||
/**
|
||||
* Array of the DataTable's row objects.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rows = [];
|
||||
|
||||
/**
|
||||
* Format for Carbon to parse datetime strings.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateTimeFormat;
|
||||
|
||||
/**
|
||||
* Creates a new DataTable
|
||||
*
|
||||
* @param string $timezone Timezone to use when dealing with dates & times
|
||||
*/
|
||||
public function __construct($timezone = null)
|
||||
{
|
||||
$this->columnFactory = new ColumnFactory;
|
||||
|
||||
if ($timezone === null) {
|
||||
$timezone = date_default_timezone_get();
|
||||
}
|
||||
|
||||
$this->setTimezone($timezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DataCell for a value in a Row
|
||||
*
|
||||
* @see \Khill\Lavacharts\DataTables\DataFactory::cell
|
||||
* @deprecated 3.0.5
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param mixed $v Value of the Cell
|
||||
* @param string $f Formatted version of the cell, as a string
|
||||
* @param array $p Cell specific customization options
|
||||
* @return \Khill\Lavacharts\DataTables\Cells\Cell
|
||||
*/
|
||||
public static function cell($v, $f = '', $p = [])
|
||||
{
|
||||
return DataFactory::cell($v, $f, $p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a string of JSON data into a DataTable.
|
||||
*
|
||||
* @deprecated 3.1.0 Use the DataFactory instead
|
||||
* @see \Khill\Lavacharts\DataTables\DataFactory::createFromJson
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $jsonString JSON string to decode
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidJson
|
||||
*/
|
||||
public static function createFromJson($jsonString)
|
||||
{
|
||||
return DataFactory::createFromJson($jsonString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Timezone that Carbon will use when parsing dates
|
||||
*
|
||||
* @param string $timezone
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidTimeZone
|
||||
*/
|
||||
public function setTimezone($timezone)
|
||||
{
|
||||
if ($this->isValidTimezone($timezone) === false) {
|
||||
throw new InvalidTimeZone($timezone);
|
||||
}
|
||||
|
||||
$this->timezone = new DateTimeZone($timezone);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current timezone used in the DataTable
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @return \DateTimeZone
|
||||
*/
|
||||
public function getTimeZone()
|
||||
{
|
||||
return $this->timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the format to be used by Carbon::createFromFormat()
|
||||
* This method is used to set the format to be used to parse a string
|
||||
* passed to a cell in a date column, that was parsed incorrectly by Carbon::parse()
|
||||
*
|
||||
* @param string $dateTimeFormat
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidDateTimeFormat
|
||||
*/
|
||||
public function setDateTimeFormat($dateTimeFormat)
|
||||
{
|
||||
if (StringValue::isNonEmpty($dateTimeFormat) === false) {
|
||||
throw new InvalidDateTimeFormat($dateTimeFormat);
|
||||
}
|
||||
|
||||
$this->dateTimeFormat = $dateTimeFormat;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set DateTime format.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @return string DateTime format
|
||||
*/
|
||||
public function getDateTimeFormat()
|
||||
{
|
||||
return (string) $this->dateTimeFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bare clone of the DataTable.
|
||||
*
|
||||
* This method clone the DataTable and strip the rows off. Useful when loading
|
||||
* charts via ajax, and you need the initial DataTable structure to pre-load
|
||||
* the chart's format.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable;
|
||||
*/
|
||||
public function bare()
|
||||
{
|
||||
$clone = clone $this;
|
||||
|
||||
return $clone->stripRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a column to the DataTable
|
||||
*
|
||||
* First signature has the following parameters:
|
||||
* type - A string with the data type of the values of the column.
|
||||
* The type can be one of the following: 'string' 'number' 'bool' 'date'
|
||||
* 'datetime' 'timeofday'.
|
||||
*
|
||||
* columnLabel - [Optional] A string with the label of the column. The column
|
||||
* label is typically displayed as part of the visualization, for example as
|
||||
* a column header in a table, or as a legend label in a pie chart. If not
|
||||
* value is specified, an empty string is assigned.
|
||||
* optId - [Optional] A string with a unique identifier for the column. If
|
||||
* not value is specified, an empty string is assigned.
|
||||
*
|
||||
*
|
||||
* @param mixed $typeOrColDescArr Column type or an array describing the column.
|
||||
* @param string $label A label for the column. (Optional)
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format A column format object. (Optional)
|
||||
* @param string $role A role for the column. (Optional)
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidConfigProperty
|
||||
*/
|
||||
public function addColumn($typeOrColDescArr, $label = '', Format $format = null, $role = '')
|
||||
{
|
||||
if (is_array($typeOrColDescArr)) {
|
||||
return call_user_func_array([$this, 'createColumnWithParams'], $typeOrColDescArr);
|
||||
}
|
||||
|
||||
if (is_string($typeOrColDescArr)) {
|
||||
return $this->createColumnWithParams($typeOrColDescArr, $label, $format, $role);
|
||||
}
|
||||
|
||||
throw new InvalidConfigValue(
|
||||
__FUNCTION__,
|
||||
'string|array'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple columns to the DataTable
|
||||
*
|
||||
* @param array $arrayOfColumns Array of columns to batch add to the DataTable.
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnDefinition
|
||||
*/
|
||||
public function addColumns(array $arrayOfColumns)
|
||||
{
|
||||
foreach ($arrayOfColumns as $columnArray) {
|
||||
if (is_array($columnArray) === false) {
|
||||
throw new InvalidColumnDefinition($columnArray);
|
||||
}
|
||||
|
||||
call_user_func_array([$this, 'createColumnWithParams'], $columnArray);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplemental function to add a boolean column with less params.
|
||||
*
|
||||
* @since 3.0.0.
|
||||
* @param string $label A label for the column.
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format A column format object. (Optional)
|
||||
* @param string $role A role for the column. (Optional)
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidLabel
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
|
||||
*/
|
||||
public function addBooleanColumn($label = '', Format $format = null, $role = '')
|
||||
{
|
||||
return $this->createColumnWithParams('boolean', $label, $format, $role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplemental function to add a string column with less params.
|
||||
*
|
||||
* @param string $label A label for the column.
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format A column format object. (Optional)
|
||||
* @param string $role A role for the column. (Optional)
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidLabel
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
|
||||
*/
|
||||
public function addStringColumn($label = '', Format $format = null, $role = '')
|
||||
{
|
||||
return $this->createColumnWithParams('string', $label, $format, $role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplemental function to add a date column with less params.
|
||||
*
|
||||
* @param string $label A label for the column.
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format A column format object. (Optional)
|
||||
* @param string $role A role for the column. (Optional)
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidLabel
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
|
||||
*/
|
||||
public function addDateColumn($label = '', Format $format = null, $role = '')
|
||||
{
|
||||
return $this->createColumnWithParams('date', $label, $format, $role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplemental function to add a datetime column with less params.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $label A label for the column.
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format A column format object. (Optional)
|
||||
* @param string $role A role for the column. (Optional)
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidLabel
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
|
||||
*/
|
||||
public function addDateTimeColumn($label = '', Format $format = null, $role = '')
|
||||
{
|
||||
return $this->createColumnWithParams('datetime', $label, $format, $role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplemental function to add a timeofday column with less params.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $label A label for the column.
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format A column format object. (Optional)
|
||||
* @param string $role A role for the column. (Optional)
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidLabel
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
|
||||
*/
|
||||
public function addTimeOfDayColumn($label = '', Format $format = null, $role = '')
|
||||
{
|
||||
return $this->createColumnWithParams('timeofday', $label, $format, $role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplemental function to add a number column with less params.
|
||||
*
|
||||
* @param string $label A label for the column.
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format A column format object. (Optional)
|
||||
* @param string $role A role for the column. (Optional)
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidLabel
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
|
||||
*/
|
||||
public function addNumberColumn($label = '', Format $format = null, $role = '')
|
||||
{
|
||||
return $this->createColumnWithParams('number', $label, $format, $role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new column for defining a data role.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $type Type of data the column will define.
|
||||
* @param string $role Type of role that the data will represent.
|
||||
* @param array $options Customization of the role.
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnRole
|
||||
*/
|
||||
public function addRoleColumn($type, $role, array $options = [])
|
||||
{
|
||||
if (Role::isValid($role) === false) {
|
||||
throw new InvalidColumnRole($role);
|
||||
}
|
||||
|
||||
return $this->createColumnWithParams($type, '', null, $role, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplemental function to create columns from strings.
|
||||
*
|
||||
* @access protected
|
||||
* @param string $type Type of column to create
|
||||
* @param string $label Label for the column.
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format A column format object.
|
||||
* @param string $role A role for the column.
|
||||
* @param array $options Extra, column specific options
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
*/
|
||||
protected function createColumnWithParams($type, $label = '', Format $format = null, $role = '', array $options = [])
|
||||
{
|
||||
$this->cols[] = $this->columnFactory->create($type, $label, $format, $role, $options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops a column and its data from the DataTable
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param int $colIndex
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnIndex
|
||||
*/
|
||||
public function dropColumn($colIndex)
|
||||
{
|
||||
if (is_int($colIndex) === false || array_key_exists($colIndex, $this->cols) === false) {
|
||||
throw new InvalidColumnIndex($colIndex, count($this->cols));
|
||||
}
|
||||
|
||||
unset($this->cols[$colIndex]);
|
||||
|
||||
$this->cols = array_values($this->cols);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the format of the column.
|
||||
*
|
||||
* @param integer $index
|
||||
* @param \Khill\Lavacharts\DataTables\Formats\Format $format
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnIndex
|
||||
*/
|
||||
public function formatColumn($index, Format $format = null)
|
||||
{
|
||||
$this->indexCheck($index);
|
||||
|
||||
$this->cols[$index] = $this->columnFactory->applyFormat($this->cols[$index], $format);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the format of multiple columns.
|
||||
*
|
||||
* @param array $formatArray
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
*/
|
||||
public function formatColumns(array $formatArray)
|
||||
{
|
||||
foreach ($formatArray as $index => $format) {
|
||||
$this->formatColumn($index, $format);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a row to the DataTable.
|
||||
*
|
||||
* A row is an array of data, that is mapped to the columns, in order.
|
||||
*
|
||||
* A column value (cell) in the row is described by a single value:
|
||||
* integer, string, date, etc.
|
||||
* OR
|
||||
* an array with the following properties to explicitly define a cell.
|
||||
* OR
|
||||
* a null to create a null row.
|
||||
*
|
||||
* Cell Properties:
|
||||
* $cell[0] - The cell value. The data type should match the column data type.
|
||||
*
|
||||
* $cell[1] - [Optional] A string version of the value, formatted for display. The
|
||||
* values should match, so if you specify "2008-0-1" for [0], you should
|
||||
* specify "January 1, 2008" or some such string for this property. This value
|
||||
* is not checked against the [0] value. The visualization will not use this value
|
||||
* for calculation, only as a label for display. If omitted, a string version
|
||||
* of [0] will be used.
|
||||
*
|
||||
* $cell[2] - [Optional] An array that is a map of custom values applied to the cell.
|
||||
* These values can be of any JavaScript type. If your visualization supports
|
||||
* any cell-level properties, it will describe them; otherwise, this property
|
||||
* will be ignored. Example: [$v, $f, "style: 'border: 1px solid green;'"]
|
||||
*
|
||||
* Cells in the row array should be in the same order as their column descriptions
|
||||
* in cols. To indicate a null cell, you can specify null. To indicate a row
|
||||
* with null for the first two cells, you would specify [null, null, {cell_val}].
|
||||
*
|
||||
* @param array|null $valueArray Array of values describing cells or null for a null row.
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidRowDefinition
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidRowProperty
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidCellCount
|
||||
*/
|
||||
public function addRow(array $valueArray = null)
|
||||
{
|
||||
$this->rows[] = Row::create($this, $valueArray);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple rows to the DataTable.
|
||||
*
|
||||
* @see addRow()
|
||||
* @param \Khill\Lavacharts\DataTables\Rows\Row[] $arrayOfRows
|
||||
* @return \Khill\Lavacharts\DataTables\DataTable
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidConfigValue
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidRowDefinition
|
||||
*/
|
||||
public function addRows(array $arrayOfRows)
|
||||
{
|
||||
/** @var array $row */
|
||||
foreach ($arrayOfRows as $row) {
|
||||
$this->addRow($row);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rows array from the DataTable
|
||||
*
|
||||
* @return \Khill\Lavacharts\DataTables\Rows\Row[]
|
||||
*/
|
||||
public function getRows()
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows in the DataTable
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRowCount()
|
||||
{
|
||||
return count($this->rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a column based on it's index.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param int $index
|
||||
* @return \Khill\Lavacharts\DataTables\Columns\Column
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnIndex
|
||||
*/
|
||||
public function getColumn($index)
|
||||
{
|
||||
$this->indexCheck($index);
|
||||
|
||||
return $this->cols[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column array from the DataTable
|
||||
*
|
||||
* @return \Khill\Lavacharts\DataTables\Columns\Column[]
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->cols;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the columns whos type match the given value.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $type
|
||||
* @return array
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnType
|
||||
*/
|
||||
public function getColumnsByType($type)
|
||||
{
|
||||
ColumnFactory::isValidType($type);
|
||||
|
||||
$indices = [];
|
||||
|
||||
foreach ($this->cols as $index => $column) {
|
||||
if ($type === $column->getType()) {
|
||||
$indices[$index] = $column;
|
||||
}
|
||||
}
|
||||
|
||||
return $indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of columns in the DataTable
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColumnCount()
|
||||
{
|
||||
return count($this->cols);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label of a column based on it's index.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param int $index
|
||||
* @return string
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnIndex
|
||||
*/
|
||||
public function getColumnLabel($index)
|
||||
{
|
||||
return $this->getColumn($index)->getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of a column based on it's index.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param int $index
|
||||
* @return string
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnIndex
|
||||
*/
|
||||
public function getColumnType($index)
|
||||
{
|
||||
return $this->getColumn($index)->getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the types of columns currently defined.
|
||||
*
|
||||
* @since 2.5.2
|
||||
* @return string[]
|
||||
*/
|
||||
public function getColumnTypes()
|
||||
{
|
||||
foreach ($this->cols as $column) {
|
||||
$colTypes[] = $column->getType();
|
||||
}
|
||||
|
||||
return $colTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the labels of columns currently defined.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @return string[]
|
||||
*/
|
||||
public function getColumnLabels()
|
||||
{
|
||||
foreach ($this->cols as $column) {
|
||||
$colTypes[] = $column->getLabel();
|
||||
}
|
||||
|
||||
return $colTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the formatted columns in an array from the DataTable
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @return \Khill\Lavacharts\DataTables\Columns\Column[]
|
||||
*/
|
||||
public function getFormattedColumns()
|
||||
{
|
||||
$columns = [];
|
||||
|
||||
foreach ($this->cols as $index => $column) {
|
||||
if ($column->isFormatted()) {
|
||||
$columns[$index] = $column;
|
||||
}
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Boolean value if there are any formatted columns
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFormattedColumns()
|
||||
{
|
||||
return count($this->getFormattedColumns()) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the DataTable to JSON
|
||||
*
|
||||
* Will include formats if defined
|
||||
*
|
||||
* @return string JSON representation of the DataTable.
|
||||
*/
|
||||
public function toJson()
|
||||
{
|
||||
if ($this->hasFormattedColumns()) {
|
||||
$formats = [];
|
||||
|
||||
foreach ($this->getFormattedColumns() as $index => $column) {
|
||||
$format = $column->getFormat();
|
||||
|
||||
$formats[] = [
|
||||
'index' => $index,
|
||||
'type' => $format->getType(),
|
||||
'config' => $format
|
||||
];
|
||||
}
|
||||
|
||||
return json_encode([
|
||||
'data' => $this,
|
||||
'formats' => $formats
|
||||
]);
|
||||
} else {
|
||||
return json_encode($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom serialization of the DataTable.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'cols' => $this->cols,
|
||||
'rows' => $this->rows,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to isNonEmpty if a number is a valid column index of the DataTable
|
||||
*
|
||||
* @access protected
|
||||
* @param int $index
|
||||
* @return void
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnIndex
|
||||
*/
|
||||
protected function indexCheck($index)
|
||||
{
|
||||
if (is_int($index) === false || isset($this->cols[$index]) === false) {
|
||||
throw new InvalidColumnIndex($index, count($this->cols));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips all the data (rows) from the DataTable
|
||||
*
|
||||
* @access protected
|
||||
* @since 3.0.0
|
||||
* @return self
|
||||
*/
|
||||
protected function stripRows()
|
||||
{
|
||||
$this->rows = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the variable against the built-in list of valid php timezones.
|
||||
*
|
||||
* Returns true if in the list, otherwise false.
|
||||
*
|
||||
* @param string $tz
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidTimezone($tz) {
|
||||
if (! is_string($tz)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$timezones = timezone_identifiers_list();
|
||||
$timezones = array_map('strtolower',$timezones);
|
||||
|
||||
return in_array(strtolower($tz), $timezones, true);
|
||||
}
|
||||
|
||||
}
|
||||
29
vendor/khill/lavacharts/src/DataTables/Formats/ArrowFormat.php
vendored
Normal file
29
vendor/khill/lavacharts/src/DataTables/Formats/ArrowFormat.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Formats;
|
||||
|
||||
/**
|
||||
* Class ArrowFormat
|
||||
*
|
||||
* Adds an up or down arrow to a numeric cell, depending on whether the value
|
||||
* is above or below a specified base value. If equal to the base value, no arrow is shown.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Formats
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @see https://developers.google.com/chart/interactive/docs/reference#arrowformatter
|
||||
*/
|
||||
class ArrowFormat extends Format
|
||||
{
|
||||
/**
|
||||
* Type of format object
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'ArrowFormat';
|
||||
}
|
||||
29
vendor/khill/lavacharts/src/DataTables/Formats/BarFormat.php
vendored
Normal file
29
vendor/khill/lavacharts/src/DataTables/Formats/BarFormat.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Formats;
|
||||
|
||||
/**
|
||||
* Class BarFormat
|
||||
*
|
||||
* Adds a colored bar to a numeric cell indicating whether the cell value
|
||||
* is above or below a specified base value.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Formats
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @see https://developers.google.com/chart/interactive/docs/reference#barformatter
|
||||
*/
|
||||
class BarFormat extends Format
|
||||
{
|
||||
/**
|
||||
* Type of format object
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'BarFormat';
|
||||
}
|
||||
28
vendor/khill/lavacharts/src/DataTables/Formats/DateFormat.php
vendored
Normal file
28
vendor/khill/lavacharts/src/DataTables/Formats/DateFormat.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Formats;
|
||||
|
||||
/**
|
||||
* Class DateFormat
|
||||
*
|
||||
* Formats date values in the datatable for display.
|
||||
* Added to columns during column definition.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Formats
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @see https://developers.google.com/chart/interactive/docs/reference#dateformatter
|
||||
*/
|
||||
class DateFormat extends Format
|
||||
{
|
||||
/**
|
||||
* Type of format object
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'DateFormat';
|
||||
}
|
||||
70
vendor/khill/lavacharts/src/DataTables/Formats/Format.php
vendored
Normal file
70
vendor/khill/lavacharts/src/DataTables/Formats/Format.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Formats;
|
||||
|
||||
use Khill\Lavacharts\Support\Contracts\VisualizationInterface;
|
||||
use Khill\Lavacharts\Support\Customizable;
|
||||
use Khill\Lavacharts\Support\Contracts\JsonableInterface;
|
||||
|
||||
/**
|
||||
* Class Format
|
||||
*
|
||||
* The base class for the individual format objects, providing common
|
||||
* functions to the child objects.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Formats
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @since 3.0.0
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Format extends Customizable implements JsonableInterface
|
||||
{
|
||||
/**
|
||||
* Static method for creating new format objects.
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $options
|
||||
* @return \Khill\Lavacharts\DataTables\Formats\Format
|
||||
*/
|
||||
public static function create($type, array $options = [])
|
||||
{
|
||||
$format = __NAMESPACE__ . '\\' . $type;
|
||||
|
||||
return new $format($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the format type.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return static::TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON representation of the Format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toJson()
|
||||
{
|
||||
return json_encode($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Javascript representation of the Format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJsClass()
|
||||
{
|
||||
return 'google.visualization.' . static::TYPE;
|
||||
}
|
||||
}
|
||||
28
vendor/khill/lavacharts/src/DataTables/Formats/NumberFormat.php
vendored
Normal file
28
vendor/khill/lavacharts/src/DataTables/Formats/NumberFormat.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Formats;
|
||||
|
||||
/**
|
||||
* NumberFormat Class
|
||||
*
|
||||
* Formats number values in the datatable for display.
|
||||
* Added to columns during column definition.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Formats
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @see https://developers.google.com/chart/interactive/docs/reference#numberformatter
|
||||
*/
|
||||
class NumberFormat extends Format
|
||||
{
|
||||
/**
|
||||
* Type of format object
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE = 'NumberFormat';
|
||||
}
|
||||
37
vendor/khill/lavacharts/src/DataTables/Rows/NullRow.php
vendored
Normal file
37
vendor/khill/lavacharts/src/DataTables/Rows/NullRow.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Rows;
|
||||
|
||||
use Khill\Lavacharts\Exceptions\InvalidParamType;
|
||||
|
||||
/**
|
||||
* NullRow Object
|
||||
*
|
||||
* The null row object is used to add an empty row to the datatable.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Rows
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class NullRow extends Row
|
||||
{
|
||||
/**
|
||||
* Creates a new NullRow object
|
||||
*
|
||||
* @param int $numOfCols Number of null columns to create.
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidParamType
|
||||
*/
|
||||
public function __construct($numOfCols)
|
||||
{
|
||||
if (is_int($numOfCols) === false) {
|
||||
throw new InvalidParamType($numOfCols, 'integer');
|
||||
}
|
||||
|
||||
parent::__construct(array_fill(0, $numOfCols, null));
|
||||
}
|
||||
}
|
||||
201
vendor/khill/lavacharts/src/DataTables/Rows/Row.php
vendored
Normal file
201
vendor/khill/lavacharts/src/DataTables/Rows/Row.php
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Rows;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\DataTables\Cells\NullCell;
|
||||
use Khill\Lavacharts\Values\StringValue;
|
||||
use Khill\Lavacharts\DataTables\Cells\Cell;
|
||||
use Khill\Lavacharts\DataTables\Cells\DateCell;
|
||||
use Khill\Lavacharts\DataTables\DataTable;
|
||||
use Khill\Lavacharts\Exceptions\InvalidCellCount;
|
||||
use Khill\Lavacharts\Exceptions\InvalidColumnIndex;
|
||||
use Khill\Lavacharts\Exceptions\InvalidDate;
|
||||
use Khill\Lavacharts\Exceptions\InvalidRowDefinition;
|
||||
|
||||
/**
|
||||
* Row Object
|
||||
*
|
||||
* The row object contains all the data for a row, stored in an array, indexed by columns.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Rows
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class Row implements \ArrayAccess, \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Row values
|
||||
*
|
||||
* @var \Khill\Lavacharts\DataTables\Cells\Cell[]
|
||||
*/
|
||||
protected $values;
|
||||
|
||||
/**
|
||||
* Creates a new Row object with the given values from an array.
|
||||
*
|
||||
* While iterating through the array, if the value is a...
|
||||
* - Carbon instance, create a DateCell
|
||||
* - null value, create a NullCell
|
||||
* - primitive value, create a Cell
|
||||
* - Cell, pass it through
|
||||
*
|
||||
* @param array $valueArray Array of row values.
|
||||
*/
|
||||
public function __construct($valueArray)
|
||||
{
|
||||
$this->values = array_map(function ($cellValue) {
|
||||
if ($cellValue instanceof Carbon) {
|
||||
return new DateCell($cellValue);
|
||||
}
|
||||
|
||||
if (is_null($cellValue)) {
|
||||
return new NullCell();
|
||||
}
|
||||
|
||||
if ($cellValue instanceof Cell) {
|
||||
return $cellValue;
|
||||
}
|
||||
|
||||
return new Cell($cellValue);
|
||||
}, $valueArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Row object from an array of values.
|
||||
*
|
||||
* @param \Khill\Lavacharts\DataTables\DataTable $datatable
|
||||
* @param array $valueArray Array of values to assign to the row.
|
||||
* @return \Khill\Lavacharts\DataTables\Rows\Row
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidCellCount
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidDate
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidRowDefinition
|
||||
*/
|
||||
public static function create(DataTable $datatable, $valueArray)
|
||||
{
|
||||
if ($valueArray !== null && is_array($valueArray) === false) {
|
||||
throw new InvalidRowDefinition($valueArray);
|
||||
}
|
||||
|
||||
if ($valueArray === null || is_array($valueArray) && empty($valueArray)) {
|
||||
return new NullRow($datatable->getColumnCount());
|
||||
}
|
||||
|
||||
$cellCount = count($valueArray);
|
||||
$columnCount = $datatable->getColumnCount();
|
||||
|
||||
if ($cellCount > $columnCount) {
|
||||
throw new InvalidCellCount($cellCount, $columnCount);
|
||||
}
|
||||
|
||||
$columnTypes = $datatable->getColumnTypes();
|
||||
$dateTimeFormat = $datatable->getDateTimeFormat();
|
||||
|
||||
$rowData = [];
|
||||
|
||||
foreach ($valueArray as $index => $cellValue) {
|
||||
if ((bool) preg_match('/date|datetime|timeofday/', $columnTypes[$index]) === true) {
|
||||
if (StringValue::isNonEmpty($cellValue) === false &&
|
||||
$cellValue instanceof Carbon === false &&
|
||||
$cellValue !== null
|
||||
) {
|
||||
throw new InvalidDate($cellValue);
|
||||
}
|
||||
|
||||
if ($cellValue === null) {
|
||||
$rowData[] = new NullCell;
|
||||
} else if ($cellValue instanceof Carbon) {
|
||||
$rowData[] = new DateCell($cellValue);
|
||||
} else {
|
||||
if (isset($dateTimeFormat)) {
|
||||
$rowData[] = DateCell::parseString($cellValue, $dateTimeFormat);
|
||||
} else {
|
||||
$rowData[] = DateCell::parseString($cellValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (is_array($cellValue) === true) {
|
||||
$cell = new \ReflectionClass(
|
||||
'Khill\\Lavacharts\\DataTables\\Cells\\Cell'
|
||||
);
|
||||
|
||||
$rowData[] = $cell->newInstanceArgs($cellValue);
|
||||
} else {
|
||||
$rowData[] = $cellValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new self($rowData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a column value from the Row.
|
||||
*
|
||||
* @param int $columnIndex Column value to fetch from the row.
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidColumnIndex
|
||||
* @return \Khill\Lavacharts\DataTables\Cells\Cell
|
||||
*/
|
||||
public function getCell($columnIndex)
|
||||
{
|
||||
if (is_int($columnIndex) === false || isset($this->values[$columnIndex]) === false) {
|
||||
throw new InvalidColumnIndex($columnIndex, count($this->values));
|
||||
}
|
||||
|
||||
return $this->values[$columnIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom json serialization of the row.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return ['c' => $this->values];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->values[] = $value;
|
||||
} else {
|
||||
$this->values[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->values[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->values[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $offset
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->values[$offset]) ? $this->values[$offset] : null;
|
||||
}
|
||||
}
|
||||
98
vendor/khill/lavacharts/src/DataTables/Rows/RowFactory.php
vendored
Normal file
98
vendor/khill/lavacharts/src/DataTables/Rows/RowFactory.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\DataTables\Rows;
|
||||
|
||||
use ArrayAccess;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\DataTables\DataTable;
|
||||
use Khill\Lavacharts\DataTables\Cells\DateCell;
|
||||
use Khill\Lavacharts\Exceptions\InvalidCellCount;
|
||||
use Khill\Lavacharts\Exceptions\InvalidRowDefinition;
|
||||
use Khill\Lavacharts\Support\Traits\ParameterValidatorsTrait as ParameterValidators;
|
||||
|
||||
/**
|
||||
* RowFactory Class
|
||||
*
|
||||
* The RowFactory creates new rows for the DataTables.
|
||||
*
|
||||
*
|
||||
* @package Khill\Lavacharts\DataTables\Rows
|
||||
* @since 3.0.0
|
||||
* @author Kevin Hill <kevinkhill@gmail.com>
|
||||
* @copyright (c) 2017, KHill Designs
|
||||
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
|
||||
* @link http://lavacharts.com Official Docs Site
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
class RowFactory
|
||||
{
|
||||
use ParameterValidators;
|
||||
|
||||
/**
|
||||
* DataTable to reference when creating new rows.
|
||||
*
|
||||
* @var \Khill\Lavacharts\DataTables\DataTable
|
||||
*/
|
||||
private $datatable;
|
||||
|
||||
/**
|
||||
* Creates a new RowFactory instance.
|
||||
*
|
||||
* @access public
|
||||
* @param \Khill\Lavacharts\DataTables\DataTable $datatable
|
||||
*/
|
||||
public function __construct(DataTable $datatable)
|
||||
{
|
||||
$this->datatable = $datatable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Row object from a collection of values.
|
||||
*
|
||||
* @param array|ArrayAccess $rowDef Collection of values to assign to the row.
|
||||
* @return \Khill\Lavacharts\DataTables\Rows\Row
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidCellCount
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidDateTimeString
|
||||
* @throws \Khill\Lavacharts\Exceptions\InvalidRowDefinition
|
||||
*/
|
||||
public function create($rowDef)
|
||||
{
|
||||
if ($rowDef !== null && $this->behavesAsArray($rowDef)) {
|
||||
throw new InvalidRowDefinition($rowDef);
|
||||
}
|
||||
|
||||
if ($rowDef === null || ($this->behavesAsArray($rowDef) && empty($rowDef))) {
|
||||
return new NullRow($this->datatable->getColumnCount());
|
||||
}
|
||||
|
||||
$cellCount = count($rowDef);
|
||||
$columnCount = $this->datatable->getColumnCount();
|
||||
|
||||
if ($cellCount > $columnCount) {
|
||||
throw new InvalidCellCount($cellCount, $columnCount);
|
||||
}
|
||||
|
||||
$columnTypes = $this->datatable->getColumnTypes();
|
||||
$dateTimeFormat = $this->datatable->getDateTimeFormat();
|
||||
|
||||
$rowData = [];
|
||||
|
||||
foreach ($rowDef as $index => $cell) {
|
||||
if ((bool) preg_match('/date|datetime|timeofday/', $columnTypes[$index]) === true) {
|
||||
if ($cell instanceof Carbon) {
|
||||
$rowData[] = new DateCell($cell);
|
||||
} else {
|
||||
if (isset($dateTimeFormat)) {
|
||||
$rowData[] = DateCell::parseString($cell, $dateTimeFormat);
|
||||
} else {
|
||||
$rowData[] = DateCell::parseString($cell);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$rowData[] = $cell;
|
||||
}
|
||||
}
|
||||
|
||||
return new Row($rowData);
|
||||
}
|
||||
}
|
||||
13
vendor/khill/lavacharts/src/Exceptions/ChartNotFound.php
vendored
Normal file
13
vendor/khill/lavacharts/src/Exceptions/ChartNotFound.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class ChartNotFound extends LavaException
|
||||
{
|
||||
public function __construct($type, $label)
|
||||
{
|
||||
$message = "$type('$label') was not found.";
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
13
vendor/khill/lavacharts/src/Exceptions/DashboardNotFound.php
vendored
Normal file
13
vendor/khill/lavacharts/src/Exceptions/DashboardNotFound.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class DashboardNotFound extends LavaException
|
||||
{
|
||||
public function __construct($label)
|
||||
{
|
||||
$message = "Dashboard('$label') was not found.";
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
15
vendor/khill/lavacharts/src/Exceptions/DataTableNotFound.php
vendored
Normal file
15
vendor/khill/lavacharts/src/Exceptions/DataTableNotFound.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
use Khill\Lavacharts\Charts\Chart;
|
||||
|
||||
class DataTableNotFound extends LavaException
|
||||
{
|
||||
public function __construct(Chart $chart)
|
||||
{
|
||||
$message = $chart->getType() . '(' . $chart->getLabel() . ') has no DataTable.';
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
15
vendor/khill/lavacharts/src/Exceptions/ElementIdException.php
vendored
Normal file
15
vendor/khill/lavacharts/src/Exceptions/ElementIdException.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
use Khill\Lavacharts\Support\Contracts\RenderableInterface as Renderable;
|
||||
|
||||
class ElementIdException extends RenderingException
|
||||
{
|
||||
public function __construct(Renderable $renderable)
|
||||
{
|
||||
$message = 'Cannot render without an elementId.';
|
||||
|
||||
parent::__construct($renderable, $message);
|
||||
}
|
||||
}
|
||||
13
vendor/khill/lavacharts/src/Exceptions/InvalidBindings.php
vendored
Normal file
13
vendor/khill/lavacharts/src/Exceptions/InvalidBindings.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidBindings extends LavaException
|
||||
{
|
||||
public function __construct($code = 0)
|
||||
{
|
||||
$message = 'You must bind ControlWrappers to ChartWrappers, as singles or arrays.';
|
||||
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
}
|
||||
14
vendor/khill/lavacharts/src/Exceptions/InvalidCellCount.php
vendored
Normal file
14
vendor/khill/lavacharts/src/Exceptions/InvalidCellCount.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidCellCount extends LavaException
|
||||
{
|
||||
public function __construct($cellCount, $columnCount, $code = 0)
|
||||
{
|
||||
$message = 'Invalid number of cells, must be less than or equal to the number of columns. ';
|
||||
$message .= "(cells: $cellCount > columns: $columnCount)";
|
||||
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
}
|
||||
18
vendor/khill/lavacharts/src/Exceptions/InvalidChartType.php
vendored
Normal file
18
vendor/khill/lavacharts/src/Exceptions/InvalidChartType.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
use Khill\Lavacharts\Charts\ChartFactory;
|
||||
|
||||
class InvalidChartType extends LavaException
|
||||
{
|
||||
public function __construct($invalidChart)
|
||||
{
|
||||
$badChart = (string) $invalidChart;
|
||||
|
||||
$message = "'$badChart' is not a valid chart type, must be one of ";
|
||||
$message .= '[ ' . implode(' | ', ChartFactory::getChartTypes()) . ']';
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
13
vendor/khill/lavacharts/src/Exceptions/InvalidChartWrapperParams.php
vendored
Normal file
13
vendor/khill/lavacharts/src/Exceptions/InvalidChartWrapperParams.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidChartWrapperParams extends LavaException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$message = "Invalid ChartWrapper parameters, must be (Chart, string)";
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
14
vendor/khill/lavacharts/src/Exceptions/InvalidColumnDefinition.php
vendored
Normal file
14
vendor/khill/lavacharts/src/Exceptions/InvalidColumnDefinition.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidColumnDefinition extends LavaException
|
||||
{
|
||||
public function __construct($invalidCol)
|
||||
{
|
||||
$msg = gettype($invalidCol);
|
||||
$msg.= " is not valid for a column definition, must be an array.";
|
||||
|
||||
parent::__construct($msg);
|
||||
}
|
||||
}
|
||||
13
vendor/khill/lavacharts/src/Exceptions/InvalidColumnFormat.php
vendored
Normal file
13
vendor/khill/lavacharts/src/Exceptions/InvalidColumnFormat.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidColumnFormat extends LavaException
|
||||
{
|
||||
public function __construct($format)
|
||||
{
|
||||
parent::__construct(
|
||||
'"'. (string) $format . '" is not a valid format.'
|
||||
);
|
||||
}
|
||||
}
|
||||
17
vendor/khill/lavacharts/src/Exceptions/InvalidColumnIndex.php
vendored
Normal file
17
vendor/khill/lavacharts/src/Exceptions/InvalidColumnIndex.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidColumnIndex extends LavaException
|
||||
{
|
||||
public function __construct($columnIndex, $count)
|
||||
{
|
||||
if (is_int($columnIndex)) {
|
||||
$message = $columnIndex .' is an invalid column index, must be 0 - '.($count-1).'.';
|
||||
} else {
|
||||
$message = gettype($columnIndex) . ' is an invalid column index, must an (int), 0 - '.($count-1).'.';
|
||||
}
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
21
vendor/khill/lavacharts/src/Exceptions/InvalidColumnRole.php
vendored
Normal file
21
vendor/khill/lavacharts/src/Exceptions/InvalidColumnRole.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
use Khill\Lavacharts\Values\Role;
|
||||
|
||||
class InvalidColumnRole extends LavaException
|
||||
{
|
||||
public function __construct($invalidRole)
|
||||
{
|
||||
if (is_string($invalidRole)) {
|
||||
$message = "'$invalidRole' is not a valid column role, must be one of ";
|
||||
} else {
|
||||
$message = gettype($invalidRole) . ' is not a valid column role, must one of ';
|
||||
}
|
||||
|
||||
$message .= '[ ' . implode(' | ', Role::$roles) . ' ]';
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
19
vendor/khill/lavacharts/src/Exceptions/InvalidColumnType.php
vendored
Normal file
19
vendor/khill/lavacharts/src/Exceptions/InvalidColumnType.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidColumnType extends LavaException
|
||||
{
|
||||
public function __construct($invalidType, $acceptedTypes, $code = 0)
|
||||
{
|
||||
if (is_string($invalidType)) {
|
||||
$message = "$invalidType is not a valid column type.";
|
||||
} else {
|
||||
$message = gettype($invalidType) . ' is not a valid column type.';
|
||||
}
|
||||
|
||||
$message .= ' Must one of [ ' . implode(' | ', $acceptedTypes) . ' ]';
|
||||
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
}
|
||||
16
vendor/khill/lavacharts/src/Exceptions/InvalidConfigProperty.php
vendored
Normal file
16
vendor/khill/lavacharts/src/Exceptions/InvalidConfigProperty.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidConfigProperty extends LavaException
|
||||
{
|
||||
public function __construct($class, $function, $rejectedProp, $acceptedProps, $code = 0)
|
||||
{
|
||||
natcasesort($acceptedProps);
|
||||
|
||||
$message = '"'.$rejectedProp.'" is not a valid property for ' . $class . '->' . $function . ', ';
|
||||
$message .= 'must be one of [ ' . implode(' | ', $acceptedProps) . ' ]';
|
||||
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
}
|
||||
17
vendor/khill/lavacharts/src/Exceptions/InvalidConfigValue.php
vendored
Normal file
17
vendor/khill/lavacharts/src/Exceptions/InvalidConfigValue.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidConfigValue extends LavaException
|
||||
{
|
||||
public function __construct($function, $requiredType, $extra = '')
|
||||
{
|
||||
$message = "The value for $function must be of type ($requiredType).";
|
||||
|
||||
if ($extra !== '') {
|
||||
$message .= ' ' . $extra;
|
||||
}
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
13
vendor/khill/lavacharts/src/Exceptions/InvalidControlWrapperParams.php
vendored
Normal file
13
vendor/khill/lavacharts/src/Exceptions/InvalidControlWrapperParams.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Khill\Lavacharts\Exceptions;
|
||||
|
||||
class InvalidControlWrapperParams extends LavaException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$message = "Invalid ControlWrapper parameters, must be (Filter, string";
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user