├── CHANGELOG.md ├── CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE.md ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── composer.json ├── src ├── ChartManager.php ├── Contracts │ └── Factory.php ├── Facades │ └── ChartFacade.php ├── LaravelGoogleChartServiceProvider.php └── resources │ └── views │ ├── bar-chart.blade.php │ ├── bubble-chart.blade.php │ ├── candlestick-chart.blade.php │ ├── combo-chart.blade.php │ ├── includes │ └── package_loader.blade.php │ ├── piechart-chart.blade.php │ ├── scatter-chart.blade.php │ ├── stacked-bar-chart.blade.php │ ├── steppedarea-chart.blade.php │ ├── treemap-chart.blade.php │ └── wordtree-chart.blade.php └── tests ├── BarChartTest.php ├── BubbleChartTest.php ├── CandlestickChartTest.php ├── ComboChartTest.php ├── PieChartTest.php ├── ScatterChartTest.php ├── StackedChartTest.php ├── SteppedAreaChartTest.php ├── TreeMapChartTest.php └── WordTreeChartTest.php /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All Notable changes to `laravel-google-chart` will be documented in this file. 4 | 5 | Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. 6 | 7 | ## NEXT - YYYY-MM-DD 8 | 9 | ### Added 10 | - Nothing 11 | 12 | ### Deprecated 13 | - Outdated dependencies. 14 | 15 | ### Fixed 16 | - Updated outdated dependencies. 17 | 18 | ### Removed 19 | - Nothing 20 | 21 | ### Security 22 | - Nothing 23 | -------------------------------------------------------------------------------- /CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at `contact@thephpleague.com`. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/:vendor/:package_name). 6 | 7 | 8 | ## Pull Requests 9 | 10 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). 11 | 12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 13 | 14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 15 | 16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 17 | 18 | - **Create feature branches** - Don't ask us to pull from your master branch. 19 | 20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 21 | 22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 23 | 24 | 25 | ## Running Tests 26 | 27 | ``` bash 28 | $ composer test 29 | ``` 30 | 31 | 32 | **Happy coding**! 33 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Detailed description 4 | 5 | Provide a detailed description of the change or addition you are proposing. 6 | 7 | Make it clear if the issue is a bug, an enhancement or just a question. 8 | 9 | ## Context 10 | 11 | Why is this change important to you? How would you use it? 12 | 13 | How can it benefit other users? 14 | 15 | ## Possible implementation 16 | 17 | Not obligatory, but suggest an idea for implementing addition or change. 18 | 19 | ## Your environment 20 | 21 | Include as many relevant details about the environment you experienced the bug in and how to reproduce it. 22 | 23 | * Version used (e.g. PHP 5.6, HHVM 3): 24 | * Operating system and version (e.g. Ubuntu 16.04, Windows 7): 25 | * Link to your project: 26 | * ... 27 | * ... 28 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) 2016 :author_name <:author_email> 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | Describe your changes in detail. 6 | 7 | ## Motivation and context 8 | 9 | Why is this change required? What problem does it solve? 10 | 11 | If it fixes an open issue, please link to the issue here (if you write `fixes #num` 12 | or `closes #num`, the issue will be automatically closed when the pull is accepted.) 13 | 14 | ## How has this been tested? 15 | 16 | Please describe in detail how you tested your changes. 17 | 18 | Include details of your testing environment, and the tests you ran to 19 | see how your change affects other areas of the code, etc. 20 | 21 | ## Screenshots (if appropriate) 22 | 23 | ## Types of changes 24 | 25 | What types of changes does your code introduce? Put an `x` in all the boxes that apply: 26 | - [ ] Bug fix (non-breaking change which fixes an issue) 27 | - [ ] New feature (non-breaking change which adds functionality) 28 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 29 | 30 | ## Checklist: 31 | 32 | Go over all the following points, and put an `x` in all the boxes that apply. 33 | 34 | Please, please, please, don't send your pull request until all of the boxes are ticked. 35 | 36 | - [ ] I have read the **[CONTRIBUTING](CONTRIBUTING.md)** document. 37 | - [ ] My pull request addresses exactly one patch/feature. 38 | - [ ] I have created a branch for this patch/feature. 39 | - [ ] Each individual commit in the pull request is meaningful. 40 | - [ ] I have added tests to cover my changes. 41 | - [ ] All new and existing tests passed. 42 | - [ ] If my change requires a change to the documentation, I have updated it accordingly. 43 | - [ ] My code follows the code style of this project. 44 | 45 | If you're unsure about any of these, don't hesitate to ask. We're here to help! 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # laravel-google-chart 2 | 3 | [![Latest Version on Packagist][ico-version]][link-packagist] 4 | [![Software License][ico-license]](LICENSE.md) 5 | [![Total Downloads][ico-downloads]][link-downloads] 6 | 7 | 8 | This package offers simple and easy integration of google charts with laravel . 9 | 10 | ## Features: 11 | -Fast and simple . Also you can provide Google chart options to documneted on google Chart API by creating a multidiemsional PHP array. 12 | - Multiple Chart of same and different types can be loaded on same page. 13 | 14 | Credit: Thanks to google chart API 15 | 16 | Chats introduced: 17 | 18 | - Bar Chart 19 | - Bubble Chart 20 | - Candlestick Chart 21 | - Combo Chart 22 | - Piechart Chart 23 | - Scatter Chart 24 | - Stepped Area Chart 25 | - Tree Map Chart 26 | - Word Tree Chart 27 | 28 | 29 | 30 | ## Install 31 | 32 | Via Composer 33 | 34 | ``` bash 35 | $ composer require scopdrag/laravel-google-chart 36 | ``` 37 | Use this command to publish charts views. 38 | 39 | ``` bash 40 | $ php artisan vendor:publish 41 | ``` 42 | 43 | 44 | 45 | Registering provider 46 | 47 | Add following line to you config/app.php providers array 48 | ``` 49 | 50 | Scopdrag\LaravelGoogleChart\LaravelGoogleChartServiceProvider::class, 51 | 52 | ``` 53 | 54 | 55 | 56 | ## Usage 57 | Use this code in your controller file and pass cols, rows and options to view 58 | 59 | Add Google chart loader script file in tag of you webpage 60 | 61 | ``` 62 | 63 | ``` 64 | 65 | 66 | 67 | ``` php 68 | $options = [ 69 | 'title' => 'Population of Largest U.S. Cities', 70 | 'chartArea' => ['width' => '50%'], 71 | 'hAxis' => [ 72 | 'title' => 'Total Population', 73 | 'minValue' => 0 74 | ], 75 | 'vAxis' => [ 76 | 'title' => 'City' 77 | ], 78 | 'bars' => 'horizontal', //required if using material chart 79 | 'axes' => [ 80 | 'y' => [0 => ['side' => 'right']] 81 | ] 82 | ]; 83 | 84 | $cols = ['City', '2010 Population', '2000 PopulaÎtions']; 85 | $rows = [ 86 | ['New York City, NY', 8175000, 8008000], 87 | ['Los Angeles, CA', 3792000, 3694000], 88 | ['Chicago, IL', 2695000, 2896000], 89 | ['Houston, TX', 2099000, 1953000], 90 | ['Philadelphia, PA', 1526000, 1517000] 91 | ]; 92 | 93 | ``` 94 | Use this in your Views/balade File 95 | 96 | ``` 97 | {!!ChartManager::setChartType('bar-chart') 98 | ->setOptions($options) 99 | ->setCols($cols) 100 | ->setRows($rows) 101 | ->render()!!} 102 | ``` 103 | 104 | 105 | ## OR You can directly use in view file 106 | Use this code on your views/blade file 107 | ``` php 108 | $options = [ 109 | 'title' => 'Population of Largest U.S. Cities', 110 | 'chartArea' => ['width' => '50%'], 111 | 'hAxis' => [ 112 | 'title' => 'Total Population', 113 | 'minValue' => 0 114 | ], 115 | 'vAxis' => [ 116 | 'title' => 'City' 117 | ], 118 | 'bars' => 'horizontal', //required if using material chart 119 | 'axes' => [ 120 | 'y' => [0 => ['side' => 'right']] 121 | ] 122 | ]; 123 | 124 | $cols = ['City', '2010 Population', '2000 PopulaÎtions']; 125 | $rows = [ 126 | ['New York City, NY', 8175000, 8008000], 127 | ['Los Angeles, CA', 3792000, 3694000], 128 | ['Chicago, IL', 2695000, 2896000], 129 | ['Houston, TX', 2099000, 1953000], 130 | ['Philadelphia, PA', 1526000, 1517000] 131 | ]; 132 | 133 | 134 | echo ChartManager::setChartType('bar-chart') 135 | ->setOptions($options) 136 | ->setCols($cols) 137 | ->setRows($rows) 138 | ->render(); 139 | ``` 140 | 141 | 142 | 143 | 144 | 145 | 146 | ## Bar chart 147 | ``` php 148 | 149 | 150 | $options = [ 151 | 'title' => 'Population of Largest U.S. Cities', 152 | 'chartArea' => ['width' => '50%'], 153 | 'hAxis' => [ 154 | 'title' => 'Total Population', 155 | 'minValue' => 0 156 | ], 157 | 'vAxis' => [ 158 | 'title' => 'City' 159 | ], 160 | 'bars' => 'horizontal', //required if using material chart 161 | 'axes' => [ 162 | 'y' => [0 => ['side' => 'right']] 163 | ] 164 | ]; 165 | 166 | $cols = ['City', '2010 Population', '2000 PopulaÎtions']; 167 | $rows = [ 168 | ['New York City, NY', 8175000, 8008000], 169 | ['Los Angeles, CA', 3792000, 3694000], 170 | ['Chicago, IL', 2695000, 2896000], 171 | ['Houston, TX', 2099000, 1953000], 172 | ['Philadelphia, PA', 1526000, 1517000] 173 | ]; 174 | 175 | ``` 176 | 177 | blade.php file code 178 | 179 | ``` 180 | {!!ChartManager::setChartType('bar-chart') 181 | ->setOptions($options) 182 | ->setCols($cols) 183 | ->setRows($rows) 184 | ->render()!!} 185 | 186 | ``` 187 | 188 | 189 | ## Coloring bar chart 190 | ``` php 191 | $options = [ 192 | 'title' => 'Population of Largest U.S. Cities', 193 | 'chartArea' => ['width' => '50%'], 194 | 'hAxis' => [ 195 | 'title' => 'Total Population', 196 | 'minValue' => 0 197 | ], 198 | 'vAxis' => [ 199 | 'title' => 'City' 200 | ], 201 | 'bars' => 'horizontal', //required if using material chart 202 | 'axes' => [ 203 | 'y' => [0 => ['side' => 'right']] 204 | ] 205 | ]; 206 | 207 | $cols = ['City', '2010 Population', '2000 PopulaÎtions', ['role' => 'style']]; 208 | $rows = [ 209 | ['New York City, NY', 8175000, 8008000, '#b87333'], 210 | ['Los Angeles, CA', 3792000, 3694000, 'silver'], 211 | ['Chicago, IL', 2695000, 2896000, 'gold'], 212 | ['Houston, TX', 2099000, 1953000, 'color: #e5e4e2'], 213 | ['Philadelphia, PA', 1526000, 1517000, 'color: #e5e4e2'] 214 | ]; 215 | ``` 216 | 217 | .blade.php file code 218 | 219 | ``` 220 | {!!ChartManager::setChartType('bar-chart') 221 | ->setOptions($options) 222 | ->setCols($cols) 223 | ->setRows($rows) 224 | ->render()!!} 225 | ``` 226 | 227 | 228 | 229 | 230 | ## Stacked Bar Chart 231 | ``` php 232 | $options = [ 233 | 'width' => 800, 234 | 'height' => 400, 235 | 'legend' => ['position' => 'top', 'maxLines' => 3], 236 | 'bars' => ['groupWidth' => '75%'], 237 | 'isStacked' => TRUE 238 | ]; 239 | 240 | 241 | 242 | 243 | $cols = ['Date', 'Fantasy & Sci Fi', 'Romance', 'Mystery/Crime', 'General', 244 | 'Western', 'Literature', ['role' => 'annotation']]; 245 | $rows = [ 246 | ['2010', 10, 24, 20, 32, 18, 5, ''], 247 | ['2020', 16, 22, 23, 30, 16, 9, ''], 248 | ['2030', 28, 19, 29, 30, 12, 13, ''] 249 | ]; 250 | 251 | ``` 252 | 253 | .blade.php code 254 | ``` 255 | {!!ChartManager::setChartType('bar-chart') 256 | ->setOptions($options) 257 | ->setCols($cols) 258 | ->setRows($rows) 259 | ->render()!!} 260 | ``` 261 | 262 | 263 | ##Bubble Chart 264 | 265 | ``` php 266 | $cols = ['ID', 'Life Expectancy', 'Fertility Rate', 'Region', 'Population']; 267 | $rows = [ 268 | ['CAN', 80.66, 1.67, 'North America', 33739900], 269 | ['DEU', 79.84, 1.36, 'Europe', 81902307], 270 | ['DNK', 78.6, 1.84, 'Europe', 5523095], 271 | ['EGY', 72.73, 2.78, 'Middle East', 79716203], 272 | ['GBR', 80.05, 2.00, 'Europe', 61801570], 273 | ['IRN', 72.49, 1.7, 'Middle East', 73137148], 274 | ['IRQ', 68.09, 4.77, 'Middle East', 31090763], 275 | ['ISR', 81.55, 2.96, 'Middle East', 7485600], 276 | ['RUS', 68.6, 1.54, 'Europe', 141850000], 277 | ['USA', 78.09, 2.05, 'North America', 307007000] 278 | ]; 279 | 280 | 281 | $options = [ 282 | 'title' => 'Correlation between life expectancy, fertility rate and population of some world countries (2010)', 283 | 'hAxis' => [ 284 | 'title' => 'Life Expectancy', 285 | ], 286 | 'vAxis' => [ 287 | 'title' => 'Fertility Rate' 288 | ], 289 | 'bubble' => 'horizontal', //required if using material chart 290 | 'bubble' => [ 291 | 'textStyle' => ['fontSize' => 11] 292 | ] 293 | ]; 294 | ``` 295 | 296 | .blade.php file code 297 | 298 | ``` 299 | {!!ChartManager::setChartType('bubble-chart') 300 | ->setOptions($options) 301 | ->setCols($cols) 302 | ->setRows($rows) 303 | ->render()!!} 304 | ``` 305 | 306 | 307 | 308 | 309 | ## Candlestick charts 310 | ``` php 311 | 312 | $rows = [ 313 | ['Mon', 20, 28, 38, 45], 314 | ['Tue', 31, 38, 55, 66], 315 | ['Wed', 50, 55, 77, 80], 316 | ['Thu', 77, 77, 66, 50], 317 | ['Fri', 68, 66, 22, 15] 318 | ]; 319 | 320 | 321 | $options = [ 322 | 'legend' => 'none' 323 | ]; 324 | 325 | 326 | $cols =[]; 327 | 328 | ``` 329 | 330 | .blade.php file code 331 | 332 | 333 | ``` 334 | {!!ChartManager::setChartType('candlestick-chart') 335 | ->setOptions($options) 336 | ->setCols($cols) 337 | ->setRows($rows) 338 | ->render()!!} 339 | 340 | ``` 341 | 342 | 343 | 344 | 345 | ## Waterfall charts 346 | 347 | ``` php 348 | $rows = [ 349 | ['Mon', 20, 28, 38, 45], 350 | ['Tue', 31, 38, 55, 66], 351 | ['Wed', 50, 55, 77, 80], 352 | ['Thu', 77, 77, 66, 50], 353 | ['Fri', 68, 66, 22, 15] 354 | ]; 355 | 356 | 357 | $options = [ 358 | 'legend' => 'none', 359 | 'bar' => [ 360 | 'groupWidth' => '100%', // Draw a trendline for data series 0. 361 | ], 362 | 'candlestick' => [ 363 | 'fallingColor' => ['strokeWidth' => 0, 'fill' => '#a52714'], 364 | 'risingColor' => ['strokeWidth' => 0, 'fill' => '#0f9d58'], 365 | ] 366 | ]; 367 | 368 | $cols=[]; 369 | ``` 370 | 371 | 372 | .blade.php code 373 | 374 | ``` 375 | {!!ChartManager::setChartType('candlestick-chart') 376 | ->setOptions($options) 377 | ->setCols($cols) 378 | ->setRows($rows) 379 | ->render()!!} 380 | 381 | ``` 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | ## Combo Chart 391 | 392 | ``` php 393 | $cols = ['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Average']; 394 | $rows = [ 395 | ['2004/05', 165, 938, 522, 998, 450, 614.6], 396 | ['2005/06', 135, 1120, 599, 1268, 288, 682], 397 | ['2006/07', 157, 1167, 587, 807, 397, 623], 398 | ['2007/08', 139, 1110, 615, 968, 215, 609.4], 399 | ['2008/09', 136, 691, 629, 1026, 366, 569.6] 400 | ]; 401 | 402 | $options = [ 403 | 'title' => 'Monthly Coffee Production by Country', 404 | 'hAxis' => [ 405 | 'title' => 'Cups', 406 | ], 407 | 'vAxis' => [ 408 | 'title' => 'Month' 409 | ], 410 | 'seriesType' => 'bars', //required if using material chart 411 | 'series' => [ 412 | '5' => ['type' => 'line'] 413 | ] 414 | ]; 415 | ``` 416 | 417 | 418 | .blade.php file code 419 | 420 | ``` 421 | {!!ChartManager::setChartType('combo-chart') 422 | ->setOptions($options) 423 | ->setCols($cols) 424 | ->setRows($rows) 425 | ->render()!!} 426 | ``` 427 | 428 | 429 | 430 | 431 | ## Pie Chart 432 | 433 | ``` php 434 | $cols = ['Major', 'Degrees']; 435 | $rows = [ 436 | ['Business', 256070], ['Education', 108034], 437 | ['Social Sciences & History', 127101], ['Health', 81863], 438 | ['Psychology', 74194] 439 | ]; 440 | $options = [ 441 | 'pieSliceText' => 'none', 442 | ]; 443 | 444 | $cols =[]; 445 | 446 | ``` 447 | 448 | .blade.php file code 449 | 450 | ``` 451 | {!!ChartManager::setChartType('piechart-chart') 452 | ->setOptions($options) 453 | ->setCols($cols) 454 | ->setRows($rows) 455 | ->render()!!} 456 | ``` 457 | 458 | 459 | 460 | ## 3D Pie Chart 461 | ``` php 462 | $cols = ['Major', 'Degrees']; 463 | $rows = [ 464 | ['Business', 256070], ['Education', 108034], 465 | ['Social Sciences & History', 127101], ['Health', 81863], 466 | ['Psychology', 74194] 467 | ]; 468 | $options = [ 469 | 'pieSliceText' => 'none', 470 | 'title' => 'My Daily Activities', 471 | 'is3D' => true, 472 | ]; 473 | 474 | ``` 475 | 476 | .blade.php file code 477 | 478 | ``` 479 | 480 | 481 | {!!ChartManager::setChartType('piechart-chart') 482 | ->setOptions($options) 483 | ->setCols($cols) 484 | ->setRows($rows) 485 | ->render()!!} 486 | ``` 487 | 488 | 489 | ## ScatterChart 490 | 491 | ``` php 492 | $cols = ['Age', 'Weight']; 493 | $rows = [ 494 | [ 8, 12], 495 | [ 4, 5.5], 496 | [ 11, 14], 497 | [ 4, 5], 498 | [ 3, 3.5], 499 | [ 6.5, 7] 500 | ]; 501 | 502 | 503 | $options = [ 504 | 'title' => 'Age vs. Weight comparison', 505 | 'hAxis' => [ 506 | 'title' => 'Age', 507 | 'minValue' => 0, 508 | 'maxValue' => 15 509 | ], 510 | 'vAxis' => [ 511 | 'title' => 'Weight', 512 | 'minValue' => 0, 513 | 'maxValue' => 15 514 | ], 515 | 'legend' => 'none', 516 | ]; 517 | ``` 518 | 519 | .blade.php file code 520 | 521 | ``` 522 | {!!ChartManager::setChartType('scatter-chart') 523 | ->setOptions($options) 524 | ->setCols($cols) 525 | ->setRows($rows) 526 | ->render()!!} 527 | 528 | ``` 529 | 530 | 531 | ## Stepped Chart 532 | ``` php 533 | $cols = ['Director (Year)', 'Rotten Tomatoes', 'IMDB']; 534 | $rows = [ 535 | ['Alfred Hitchcock (1935)', 8.4, 7.9], 536 | ['Ralph Thomas (1959)', 6.9, 6.5], 537 | ['Don Sharp (1978)', 6.5, 6.4], 538 | ['James Hawes (2008)', 4.4, 6.2] 539 | ]; 540 | 541 | 542 | $options = [ 543 | 'title' => 'The decline of \'The 39 Steps\'', 544 | 'hAxis' => [ 545 | 'title' => 'Accumulated Rating', 546 | ], 547 | 'isStacked' => 'true', 548 | ]; 549 | 550 | ``` 551 | .blade.php file code 552 | 553 | ``` 554 | {!!ChartManager::setChartType('steppedarea-chart') 555 | ->setOptions($options) 556 | ->setCols($cols) 557 | ->setRows($rows) 558 | ->render()!!} 559 | 560 | ``` 561 | 562 | ## Tree Map Charts 563 | 564 | ``` php 565 | $cols = ['Location', 'Parent', 'Market trade volume (size)', 'Market increase/decrease (color)']; 566 | $rows = [ 567 | ['Global', null, 0, 0], 568 | ['America', 'Global', 0, 0], 569 | ['Europe', 'Global', 0, 0], 570 | ['Asia', 'Global', 0, 0], 571 | ['Australia', 'Global', 0, 0], 572 | ['Africa', 'Global', 0, 0], 573 | ['Brazil', 'America', 11, 10], 574 | ['USA', 'America', 52, 31], 575 | ['Mexico', 'America', 24, 12], 576 | ['Canada', 'America', 16, -23], 577 | ['France', 'Europe', 42, -11], 578 | ['Germany', 'Europe', 31, -2], 579 | ['Sweden', 'Europe', 22, -13], 580 | ['Italy', 'Europe', 17, 4], 581 | ['UK', 'Europe', 21, -5], 582 | ['China', 'Asia', 36, 4], 583 | ['Japan', 'Asia', 20, -12], 584 | ['India', 'Asia', 40, 63], 585 | ['Laos', 'Asia', 4, 34], 586 | ['Mongolia', 'Asia', 1, -5], 587 | ['Israel', 'Asia', 12, 24], 588 | ['Iran', 'Asia', 18, 13], 589 | ['Pakistan', 'Asia', 11, -52], 590 | ['Egypt', 'Africa', 21, 0], 591 | ['S. Africa', 'Africa', 30, 43], 592 | ['Sudan', 'Africa', 12, 2], 593 | ['Congo', 'Africa', 10, 12], 594 | ['Zaire', 'Africa', 8, 10] 595 | ]; 596 | 597 | 598 | $options = [ 599 | 'minColor' => '#f00', 600 | 'midColor' => '#ddd', 601 | 'maxColor' => '#0d0', 602 | 'headerHeight' => 15, 603 | 'fontColor' => 'black', 604 | 'showScale' => TRUE 605 | ]; 606 | ``` 607 | 608 | .blade.php 609 | 610 | ``` 611 | 612 | 613 | {!!ChartManager::setChartType('treemap-chart') 614 | ->setOptions($options) 615 | ->setCols($cols) 616 | ->setRows($rows) 617 | ->render()!!} 618 | 619 | ``` 620 | 621 | ## Scatter Chart 622 | ``` php 623 | $cols = ['Diameter', 'Age']; 624 | $rows = [ 625 | [8, 37], 626 | [4, 19.5], 627 | [11, 52], 628 | [4, 22], 629 | [3, 16.5], 630 | [6.5, 32.8], [ 631 | 14, 72] 632 | ]; 633 | 634 | $options = [ 635 | 'title' => 'Age of sugar maples vs. trunk diameter, in inches', 636 | 'hAxis' => [ 637 | 'title' => 'Diameter', 638 | ], 639 | 'vAxis' => [ 640 | 'title' => 'Age', 641 | ], 642 | 'legend' => 'none', 643 | 'trendlines' => [ 644 | 0 => [], // Draw a trendline for data series 0. 645 | ], 646 | ]; 647 | ``` 648 | 649 | 650 | .blade.php file code 651 | 652 | ``` 653 | {!!ChartManager::setChartType('scatter-chart') 654 | ->setOptions($options) 655 | ->setCols($cols) 656 | ->setRows($rows) 657 | ->render()!!} 658 | 659 | ``` 660 | 661 | 662 | 663 | ## Word tree charts 664 | ``` php 665 | $cols = ['Phrases']; 666 | $rows = [ 667 | ['cats are better than dogs'], 668 | ['cats eat kibble'], 669 | ['cats are better than hamsters'], 670 | ['cats are awesome'], 671 | ['cats are people too'], 672 | ['cats eat mice'], 673 | ['cats meowing'], 674 | ['cats in the cradle'], 675 | ['cats eat mice'], 676 | ['cats in the cradle lyrics'], 677 | ['cats eat kibble'], 678 | ['cats for adoption'], 679 | ['cats are family'], 680 | ['cats eat mice'], 681 | ['cats are better than kittens'], 682 | ['cats are evil'], 683 | ['cats are weird'], 684 | ['cats eat mice'], 685 | ]; 686 | 687 | $options = [ 688 | 'wordtree' => ['format' => 'implicit', 'word' => 'cats'] 689 | ]; 690 | 691 | ``` 692 | .blade.php file code 693 | 694 | ``` 695 | {!!ChartManager::setChartType('wordtree-chart') 696 | ->setOptions($options) 697 | ->setCols($cols) 698 | ->setRows($rows) 699 | ->render()!!} 700 | ``` 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | Arguements for 'setChartType()' can be following depending upon requirements. 709 | ``` 710 | - 'bar-chart' 711 | - 'bubble-chart' 712 | - 'candlestick-chart' 713 | - 'combo-chart' 714 | - 'piechart-chart' 715 | - 'scatter-chart' 716 | - 'steppedarea-chart' 717 | - 'treemap-chart' 718 | - 'wordtree-chart' 719 | ``` 720 | ## Change log 721 | 722 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 723 | 724 | ## Testing 725 | 726 | ``` bash 727 | $ ./vendor/bin/phpunit 728 | ``` 729 | 730 | 731 | 732 | ## Credits 733 | 734 | - Thanks to Google Chart API 735 | 736 | ## License 737 | 738 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 739 | 740 | [ico-version]: https://img.shields.io/packagist/v/Scopdrag/laravel-google-chart.svg?style=flat-square 741 | [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square 742 | [ico-travis]: https://img.shields.io/travis/Scopdrag/laravel-google-chart/master.svg?style=flat-square 743 | [ico-downloads]: https://img.shields.io/packagist/dt/Scopdrag/laravel-google-chart.svg?style=flat-square 744 | 745 | [link-packagist]: https://packagist.org/packages/Scopdrag/laravel-google-chart 746 | [link-travis]: https://travis-ci.org/Scopdrag/laravel-google-chart 747 | [link-downloads]: https://packagist.org/packages/Scopdrag/laravel-google-chart 748 | [link-author]: https://github.com/:author_username 749 | [link-contributors]: ../../contributors 750 | # laravel-google-chart 751 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scopdrag/laravel-google-chart", 3 | "type": "library", 4 | "description": "Makes Google chart integration simple and easy for laravel", 5 | "keywords": [ 6 | "Scopdrag", 7 | "LaravelGoogleChart" 8 | ], 9 | "homepage": "https://github.com/scopdrag/laravel-google-chart.git", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Scopdrag", 14 | "email": "codemonster34@gmail.com", 15 | "homepage": "http://scopdrag.com", 16 | "role": "Developer" 17 | } 18 | ], 19 | "require": { 20 | "illuminate/support": "~5.0", 21 | "php" : "~5.3|~7.0" 22 | }, 23 | "require-dev": { 24 | "phpunit/phpunit" : "~4.0||~5.0", 25 | "scrutinizer/ocular": "~1.1", 26 | "squizlabs/php_codesniffer": "~2.7" 27 | }, 28 | "autoload": { 29 | "psr-4": { 30 | "Scopdrag\\LaravelGoogleChart\\": "src" 31 | } 32 | }, 33 | "autoload-dev": { 34 | "psr-4": { 35 | "Scopdrag\\LaravelGoogleChart\\": "tests" 36 | } 37 | }, 38 | "scripts": { 39 | "test": "phpunit", 40 | "format": "phpcbf --standard=psr2 src/" 41 | }, 42 | "extra": { 43 | "branch-alias": { 44 | "dev-master": "1.0-dev" 45 | } 46 | }, 47 | "config": { 48 | "sort-packages": true 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/ChartManager.php: -------------------------------------------------------------------------------- 1 | id = microtime(TRUE); 22 | } 23 | /** 24 | * getting chart id 25 | * @return type 26 | */ 27 | public function getId() { 28 | return $this->id; 29 | } 30 | 31 | /** 32 | *Setting chart type 33 | * @param type $type 34 | * @return \Scopdrag\LaravelGoogleChart\ChartManager 35 | */ 36 | public function setChartType($type) { 37 | $this->chart_type = $type; 38 | return $this; 39 | } 40 | 41 | /** 42 | * Getting chart type 43 | * @return type 44 | */ 45 | public function getChartType() { 46 | return strtolower($this->chart_type); 47 | } 48 | 49 | /** 50 | * Setting options 51 | * @param type $options 52 | * @return \Scopdrag\LaravelGoogleChart\ChartManager 53 | */ 54 | public function setOptions($options) { 55 | $default_options = [ 56 | 'chart' => [ 57 | 'title' => 'Population of Largest U.S. Cities', 58 | 'subtitle' => 'Based on most recent and previous census data' 59 | ], 60 | 'hAxis' => [ 61 | 'title' => 'Total Population', 62 | 'minValue' => 0 63 | ], 64 | 'vAxis' => [ 65 | 'title' => 'City' 66 | ], 67 | 'bars' => 'horizontal', //required if using material chart 68 | 'axes' => [ 69 | 'y' => [0 => ['side' => 'right']] 70 | ] 71 | ]; 72 | 73 | 74 | 75 | $this->options = empty($options) ? $default_options : $options; 76 | return $this; 77 | } 78 | 79 | /** 80 | * Setting cols 81 | * @param type $cols 82 | * @return \Scopdrag\LaravelGoogleChart\ChartManager 83 | */ 84 | public function setCols($cols = []) { 85 | $this->cols = $cols; 86 | return $this; 87 | } 88 | 89 | /** 90 | * getting cols 91 | * @return type 92 | */ 93 | public function getCols() { 94 | return $this->cols; 95 | } 96 | /** 97 | * Setting rows 98 | * @param type $rows 99 | * @return \Scopdrag\LaravelGoogleChart\ChartManager 100 | * @throws \Exception 101 | */ 102 | public function setRows($rows = []) { 103 | 104 | if (!empty($this->cols)) { 105 | if (count($rows[0]) < 1) { 106 | throw new \Exception('Expected 2 dimensional array for rows'); 107 | } elseif (count($this->cols) != 0 && count($this->cols) != count($rows[0])) { 108 | throw new \Exception('No of cols must equivelent to no heads in rows'); 109 | } 110 | } 111 | $this->rows = $rows; 112 | return $this; 113 | } 114 | 115 | /** 116 | * processing rows and there heads 117 | * @return type 118 | */ 119 | protected function processRowsHeads() { 120 | $cols = $this->getCols(); 121 | $this->data = $this->rows; 122 | if (!empty($cols)) { 123 | array_unshift($this->data, $cols); 124 | } 125 | return $this->data; 126 | } 127 | 128 | /** 129 | * genrate Google chart 130 | * @return type 131 | */ 132 | public function render() { 133 | $this->setId(); 134 | $id = $this->id; 135 | $this->processRowsHeads(); 136 | return view('LaravelGoogleChart::' . $this->getChartType()) 137 | ->with(['options' => $this->options, 138 | 'id' => $this->id, 139 | 'data' => $this->data])->render(); 140 | } 141 | 142 | 143 | 144 | } 145 | -------------------------------------------------------------------------------- /src/Contracts/Factory.php: -------------------------------------------------------------------------------- 1 | loadViewsFrom(__DIR__ . '/../resources/views', 'LaravelGoogleChart'); 16 | $this->publishes([ 17 | __DIR__ . '/resources/views' => resource_path('views/vendor/LaravelGoogleChart'), 18 | ]); 19 | } 20 | 21 | /** 22 | * Register any package services. 23 | * 24 | * @return void 25 | */ 26 | public function register() { 27 | 28 | 29 | $this->app->bind('Scopdrag\LaravelGoogleChart\Contracts\Factory', function() { 30 | return new ChartManager(); 31 | }); 32 | 33 | $className='ChartManager'; 34 | $this->app->booting(function() use($className) { 35 | $loader = \Illuminate\Foundation\AliasLoader::getInstance(); 36 | $loader->alias($className, 'Scopdrag\LaravelGoogleChart\Facades\ChartFacade'); 37 | }); 38 | 39 | } 40 | 41 | public function provides() { 42 | return ['Scopdrag\LaravelGoogleChart\Contracts\Factory']; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/resources/views/bar-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | -------------------------------------------------------------------------------- /src/resources/views/bubble-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | -------------------------------------------------------------------------------- /src/resources/views/candlestick-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | -------------------------------------------------------------------------------- /src/resources/views/combo-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | -------------------------------------------------------------------------------- /src/resources/views/includes/package_loader.blade.php: -------------------------------------------------------------------------------- 1 | 9 | @yield('content') 10 | 11 | -------------------------------------------------------------------------------- /src/resources/views/piechart-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | -------------------------------------------------------------------------------- /src/resources/views/scatter-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | -------------------------------------------------------------------------------- /src/resources/views/stacked-bar-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | 12 | 13 | -------------------------------------------------------------------------------- /src/resources/views/steppedarea-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | -------------------------------------------------------------------------------- /src/resources/views/treemap-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | -------------------------------------------------------------------------------- /src/resources/views/wordtree-chart.blade.php: -------------------------------------------------------------------------------- 1 | @include('LaravelGoogleChart::includes.package_loader') 2 |
3 | -------------------------------------------------------------------------------- /tests/BarChartTest.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'title' => 'Population of Largest U.S. Cities', 18 | 'subtitle' => 'Based on most recent and previous census data' 19 | ], 20 | 'chartArea' => ['width' => '50%'], 21 | 'hAxis' => [ 22 | 'title' => 'Total Population', 23 | 'minValue' => 0 24 | ], 25 | 'vAxis' => [ 26 | 'title' => 'City' 27 | ], 28 | 'bars' => 'horizontal', //required if using material chart 29 | 'axes' => [ 30 | 'y' => [0 => ['side' => 'right']] 31 | ] 32 | ]; 33 | 34 | $cols = ['City', '2010 Population', '2000 PopulaÎtions']; 35 | $rows = [ 36 | ['New York City, NY', 8175000, 8008000], 37 | ['Los Angeles, CA', 3792000, 3694000], 38 | ['Chicago, IL', 2695000, 2896000], 39 | ['Houston, TX', 2099000, 1953000], 40 | ['Philadelphia, PA', 1526000, 1517000] 41 | ]; 42 | 43 | $chartManager = ChartManager::setChartType('bar-chart') 44 | ->setOptions($options) 45 | ->setCols($cols) 46 | ->setRows($rows); 47 | 48 | $content = $chartManager->render(); 49 | 50 | $this->assertEquals('bar-chart', $chartManager->getChartType()); 51 | $this->assertRegExp('/visualization\\.BarChart/', $content); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /tests/BubbleChartTest.php: -------------------------------------------------------------------------------- 1 | [ 34 | 'title' => 'Correlation between life expectancy, fertility rate and population of some world countries (2010)', 35 | ], 36 | 'hAxis' => [ 37 | 'title' => 'Life Expectancy', 38 | ], 39 | 'vAxis' => [ 40 | 'title' => 'Fertility Rate' 41 | ], 42 | 'bubble' => 'horizontal', //required if using material chart 43 | 'bubble' => [ 44 | 'textStyle' => ['fontSize' => 11] 45 | ] 46 | ]; 47 | 48 | $chartManager = ChartManager::setChartType('bubble-chart') 49 | ->setOptions($options) 50 | ->setCols($cols) 51 | ->setRows($rows); 52 | 53 | $content = $chartManager->render(); 54 | 55 | $this->assertEquals('bubble-chart', $chartManager->getChartType()); 56 | $this->assertRegExp('/visualization\\.BubbleChart/', $content); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /tests/CandlestickChartTest.php: -------------------------------------------------------------------------------- 1 | 'none' 27 | ]; 28 | 29 | 30 | $chartManager = ChartManager::setChartType('candlestick-chart') 31 | ->setOptions($options) 32 | ->setCols([]) 33 | ->setRows($rows); 34 | 35 | $content = $chartManager->render(); 36 | 37 | $this->assertEquals('candlestick-chart', $chartManager->getChartType()); 38 | $this->assertRegExp('/visualization\\.CandlestickChart/', $content); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /tests/ComboChartTest.php: -------------------------------------------------------------------------------- 1 | 'Monthly Coffee Production by Country', 26 | 'hAxis' => [ 27 | 'title' => 'Cups', 28 | ], 29 | 'vAxis' => [ 30 | 'title' => 'Month' 31 | ], 32 | 'seriesType' => 'bars', //required if using material chart 33 | 'series' => [ 34 | '5' => ['type' => 'line'] 35 | ] 36 | ]; 37 | 38 | $chartManager = ChartManager::setChartType('combo-chart') 39 | ->setOptions($options) 40 | ->setCols($cols) 41 | ->setRows($rows); 42 | 43 | $content = $chartManager->render(); 44 | 45 | $this->assertEquals('combo-chart', $chartManager->getChartType()); 46 | $this->assertRegExp('/visualization\\.ComboChart/', $content); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /tests/PieChartTest.php: -------------------------------------------------------------------------------- 1 | 'none', 23 | ]; 24 | 25 | $chartManager =ChartManager::setChartType('piechart-chart') 26 | ->setOptions($options) 27 | ->setCols($cols) 28 | ->setRows($rows); 29 | 30 | $content = $chartManager->render(); 31 | 32 | $this->assertEquals('piechart-chart', $chartManager->getChartType()); 33 | $this->assertRegExp('/visualization\\.PieChart/', $content); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /tests/ScatterChartTest.php: -------------------------------------------------------------------------------- 1 | 'Age of sugar maples vs. trunk diameter, in inches', 28 | 'hAxis' => [ 29 | 'title' => 'Diameter', 30 | ], 31 | 'vAxis' => [ 32 | 'title' => 'Age', 33 | ], 34 | 'legend' => 'none', 35 | 'trendlines' => [ 36 | 0 => [], // Draw a trendline for data series 0. 37 | ], 38 | ]; 39 | 40 | $chartManager = ChartManager::setChartType('scatter-chart') 41 | ->setOptions($options) 42 | ->setCols($cols) 43 | ->setRows($rows); 44 | 45 | $content = $chartManager->render(); 46 | 47 | $this->assertEquals('scatter-chart', $chartManager->getChartType()); 48 | $this->assertRegExp('/visualization\\.ScatterChart/', $content); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /tests/StackedChartTest.php: -------------------------------------------------------------------------------- 1 | 600, 18 | 'width' => 400, 19 | 'legend' => ['position' => 'top', 'maxLines' => 3], 20 | 'bars' => ['groupWidth' => '75%'], 21 | 'isStacked' => TRUE 22 | ]; 23 | 24 | 25 | 26 | 27 | $cols = ['Date', 'Fantasy & Sci Fi', 'Romance', 'Mystery/Crime', 'General', 28 | 'Western', 'Literature', ['role' => 'annotation']]; 29 | $rows = [ 30 | ['2010', 10, 24, 20, 32, 18, 5, ''], 31 | ['2020', 16, 22, 23, 30, 16, 9, ''], 32 | ['2030', 28, 19, 29, 30, 12, 13, ''] 33 | ]; 34 | 35 | $chartManager = ChartManager::setChartType('bar-chart') 36 | ->setOptions($options) 37 | ->setCols($cols) 38 | ->setRows($rows); 39 | 40 | $content = $chartManager->render(); 41 | 42 | $this->assertEquals('bar-chart', $chartManager->getChartType()); 43 | $this->assertRegExp('/visualization\\.BarChart/', $content); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/SteppedAreaChartTest.php: -------------------------------------------------------------------------------- 1 | 'The decline of \'The 39 Steps\'', 26 | 'hAxis' => [ 27 | 'title' => 'Accumulated Rating', 28 | ], 29 | 'isStacked' => 'true', 30 | ]; 31 | 32 | $chartManager = ChartManager::setChartType('steppedarea-chart') 33 | ->setOptions($options) 34 | ->setCols($cols) 35 | ->setRows($rows); 36 | 37 | $content = $chartManager->render(); 38 | 39 | $this->assertEquals('steppedarea-chart', $chartManager->getChartType()); 40 | $this->assertRegExp('/visualization\\.SteppedAreaChart/', $content); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /tests/TreeMapChartTest.php: -------------------------------------------------------------------------------- 1 | '#f00', 50 | 'midColor' => '#ddd', 51 | 'maxColor' => '#0d0', 52 | 'headerHeight' => 15, 53 | 'fontColor' => 'black', 54 | 'showScale' => TRUE 55 | ]; 56 | 57 | $chartManager = ChartManager::setChartType('treemap-chart') 58 | ->setOptions($options) 59 | ->setCols($cols) 60 | ->setRows($rows); 61 | 62 | $content = $chartManager->render(); 63 | 64 | $this->assertEquals('treemap-chart', $chartManager->getChartType()); 65 | $this->assertRegExp('/visualization\\.TreeMap/', $content); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /tests/WordTreeChartTest.php: -------------------------------------------------------------------------------- 1 | ['format' => 'implicit', 'word' => 'cats'] 39 | ]; 40 | 41 | 42 | $chartManager = ChartManager::setChartType('wordtree-chart') 43 | ->setOptions($options) 44 | ->setCols($cols) 45 | ->setRows($rows); 46 | 47 | $content = $chartManager->render(); 48 | 49 | $this->assertEquals('wordtree-chart', $chartManager->getChartType()); 50 | $this->assertRegExp('/visualization\\.WordTree/', $content); 51 | } 52 | 53 | } 54 | --------------------------------------------------------------------------------