composer static phpchartjs pandora_enterprise#9554

This commit is contained in:
daniel 2022-12-20 14:22:13 +01:00
parent 2e48d51714
commit ae88c33aad
157 changed files with 19876 additions and 142 deletions

View File

@ -16,8 +16,17 @@
"mpdf/mpdf": "^8.0.15",
"swiftmailer/swiftmailer": "^6.0",
"amphp/parallel-functions": "^1.0",
"nutsy/phpchartjs": "*",
"chrome-php/chrome": "^1.7.1"
"chrome-php/chrome": "^1.7.1",
"artica/phpchartjs": "^1.0"
},
"repositories": {
"phpchartjs": {
"type": "path",
"url": "../../../phpchartjs",
"options": {
"symlink": false
}
}
},
"autoload": {
"psr-4": {

View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8df19e49d9715736491944daea32b45c",
"content-hash": "be2ad3d9d4df55d7ccb87981e82c4932",
"packages": [
{
"name": "amphp/amp",
@ -549,6 +549,69 @@
],
"time": "2021-10-25T18:29:10+00:00"
},
{
"name": "artica/phpchartjs",
"version": "v1.0.1",
"dist": {
"type": "path",
"url": "../../../phpchartjs",
"reference": "7ec8ed26f31671a6fc0c91c294b48dc9625d7827"
},
"require": {
"ext-dom": "*",
"ext-json": "*",
"halfpastfouram/collection": "1.0.0",
"laminas/laminas-json": ">3.1.2",
"php": ">=7.2",
"symfony/var-dumper": "^3.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpunit/phpunit": "^9.5",
"sensiolabs/security-checker": "^5.0",
"squizlabs/php_codesniffer": "3.5.3"
},
"type": "package",
"autoload": {
"psr-4": {
"Artica\\PHPChartJS\\": "src/",
"Test\\": "test/"
}
},
"scripts": {
"test": [
"./vendor/bin/phpunit"
],
"cs-check": [
"./vendor/bin/phpcs"
],
"cs-fix": [
"./vendor/bin/phpcbf"
]
},
"license": [
"AGPL-3.0-or-later"
],
"authors": [
{
"name": "Bob Kruithof"
},
{
"name": "Daniel Barbero"
}
],
"description": "PHP library for ChartJS",
"homepage": "https://artica.es/",
"keywords": [
"chartjs",
"graph",
"php"
],
"transport-options": {
"symlink": false,
"relative": true
}
},
{
"name": "chrome-php/chrome",
"version": "v1.7.1",
@ -1218,62 +1281,6 @@
],
"time": "2020-11-13T09:40:50+00:00"
},
{
"name": "nutsy/phpchartjs",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/danielbarmar85/phpchartjs.git",
"reference": "a6c7683198e6c4d4536fd8063a38e6277598a1b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/danielbarmar85/phpchartjs/zipball/a6c7683198e6c4d4536fd8063a38e6277598a1b8",
"reference": "a6c7683198e6c4d4536fd8063a38e6277598a1b8",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-json": "*",
"halfpastfouram/collection": "1.0.0",
"laminas/laminas-json": ">3.1.2",
"php": ">=7.2",
"symfony/var-dumper": "^3.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpunit/phpunit": "^9.5",
"sensiolabs/security-checker": "^5.0",
"squizlabs/php_codesniffer": "3.5.3"
},
"type": "package",
"autoload": {
"psr-4": {
"Test\\": "test/",
"Nutsy\\PHPChartJS\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"AGPL-3.0-or-later"
],
"authors": [
{
"name": "Daniel Barbero"
}
],
"description": "PHP library for ChartJS",
"homepage": "https://thenutsycompany.com/",
"keywords": [
"chartjs",
"graph",
"php"
],
"support": {
"source": "https://github.com/danielbarmar85/phpchartjs/tree/v1.0.0"
},
"time": "2022-11-23T13:00:43+00:00"
},
{
"name": "opis/closure",
"version": "3.6.3",

View File

@ -11,7 +11,7 @@
// Turn on output buffering.
// The entire buffer will be discarded later so that any accidental output
// does not corrupt images generated by fgraph.
use Nutsy\PHPChartJS\Factory;
use Artica\PHPChartJS\Factory;
ob_start();

View File

@ -0,0 +1,30 @@
---
engines:
duplication:
enabled: true
config:
languages:
- javascript
- php
fixme:
enabled: true
phpmd:
enabled: true
checks:
Design/TooManyFields:
enabled: false
CleanCode/StaticAccess:
enabled: false
Naming/LongVariable:
enabled: false
ratings:
paths:
- "**.inc"
- "**.js"
- "**.jsx"
- "**.module"
- "**.php"
- "**.py"
- "**.rb"
exclude_paths:
- test/

View File

@ -0,0 +1,9 @@
# Created by .ignore support plugin (hsz.mobi)
/.idea/
/composer.phar
composer.phar
/vendor/
codeCoverage
build
*DS_Store
.phpunit.result.cache

View File

@ -0,0 +1,31 @@
language: php
php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- nightly
before_script:
- composer self-update
- composer install
- mkdir build/logs -p
script:
- composer test
- composer cs-check
- php vendor/bin/security-checker security:check
after_script:
- rm -rf build/logs
matrix:
allow_failures:
- php: nightly
branches:
only:
- master
- dev

View File

@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

View File

@ -0,0 +1,177 @@
### Stable
[![Latest Stable Version](https://poser.pugx.org/Articaam/phpchartjs/v/stable)](https://packagist.org/packages/Articaam/phpchartjs)
[![Total Downloads](https://poser.pugx.org/Articaam/phpchartjs/downloads)](https://packagist.org/packages/Articaam/phpchartjs)
[![License](https://poser.pugx.org/Articaam/phpchartjs/license)](https://packagist.org/packages/Articaam/phpchartjs)
[![composer.lock](https://poser.pugx.org/Articaam/phpchartjs/composerlock)](https://packagist.org/packages/Articaam/phpchartjs)
[![Build Status](https://travis-ci.org/Articaam/PHPChartJS.svg?branch=master)](https://travis-ci.org/Articaam/PHPChartJS)
[![Code Climate](https://codeclimate.com/github/Articaam/PHPChartJS/badges/gpa.svg)](https://codeclimate.com/github/Articaam/PHPChartJS)
[![Test Coverage](https://codeclimate.com/github/Articaam/PHPChartJS/badges/coverage.svg)](https://codeclimate.com/github/Articaam/PHPChartJS/coverage)
[![Quality](https://scrutinizer-ci.com/g/Articaam/PHPChartJS/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Articaam/PHPChartJS/)
### Development
[![Latest Unstable Version](https://poser.pugx.org/Articaam/phpchartjs/v/unstable)](https://packagist.org/packages/Articaam/phpchartjs)
[![Build Status](https://travis-ci.org/Articaam/PHPChartJS.svg?branch=dev)](https://travis-ci.org/Articaam/PHPChartJS)
# PHPChartJS
PHP OOP library for [ChartJS](http://www.chartjs.org/)
PHPChartJS acts as an interface between the ChartJS library and the server side code. Set up a chart in no time and have every aspect of the graph managable from your PHP code. This interface is set up to provide code completion in every scenario so you never have to guess or lookup what options are available for the chosen chart. The library is entirely object oriented.
This library is still in active development and aims to implement all options ChartJS has to offer. Check the [Configuration milestone](https://github.com/Articaam/PHPChartJS/milestone/1) to view the progress of implementing all existing options.
## Example use
````php
<?php
use Artica\PHPChartJS\Chart\Bar;
$bar = new Bar();
$bar->setId("myBar");
// Set labels
$bar->labels()->exchangeArray(["M", "T", "W", "T", "F", "S", "S"]);
// Add apples
$apples = $bar->createDataSet();
$apples->setLabel("apples")
->setBackgroundColor("rgba( 0, 150, 0, .5 )")
->data()->exchangeArray([12, 19, 3, 17, 28, 24, 7]);
$bar->addDataSet($apples);
// Add oranges as well
$oranges = $bar->createDataSet();
$oranges->setLabel("oranges")
->setBackgroundColor("rgba( 255, 153, 0, .5 )")
->data()->exchangeArray([ 30, 29, 5, 5, 20, 3 ]);
// Add some extra data
$oranges->data()->append(10);
$bar->addDataSet($oranges);
// Render the chart
echo $bar->render();
````
The result generated by rendering the chart will look something like this:
````html
<canvas id="myBar"></canvas>
<script>
window.onload=(function(oldLoad){return function(){
if( oldLoad ) oldLoad();
var ctx = document.getElementById( "myBar" ).getContext( "2d" );
var chart = new Chart( ctx, {"type":"bar","data":{"labels":["M","T","W","T","F","S","S"],"datasets":[{"data":[12,19,3,17,28,24,7],"label":"apples","backgroundColor":"rgba( 0, 150, 0, .5 )"},{"data":[30,29,5,5,20,3,10],"label":"oranges","backgroundColor":"rgba( 255, 153, 0, .5 )"}]}} );
}})(window.onload);
</script>
````
### Callbacks
You can provide javascript callbacks with ease:
````php
$myCallback = "function(item){ console.log(item); }";
$bar->options()->getTooltips()->callbacks()->setAfterBody($myCallback);
````
### Rendering
Rendering the chart creates some HTML and some JavaScript. The JavaScript contains a JSON object providing the necessary
configuration for ChartJS. Every part of the configuration can be cast to an array or a JSON object.
Render isolated part of the configuration:
````php
$json = $myChart->options()->getScales()->jsonSerialize();
````
Or return an array containing the set configuration:
````php
$options = $myChart->options()->getScales()->getArrayCopy();
````
### Pretty mode
If you're not a fan of the long lines of code that are being generated you can force the rendering to be done in *pretty mode*, see the following example.
````php
// Render in pretty mode
$bar->render(true);
````
Want to see more? Fork this project and take a look at the examples in the test folder to explore the different options.
## Configuration options
Every option that is supported by ChartJS will be made available in this library.
### Layers
ChartJS requires you to build a JSON object containing the configuration options you want to set for the current chart.
These options are spread over multiple layers inside the configuration object. Accessing these layers with PHPChartJS is
super easy.
Let's say we wanted to access the chart's getAnimation subtree within the options subtree:
````php
$getAnimation = $myChart->options()->getAnimation();
````
You can now adjust any of ChartJS's getAnimation settings by using the getters and setters provided in that particular class.
## Collections
If ChartJS requires an array with certain items as subsets in a configuration option that array will be represented by a
collection in PHPChartJS. The collection can always by accessed directly to add, remove and replace values.
In some cases a specific object with a predetermined list of options is required in a collection. In these cases methods
will be provided to create a new instance of said object and adding it to the collection.
Datasets are stored in a collection:
````php
// Create new dataset
$dataset = $myChart->createDataSet();
... (add data to the dataset)
$myChart->addDataSet($dataset);
````
But the actual data in a dataset is also stored inside a collection:
````php
// Create new dataset
$dataset = $myChart->createDataSet();
// Add some data
$dataset->data()->append(1)->append(2);
// Prepend some data
$dataset->data()->prepend(0);
// Replace data at certain position
$dataset->data()->offsetSet(1, 3);
// Retrieve data from certain position
$value = $dataset->data()->offsetGet(1); // 3
// Add a lot of data at once whilst returning the old values
$oldData = $dataset->data()->exchangeArray([1, 2, 3]); // array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) }
$myChart->addDataSet($dataset);
````
For more information about the collections visit the [Articaam/collection](https://github.com/Articaam/collection) project.
## Installation
### Using composer
$ composer require Articaam/phpchartjs
### Development
This project uses composer, which should be installed on your system. Most
Linux systems have composer available in their PHP packages.
Alternatively you can download composer from [getcomposer.org](http://getcomposer.org).
If you use the PhpStorm IDE then you can simply init composer through the IDE. However,
full use requires the commandline. See PhpStorm help, search for composer.
To start development, do `composer install` from the project directory.
**Remark** Do not use `composer update` unless you changed the dependency requirements in composer.json.
The difference is that `composer install` will use composer.lock read-only,
while `composer update` will update your composer.lock file regardless of any change.
As the composer.lock file is committed to the repo, other developers might conclude
dependencies have changed, while they have not.

View File

@ -0,0 +1 @@
theme: jekyll-theme-cayman

View File

@ -0,0 +1,47 @@
{
"name": "artica/phpchartjs",
"description": "PHP library for ChartJS",
"keywords": [
"chartjs",
"graph",
"php"
],
"readme": "README.md",
"homepage": "https://artica.es/",
"type": "package",
"version": "v1.0.1",
"license": "AGPL-3.0-or-later",
"authors": [
{
"name": "Bob Kruithof"
},
{
"name": "Daniel Barbero"
}
],
"require": {
"php": ">=7.2",
"ext-dom": "*",
"ext-json": "*",
"laminas/laminas-json": ">3.1.2",
"halfpastfouram/collection": "1.0.0",
"symfony/var-dumper": "^3.4"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "3.5.3",
"friendsofphp/php-cs-fixer": "*",
"sensiolabs/security-checker": "^5.0"
},
"autoload": {
"psr-4": {
"Artica\\PHPChartJS\\": "src/",
"Test\\": "test/"
}
},
"scripts": {
"test": "./vendor/bin/phpunit",
"cs-check": "./vendor/bin/phpcs",
"cs-fix": "./vendor/bin/phpcbf"
}
}

3910
pandora_console/vendor/artica/phpchartjs/composer.lock generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<ruleset>
<!-- display progress -->
<arg value="p"/>
<arg name="colors"/>
<arg name="extensions" value="php,dist,phtml"/>
<!-- inherit rules from: -->
<rule ref="PSR2"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Formatting.SpaceAfterNot"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<severity>4</severity>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<severity>4</severity>
</rule>
<!-- Paths to check -->
<file>src</file>
</ruleset>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="test/bootstrap.php">
<testsuites>
<testsuite name="Default Unit Test Suite">
<directory>test/unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">test</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./codeCoverage" charset="UTF-8" yui="true" highlight="false"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>

View File

@ -0,0 +1,17 @@
<?php
namespace Artica\PHPChartJS;
/**
* Interface ArraySerializableInterface
* @package Artica\PHPChartJS
*/
interface ArraySerializableInterface
{
/**
* Should return an array containing all values.
*
* @return array
*/
public function getArrayCopy();
}

View File

@ -0,0 +1,334 @@
<?php
namespace Artica\PHPChartJS;
use Artica\PHPChartJS\Renderer\Html;
use Laminas\Json\Expr;
/**
* Class Chart
*
* @package Artica\PHPChartJS
*/
abstract class Chart implements ChartInterface
{
/**
* The internal type of chart.
*/
const TYPE = null;
/**
* The list of models that should be used for this chart type.
*/
const MODEL = [
'dataset' => DataSet::class,
'options' => Options::class,
];
/**
* @var string
*/
protected $id;
/**
* @var integer
*/
protected $height;
/**
* @var integer
*/
protected $width;
/**
* @var string
*/
protected $title;
/**
* @var LabelsCollection
*/
protected $labels;
/**
* @var PluginsCollection
*/
protected $plugins;
/**
* @var Options
*/
protected $options;
/**
* @var Defaults
*/
protected $defaults;
/**
* @var DataSetCollection
*/
protected $dataSets;
/**
* @return string
*/
public function getId()
{
if (is_null($this->id)) {
$this->id = uniqid('chart');
}
return $this->id;
}
/**
* @param string $id
*
* @return Chart
*/
public function setId($id)
{
$this->id = strval($id);
return $this;
}
/**
* @return integer
*/
public function getHeight()
{
return $this->height;
}
/**
* @param integer $height
*
* @return Chart
*/
public function setHeight($height)
{
$this->height = intval($height);
return $this;
}
/**
* @return integer
*/
public function getWidth()
{
return $this->width;
}
/**
* @param integer $width
*
* @return Chart
*/
public function setWidth($width)
{
$this->width = intval($width);
return $this;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*
* @return Chart
*/
public function setTitle($title)
{
$this->title = strval($title);
return $this;
}
/**
* @return LabelsCollection
*/
public function labels()
{
if (is_null($this->labels)) {
$this->labels = new LabelsCollection();
}
return $this->labels;
}
/**
* @param string $label
*
* @return $this
*/
public function addLabel($label)
{
$this->labels()->append($label);
return $this;
}
/**
* @param $offset
*
* @return string|boolean
*/
public function getLabel($offset)
{
return $this->labels()->offsetGet($offset);
}
/**
* @return PluginsCollection
*/
public function plugins()
{
if (is_null($this->plugins)) {
$this->plugins = new PluginsCollection();
}
return $this->plugins;
}
/**
* @param string $plugin
*
* @return $this
*/
public function addPlugin($plugin)
{
$this->plugins()->append(new Expr(strval($plugin)));
return $this;
}
/**
* @param $offset
*
* @return string|boolean
*/
public function getPlugin($offset)
{
return $this->plugins()->offsetGet($offset);
}
/**
* @return DataSetCollection
*/
public function dataSets()
{
if (is_null($this->dataSets)) {
$this->dataSets = new DataSetCollection();
}
return $this->dataSets;
}
/**
* @param DataSet $dataSet
*
* @return $this
*/
public function addDataSet(DataSet $dataSet)
{
$this->dataSets()->append($dataSet->setOwner($this));
return $this;
}
/**
* @param $offset
*
* @return DataSet|boolean
*/
public function getDataSet($offset)
{
return $this->dataSets()->offsetGet($offset);
}
/**
* @param boolean $pretty
*
* @return string
*/
public function render($pretty=false)
{
$renderer = new Html($this);
return $renderer->render($pretty ? $renderer::RENDER_PRETTY : null);
}
/**
* @return DataSet
*/
public function createDataSet()
{
$datasetClass = static::MODEL['dataset'];
/*
@var \Artica\PHPChartJS\DataSet $dataSet
*/
$dataSet = new $datasetClass();
$dataSet->setOwner($this);
return $dataSet;
}
/**
* @return Options
*/
public function options()
{
if (is_null($this->options)) {
$optionsClass = static::MODEL['options'];
$this->options = new $optionsClass($this);
$this->options->setOwner($this);
}
return $this->options;
}
/**
* @return Defaults
*/
public function defaults()
{
if (is_null($this->defaults)) {
$this->defaults = new Defaults($this);
}
return $this->defaults;
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\DataSet\BarDataSet;
use Artica\PHPChartJS\Options\BarOptions;
/**
* Class Bar
* @package Artica\PHPChartJS\Chart
*
* @method BarDataSet createDataSet
* @method BarOptions options
*/
class Bar extends Chart
{
/**
* The internal type of chart.
*/
const TYPE = 'bar';
/**
* The list of models that should be used for this chart type.
*/
const MODEL = [
'dataset' => BarDataSet::class,
'options' => BarOptions::class,
];
}

View File

@ -0,0 +1,30 @@
<?php
namespace Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\DataSet\BubbleDataSet;
use Artica\PHPChartJS\Options\BubbleOptions;
/**
* Class Bubble
* @package Artica\PHPChartJS\Chart
*
* @method BubbleDataSet createDataSet
* @method BubbleOptions options
*/
class Bubble extends Chart
{
/**
* The internal type of chart.
*/
const TYPE = 'bubble';
/**
* The list of models that should be used for this chart type.
*/
const MODEL = [
'dataset' => BubbleDataSet::class,
'options' => BubbleOptions::class,
];
}

View File

@ -0,0 +1,15 @@
<?php
namespace Artica\PHPChartJS\Chart;
/**
* Class Doughnut
* @package Artica\PHPChartJS\Chart
*/
class Doughnut extends Pie
{
/**
* The internal type of chart.
*/
const TYPE = 'doughnut';
}

View File

@ -0,0 +1,15 @@
<?php
namespace Artica\PHPChartJS\Chart;
/**
* Class HorizontalBar
* @package Artica\PHPChartJS\Chart
*/
class HorizontalBar extends Bar
{
/**
* The internal type of chart.
*/
const TYPE = 'horizontalBar';
}

View File

@ -0,0 +1,28 @@
<?php
namespace Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\DataSet\LineDataSet;
use Artica\PHPChartJS\Options\LineOptions;
/**
* Class Line
* @package Artica\PHPChartJS\Chart
* @method LineDataSet createDataSet()
*/
class Line extends Chart
{
/**
* The internal type of chart.
*/
const TYPE = 'line';
/**
* The list of models that should be used for this chart type.
*/
const MODEL = [
'dataset' => LineDataSet::class,
'options' => LineOptions::class,
];
}

View File

@ -0,0 +1,31 @@
<?php
namespace Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\ChartInterface;
use Artica\PHPChartJS\DataSet\PieDataSet;
use Artica\PHPChartJS\Options\PieOptions;
/**
* Class Pie
* @package Artica\PHPChartJS\Chart
*
* @method PieDataSet createDataSet
* @method PieOptions options
*/
class Pie extends Chart implements ChartInterface
{
/**
* The internal type of chart.
*/
const TYPE = 'pie';
/**
* The list of models that should be used for this chart type.
*/
const MODEL = [
'dataset' => PieDataSet::class,
'options' => PieOptions::class,
];
}

View File

@ -0,0 +1,31 @@
<?php
namespace Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\ChartInterface;
use Artica\PHPChartJS\DataSet\PolarAreaDataSet;
use Artica\PHPChartJS\Options\PolarAreaOptions;
/**
* Class PolarArea
* @package Artica\PHPChartJS\Chart
*
* @method PolarAreaDataSet createDataSet
* @method PolarAreaOptions options
*/
class PolarArea extends Chart implements ChartInterface
{
/**
* The internal type of chart.
*/
const TYPE = 'polarArea';
/**
* The list of models that should be used for this chart type.
*/
const MODEL = [
'dataset' => PolarAreaDataSet::class,
'options' => PolarAreaOptions::class,
];
}

View File

@ -0,0 +1,31 @@
<?php
namespace Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\ChartInterface;
use Artica\PHPChartJS\DataSet\RadarDataSet;
use Artica\PHPChartJS\Options\RadarOptions;
/**
* Class Radar
* @package Artica\PHPChartJS\Chart
*
* @method RadarDataSet createDataSet
* @method RadarOptions options
*/
class Radar extends Chart implements ChartInterface
{
/**
* The internal type of chart.
*/
const TYPE = 'radar';
/**
* The list of models that should be used for this chart type.
*/
const MODEL = [
'dataset' => RadarDataSet::class,
'options' => RadarOptions::class,
];
}

View File

@ -0,0 +1,31 @@
<?php
namespace Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\Chart;
use Artica\PHPChartJS\DataSet\ScatterDataSet;
use Artica\PHPChartJS\Options\ScatterOptions;
/**
* Class Scatter
*
* @package Artica\PHPChartJS\Chart
*
* @method ScatterDataSet createDataSet
* @method ScatterOptions options
*/
class Scatter extends Chart
{
/**
* The internal type of chart.
*/
const TYPE = 'scatter';
/**
* The list of models that should be used for this chart type.
*/
const MODEL = [
'dataset' => ScatterDataSet::class,
'options' => ScatterOptions::class,
];
}

View File

@ -0,0 +1,51 @@
<?php
namespace Artica\PHPChartJS;
use Halfpastfour\Collection\CollectionInterface;
/**
* Interface ChartInterface
* @package Artica\PHPChartJS
*/
interface ChartInterface
{
/**
* @return Options
*/
public function options();
/**
* @return Defaults
*/
public function defaults();
/**
* @return DataSet
*/
public function createDataSet();
/**
* @param DataSet $dataSet
*
* @return $this
*/
public function addDataSet(DataSet $dataSet);
/**
* @param $offset
*
* @return DataSet
*/
public function getDataSet($offset);
/**
* @return CollectionInterface
*/
public function dataSets();
/**
* @return string
*/
public function render();
}

View File

@ -0,0 +1,36 @@
<?php
namespace Artica\PHPChartJS;
/**
* Class ChartOwned
*
* @package Artica\PHPChartJS
*/
trait ChartOwned
{
/**
* @var ChartInterface
*/
private $owner;
/**
* @param ChartInterface $chart
*
* @return $this
*/
public function setOwner(ChartInterface $chart)
{
$this->owner = $chart;
return $this;
}
/**
* @return ChartInterface
*/
public function owner()
{
return $this->owner;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Artica\PHPChartJS;
/**
* Class DataSet
* @package Artica\PHPChartJS
*/
interface ChartOwnedInterface
{
/**
* @param ChartInterface $chart
*
* @return $this
*/
public function setOwner(ChartInterface $chart);
/**
* @return ChartInterface
*/
public function owner();
}

View File

@ -0,0 +1,17 @@
<?php
namespace Artica\PHPChartJS\Collection;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\Delegate;
use JsonSerializable as JsonSerializableInterface;
/**
* Class Data
*
* @package Artica\PHPChartJS\Collection
*/
class Data extends ArrayAccess implements JsonSerializableInterface
{
use Delegate\JsonSerializable;
}

View File

@ -0,0 +1,8 @@
<?php
namespace Artica\PHPChartJS\ConfigDefaults;
class AnimationConfig
{
}

View File

@ -0,0 +1,8 @@
<?php
namespace Artica\PHPChartJS\ConfigDefaults;
class ElementsConfig
{
}

View File

@ -0,0 +1,219 @@
<?php
namespace Artica\PHPChartJS\ConfigDefaults;
/**
* Class GlobalConfig
* @package Artica\PHPChartJS\ConfigDefaults
*/
class GlobalConfig
{
/**
* @var GlobalConfig
*/
private static $instance;
/**
* @var string
*/
private $defaultFontColor;
/**
* @var string
*/
private $defaultFontFamily;
/**
* @var int
*/
private $defaultFontSize;
/**
* @var string
*/
private $defaultFontStyle;
/**
* @var LayoutConfig
*/
private $layout;
/**
* @var TooltipsConfig
*/
private $tooltips;
/**
* @var HoverConfig
*/
private $hover;
/**
* @var AnimationConfig
*/
private $animation;
/**
* @var ElementsConfig
*/
private $elements;
/**
* GlobalConfig constructor.
*/
private function __construct()
{
}
/**
* @return $this
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self;
}
return self::$instance;
}
/**
* @return string
*/
public function getDefaultFontColor()
{
return $this->defaultFontColor;
}
/**
* @param string $defaultFontColor
*
* @return $this
*/
public function setDefaultFontColor($defaultFontColor)
{
$this->defaultFontColor = strval($defaultFontColor);
return $this;
}
/**
* @return string
*/
public function getDefaultFontFamily()
{
return $this->defaultFontFamily;
}
/**
* @param string $defaultFontFamily
*
* @return $this
*/
public function setDefaultFontFamily($defaultFontFamily)
{
$this->defaultFontFamily = strval($defaultFontFamily);
return $this;
}
/**
* @return int
*/
public function getDefaultFontSize()
{
return $this->defaultFontSize;
}
/**
* @param int $defaultFontSize
*
* @return $this
*/
public function setDefaultFontSize($defaultFontSize)
{
$this->defaultFontSize = intval($defaultFontSize);
return $this;
}
/**
* @return string
*/
public function getDefaultFontStyle()
{
return $this->defaultFontStyle;
}
/**
* @param string $defaultFontStyle
*
* @return $this
*/
public function setDefaultFontStyle($defaultFontStyle)
{
$this->defaultFontStyle = $defaultFontStyle;
return $this;
}
/**
* @return LayoutConfig
*/
public function layout()
{
if (is_null($this->layout)) {
$this->layout = new LayoutConfig();
}
return $this->layout;
}
/**
* @return TooltipsConfig
*/
public function tooltips()
{
if (is_null($this->tooltips)) {
$this->tooltips = new TooltipsConfig();
}
return $this->tooltips;
}
/**
* @return HoverConfig
*/
public function hover()
{
if (is_null($this->hover)) {
$this->hover = new HoverConfig();
}
return $this->hover;
}
/**
* @return AnimationConfig
*/
public function animation()
{
if (is_null($this->animation)) {
$this->animation = new AnimationConfig();
}
return $this->animation;
}
/**
* @return ElementsConfig
*/
public function elements()
{
if (is_null($this->elements)) {
$this->elements = new ElementsConfig();
}
return $this->elements;
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace Artica\PHPChartJS\ConfigDefaults;
class HoverConfig
{
}

View File

@ -0,0 +1,8 @@
<?php
namespace Artica\PHPChartJS\ConfigDefaults;
class LayoutConfig
{
}

View File

@ -0,0 +1,8 @@
<?php
namespace Artica\PHPChartJS\ConfigDefaults;
class TooltipsConfig
{
}

View File

@ -0,0 +1,407 @@
<?php
namespace Artica\PHPChartJS;
use Artica\PHPChartJS\Collection\Data;
use Artica\PHPChartJS\Delegate;
use JsonSerializable as JsonSerializableInterface;
/**
* Class DataSet
*
* @package Artica\PHPChartJS
*/
class DataSet implements ChartOwnedInterface, ArraySerializableInterface, JsonSerializableInterface
{
use ChartOwned;
use Delegate\ArraySerializable;
use Delegate\JsonSerializable;
/**
* @var string
*/
protected $type;
/**
* @var Data
*/
protected $data;
/**
* @var string
*/
protected $label;
/**
* @var string
*/
protected $xAxisID;
/**
* @var string
*/
protected $yAxisID;
/**
* @var string|string[]
*/
protected $backgroundColor;
/**
* @var string|string[]
*/
protected $borderColor;
/**
* @var int|int[]
*/
protected $borderWidth;
/**
* @var string
*/
protected $borderSkipped;
/**
* @var string|string[]
*/
protected $hoverBackgroundColor;
/**
* @var string|string[]
*/
protected $hoverBorderColor;
/**
* @var int|int[]
*/
protected $hoverBorderWidth;
/**
* @var bool|null
*/
protected $hidden;
/**
* @var string|null
*/
protected $axis;
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string $type
*
* @return $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* @return Data
*/
public function data()
{
if (is_null($this->data)) {
$this->data = new Data();
}
return $this->data;
}
/**
* @return string
*/
public function getLabel()
{
return $this->label;
}
/**
* @param string $label
*
* @return $this
*/
public function setLabel($label)
{
$this->label = strval($label);
return $this;
}
/**
* @return string
*/
public function getAxis()
{
return $this->axis;
}
/**
* @param string $axis
*
* @return $this
*/
public function setAxis($axis)
{
$this->axis = $axis;
return $this;
}
/**
* @return string
*/
public function getXAxisID()
{
return $this->xAxisID;
}
/**
* @param string $xAxisID
*
* @return $this
*/
public function setXAxisID($xAxisID)
{
$this->xAxisID = strval($xAxisID);
return $this;
}
/**
* @return string
*/
public function getYAxisID()
{
return $this->yAxisID;
}
/**
* @param string $yAxisID
*
* @return $this
*/
public function setYAxisID($yAxisID)
{
$this->yAxisID = strval($yAxisID);
return $this;
}
/**
* @return string|string[]
*/
public function getBackgroundColor()
{
return $this->backgroundColor;
}
/**
* @param string|string[] $backgroundColor
*
* @return $this
*/
public function setBackgroundColor($backgroundColor)
{
if (is_array($backgroundColor)) {
$backgroundColor = array_map('strval', $backgroundColor);
}
if (! is_array($backgroundColor)) {
$backgroundColor = strval($backgroundColor);
}
$this->backgroundColor = $backgroundColor;
return $this;
}
/**
* @return string|string[]
*/
public function getBorderColor()
{
return $this->borderColor;
}
/**
* @param string|string[] $borderColor
*
* @return $this
*/
public function setBorderColor($borderColor)
{
if (is_array($borderColor)) {
$borderColor = array_map('strval', $borderColor);
}
if (! is_array($borderColor)) {
$borderColor = strval($borderColor);
}
$this->borderColor = $borderColor;
return $this;
}
/**
* @return int|int[]
*/
public function getBorderWidth()
{
return $this->borderWidth;
}
/**
* @param int|int[] $borderWidth
*
* @return $this
*/
public function setBorderWidth($borderWidth)
{
if (is_array($borderWidth)) {
$borderWidth = array_map('intval', $borderWidth);
}
if (! is_array($borderWidth)) {
$borderWidth = intval($borderWidth);
}
$this->borderWidth = $borderWidth;
return $this;
}
/**
* @return string
*/
public function getBorderSkipped()
{
return $this->borderSkipped;
}
/**
* @param string $borderSkipped
*
* @return $this
*/
public function setBorderSkipped($borderSkipped)
{
$this->borderSkipped = strval($borderSkipped);
return $this;
}
/**
* @return string|string[]
*/
public function getHoverBackgroundColor()
{
return $this->hoverBackgroundColor;
}
/**
* @param string|string[] $hoverBackgroundColor
*
* @return $this
*/
public function setHoverBackgroundColor($hoverBackgroundColor)
{
if (is_array($hoverBackgroundColor)) {
$hoverBackgroundColor = array_map('strval', $hoverBackgroundColor);
}
if (! is_array($hoverBackgroundColor)) {
$hoverBackgroundColor = strval($hoverBackgroundColor);
}
$this->hoverBackgroundColor = $hoverBackgroundColor;
return $this;
}
/**
* @return string|string[]
*/
public function getHoverBorderColor()
{
return $this->hoverBorderColor;
}
/**
* @param string|string[] $hoverBorderColor
*
* @return $this
*/
public function setHoverBorderColor($hoverBorderColor)
{
if (is_array($hoverBorderColor)) {
$hoverBorderColor = array_map('strval', $hoverBorderColor);
}
if (! is_array($hoverBorderColor)) {
$hoverBorderColor = strval($hoverBorderColor);
}
$this->hoverBorderColor = $hoverBorderColor;
return $this;
}
/**
* @return int|int[]
*/
public function getHoverBorderWidth()
{
return $this->hoverBorderWidth;
}
/**
* @param int|int[] $hoverBorderWidth
*
* @return $this
*/
public function setHoverBorderWidth($hoverBorderWidth)
{
if (is_array($hoverBorderWidth)) {
$hoverBorderWidth = array_map('intval', $hoverBorderWidth);
}
if (! is_array($hoverBorderWidth)) {
$hoverBorderWidth = intval($hoverBorderWidth);
}
$this->hoverBorderWidth = $hoverBorderWidth;
return $this;
}
/**
* @return bool|null
*/
public function isHidden()
{
if (is_null($this->hidden)) {
$this->hidden = false;
}
return $this->hidden;
}
/**
* @param bool|null $hidden
*
* @return $this
*/
public function setHidden($hidden)
{
$this->hidden = is_null($hidden) ? null : boolval($hidden);
return $this;
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Artica\PHPChartJS\DataSet;
use Artica\PHPChartJS\DataSet;
/**
* Class BarDataSet
* @package Artica\PHPChartJS\DataSet
*/
class BarDataSet extends DataSet
{
}

View File

@ -0,0 +1,63 @@
<?php
namespace Artica\PHPChartJS\DataSet;
use Artica\PHPChartJS\DataSet;
/**
* Class BubbleDataSet
*
* @package Artica\PHPChartJS\DataSet
*/
class BubbleDataSet extends DataSet
{
/**
* @var string
*/
protected $pointStyle;
/**
* @var int
*/
protected $radius;
/**
* @return string
*/
public function getPointStyle()
{
return $this->pointStyle;
}
/**
* @param string $pointStyle
*
* @return \Artica\PHPChartJS\DataSet\BubbleDataSet
*/
public function setPointStyle($pointStyle)
{
$this->pointStyle = $pointStyle;
return $this;
}
/**
* @return int|null
*/
public function getRadius()
{
return $this->radius;
}
/**
* @param int $radius
*
* @return \Artica\PHPChartJS\DataSet\BubbleDataSet
*/
public function setRadius($radius)
{
$this->radius = $radius;
return $this;
}
}

View File

@ -0,0 +1,512 @@
<?php
namespace Artica\PHPChartJS\DataSet;
use Artica\PHPChartJS\DataSet;
/**
* Class LineDataSet
* @package Artica\PHPChartJS\DataSet
*/
class LineDataSet extends DataSet
{
/**
* @var bool|string
*/
protected $fill;
/**
* @var string
*/
protected $cubicInterpolationMode;
/**
* @var int
*/
protected $lineTension;
/**
* @var string
*/
protected $borderCapStyle;
/**
* @var array
*/
protected $borderDash;
/**
* @var float
*/
protected $borderDashOffset;
/**
* @var string
*/
protected $borderJoinStyle;
/**
* @var string|string[]
*/
protected $pointBorderColor;
/**
* @var string|string[]
*/
protected $pointBackgroundColor;
/**
* @var int|int[]
*/
protected $pointBorderWidth;
/**
* @var int|int[]
*/
protected $pointRadius;
/**
* @var int|int[]
*/
protected $pointHoverRadius;
/**
* @var int|int[]
*/
protected $pointHitRadius;
/**
* @var string|string[]
*/
protected $pointHoverBackgroundColor;
/**
* @var string|string[]
*/
protected $pointHoverBorderColor;
/**
* @var int|int[]
*/
protected $pointHoverBorderWidth;
/**
* @var mixed
*/
protected $pointStyle;
/**
* @var bool
*/
protected $showLine;
/**
* @var bool
*/
protected $spanGaps;
/**
* @var bool
*/
protected $steppedLine;
/**
* @return bool|string
*/
public function getFill()
{
return $this->fill;
}
/**
* @param bool|string $fill
*
* @return $this
*/
public function setFill($fill)
{
$this->fill = $fill;
return $this;
}
/**
* @return string
*/
public function getCubicInterpolationMode()
{
return $this->cubicInterpolationMode;
}
/**
* @param string $cubicInterpolationMode
*
* @return $this
*/
public function setCubicInterpolationMode($cubicInterpolationMode)
{
$this->cubicInterpolationMode = $cubicInterpolationMode;
return $this;
}
/**
* @return int
*/
public function getLineTension()
{
return $this->lineTension;
}
/**
* @param float $lineTension
*
* @return $this
*/
public function setLineTension($lineTension)
{
$this->lineTension = floatval($lineTension);
return $this;
}
/**
* @return string
*/
public function getBorderCapStyle()
{
return $this->borderCapStyle;
}
/**
* @param string $borderCapStyle
*
* @return $this
*/
public function setBorderCapStyle($borderCapStyle)
{
$this->borderCapStyle = $borderCapStyle;
return $this;
}
/**
* @return array
*/
public function getBorderDash()
{
return $this->borderDash;
}
/**
* @param array $borderDash
*
* @return $this
*/
public function setBorderDash($borderDash)
{
$this->borderDash = $borderDash;
return $this;
}
/**
* @return int
*/
public function getBorderDashOffset()
{
return $this->borderDashOffset;
}
/**
* @param float $borderDashOffset
*
* @return $this
*/
public function setBorderDashOffset($borderDashOffset)
{
$this->borderDashOffset = floatval($borderDashOffset);
return $this;
}
/**
* @return string
*/
public function getBorderJoinStyle()
{
return $this->borderJoinStyle;
}
/**
* @param string $borderJoinStyle
*
* @return $this
*/
public function setBorderJoinStyle($borderJoinStyle)
{
$this->borderJoinStyle = $borderJoinStyle;
return $this;
}
/**
* @return string|string[]
*/
public function getPointBorderColor()
{
return $this->pointBorderColor;
}
/**
* @param string|string[] $pointBorderColor
*
* @return $this
*/
public function setPointBorderColor($pointBorderColor)
{
$this->pointBorderColor = $pointBorderColor;
return $this;
}
/**
* @return string|string[]
*/
public function getPointBackgroundColor()
{
return $this->pointBackgroundColor;
}
/**
* @param string|string[] $pointBackgroundColor
*
* @return $this
*/
public function setPointBackgroundColor($pointBackgroundColor)
{
$this->pointBackgroundColor = $pointBackgroundColor;
return $this;
}
/**
* @return int|int[]
*/
public function getPointBorderWidth()
{
return $this->pointBorderWidth;
}
/**
* @param int|int[] $pointBorderWidth
*
* @return $this
*/
public function setPointBorderWidth($pointBorderWidth)
{
$this->pointBorderWidth = $pointBorderWidth;
return $this;
}
/**
* @return int|int[]
*/
public function getPointRadius()
{
return $this->pointRadius;
}
/**
* @param int|int[] $pointRadius
*
* @return $this
*/
public function setPointRadius($pointRadius)
{
$this->pointRadius = $pointRadius;
return $this;
}
/**
* @return int|int[]
*/
public function getPointHoverRadius()
{
return $this->pointHoverRadius;
}
/**
* @param int|int[] $pointHoverRadius
*
* @return $this
*/
public function setPointHoverRadius($pointHoverRadius)
{
$this->pointHoverRadius = $pointHoverRadius;
return $this;
}
/**
* @return int|int[]
*/
public function getPointHitRadius()
{
return $this->pointHitRadius;
}
/**
* @param int|int[] $pointHitRadius
*
* @return $this
*/
public function setPointHitRadius($pointHitRadius)
{
$this->pointHitRadius = $pointHitRadius;
return $this;
}
/**
* @return string|string[]
*/
public function getPointHoverBackgroundColor()
{
return $this->pointHoverBackgroundColor;
}
/**
* @param string|string[] $pointHoverBackgroundColor
*
* @return $this
*/
public function setPointHoverBackgroundColor($pointHoverBackgroundColor)
{
$this->pointHoverBackgroundColor = $pointHoverBackgroundColor;
return $this;
}
/**
* @return string|string[]
*/
public function getPointHoverBorderColor()
{
return $this->pointHoverBorderColor;
}
/**
* @param string|string[] $pointHoverBorderColor
*
* @return $this
*/
public function setPointHoverBorderColor($pointHoverBorderColor)
{
$this->pointHoverBorderColor = $pointHoverBorderColor;
return $this;
}
/**
* @return int|int[]
*/
public function getPointHoverBorderWidth()
{
return $this->pointHoverBorderWidth;
}
/**
* @param int|int[] $pointHoverBorderWidth
*
* @return $this
*/
public function setPointHoverBorderWidth($pointHoverBorderWidth)
{
$this->pointHoverBorderWidth = $pointHoverBorderWidth;
return $this;
}
/**
* @return mixed
*/
public function getPointStyle()
{
return $this->pointStyle;
}
/**
* @param mixed $pointStyle
*
* @return $this
*/
public function setPointStyle($pointStyle)
{
$this->pointStyle = $pointStyle;
return $this;
}
/**
* @return bool
*/
public function isShowLine()
{
return $this->showLine;
}
/**
* @param bool $showLine
*
* @return $this
*/
public function setShowLine($showLine)
{
$this->showLine = $showLine;
return $this;
}
/**
* @return bool
*/
public function isSpanGaps()
{
return $this->spanGaps;
}
/**
* @param bool $spanGaps
*
* @return $this
*/
public function setSpanGaps($spanGaps)
{
$this->spanGaps = $spanGaps;
return $this;
}
/**
* @return bool
*/
public function isSteppedLine()
{
return $this->steppedLine;
}
/**
* @param bool $steppedLine
*
* @return $this
*/
public function setSteppedLine($steppedLine)
{
$this->steppedLine = $steppedLine;
return $this;
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Artica\PHPChartJS\DataSet;
use Artica\PHPChartJS\DataSet;
/**
* Class PieDataSet
* @package Artica\PHPChartJS\DataSet
*/
class PieDataSet extends DataSet
{
}

View File

@ -0,0 +1,13 @@
<?php
namespace Artica\PHPChartJS\DataSet;
use Artica\PHPChartJS\DataSet;
/**
* Class PolarAreaDataSet
* @package Artica\PHPChartJS\DataSet
*/
class PolarAreaDataSet extends DataSet
{
}

View File

@ -0,0 +1,412 @@
<?php
namespace Artica\PHPChartJS\DataSet;
use Artica\PHPChartJS\DataSet;
/**
* Class RadarDataSet
* @package Artica\PHPChartJS\DataSet
*/
class RadarDataSet extends DataSet
{
/**
* @var bool
*/
protected $fill;
/**
* @var float
*/
protected $lineTension;
/**
* @var string
*/
protected $borderCapStyle;
/**
* @var int[]
*/
protected $borderDash;
/**
* @var int
*/
protected $borderDashOffset;
/**
* @var string
*/
protected $borderJoinStyle;
/**
* @var string|string[]
*/
protected $pointBorderColor;
/**
* @var string|string[]
*/
protected $pointBackgroundColor;
/**
* @var int|int[]
*/
protected $pointBorderWidth;
/**
* @var int|int[]
*/
protected $pointRadius;
/**
* @var int|int[]
*/
protected $pointHoverRadius;
/**
* @var int|int[]
*/
protected $hitRadius;
/**
* @var string|string[]
*/
protected $pointHoverBackgroundColor;
/**
* @var string|string[]
*/
protected $pointHoverBorderColor;
/**
* @var int|int[]
*/
protected $pointHoverBorderWidth;
/**
* @var string|string[]
*/
protected $pointStyle;
/**
* @return bool
*/
public function isFill()
{
return $this->fill;
}
/**
* @param bool $fill
*
* @return $this
*/
public function setFill($fill)
{
$this->fill = $fill;
return $this;
}
/**
* @return int
*/
public function getLineTension()
{
return $this->lineTension;
}
/**
* @param float $lineTension
*
* @return $this
*/
public function setLineTension($lineTension)
{
$this->lineTension = $lineTension;
return $this;
}
/**
* @return string
*/
public function getBorderCapStyle()
{
return $this->borderCapStyle;
}
/**
* @param string $borderCapStyle
*
* @return $this
*/
public function setBorderCapStyle($borderCapStyle)
{
$this->borderCapStyle = $borderCapStyle;
return $this;
}
/**
* @return int[]
*/
public function getBorderDash()
{
return $this->borderDash;
}
/**
* @param int[] $borderDash
*
* @return $this
*/
public function setBorderDash($borderDash)
{
$this->borderDash = $borderDash;
return $this;
}
/**
* @return int
*/
public function getBorderDashOffset()
{
return $this->borderDashOffset;
}
/**
* @param int $borderDashOffset
*
* @return $this
*/
public function setBorderDashOffset($borderDashOffset)
{
$this->borderDashOffset = $borderDashOffset;
return $this;
}
/**
* @return string
*/
public function getBorderJoinStyle()
{
return $this->borderJoinStyle;
}
/**
* @param string $borderJoinStyle
*
* @return $this
*/
public function setBorderJoinStyle($borderJoinStyle)
{
$this->borderJoinStyle = $borderJoinStyle;
return $this;
}
/**
* @return string|string[]
*/
public function getPointBorderColor()
{
return $this->pointBorderColor;
}
/**
* @param string|string[] $pointBorderColor
*
* @return $this
*/
public function setPointBorderColor($pointBorderColor)
{
$this->pointBorderColor = $pointBorderColor;
return $this;
}
/**
* @return string|string[]
*/
public function getPointBackgroundColor()
{
return $this->pointBackgroundColor;
}
/**
* @param string|string[] $pointBackgroundColor
*
* @return $this
*/
public function setPointBackgroundColor($pointBackgroundColor)
{
$this->pointBackgroundColor = $pointBackgroundColor;
return $this;
}
/**
* @return int|int[]
*/
public function getPointBorderWidth()
{
return $this->pointBorderWidth;
}
/**
* @param int|int[] $pointBorderWidth
*
* @return $this
*/
public function setPointBorderWidth($pointBorderWidth)
{
$this->pointBorderWidth = $pointBorderWidth;
return $this;
}
/**
* @return int|int[]
*/
public function getPointRadius()
{
return $this->pointRadius;
}
/**
* @param int|int[] $pointRadius
*
* @return $this
*/
public function setPointRadius($pointRadius)
{
$this->pointRadius = $pointRadius;
return $this;
}
/**
* @return int|int[]
*/
public function getPointHoverRadius()
{
return $this->pointHoverRadius;
}
/**
* @param int|int[] $pointHoverRadius
*
* @return $this
*/
public function setPointHoverRadius($pointHoverRadius)
{
$this->pointHoverRadius = $pointHoverRadius;
return $this;
}
/**
* @return int|int[]
*/
public function getHitRadius()
{
return $this->hitRadius;
}
/**
* @param int|int[] $hitRadius
*
* @return $this
*/
public function setHitRadius($hitRadius)
{
$this->hitRadius = $hitRadius;
return $this;
}
/**
* @return string|string[]
*/
public function getPointHoverBackgroundColor()
{
return $this->pointHoverBackgroundColor;
}
/**
* @param string|string[] $pointHoverBackgroundColor
*
* @return $this
*/
public function setPointHoverBackgroundColor($pointHoverBackgroundColor)
{
$this->pointHoverBackgroundColor = $pointHoverBackgroundColor;
return $this;
}
/**
* @return string|string[]
*/
public function getPointHoverBorderColor()
{
return $this->pointHoverBorderColor;
}
/**
* @param string|string[] $pointHoverBorderColor
*
* @return $this
*/
public function setPointHoverBorderColor($pointHoverBorderColor)
{
$this->pointHoverBorderColor = $pointHoverBorderColor;
return $this;
}
/**
* @return int|int[]
*/
public function getPointHoverBorderWidth()
{
return $this->pointHoverBorderWidth;
}
/**
* @param int|int[] $pointHoverBorderWidth
*
* @return $this
*/
public function setPointHoverBorderWidth($pointHoverBorderWidth)
{
$this->pointHoverBorderWidth = $pointHoverBorderWidth;
return $this;
}
/**
* @return string|string[]
*/
public function getPointStyle()
{
return $this->pointStyle;
}
/**
* @param string|string[] $pointStyle
*
* @return $this
*/
public function setPointStyle($pointStyle)
{
$this->pointStyle = $pointStyle;
return $this;
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace Artica\PHPChartJS\DataSet;
/**
* Class ScatterDataSet
* @package Artica\PHPChartJS\DataSet
*/
class ScatterDataSet extends LineDataSet
{
}

View File

@ -0,0 +1,42 @@
<?php
namespace Artica\PHPChartJS;
use Halfpastfour\Collection\Collection\ArrayAccess;
use JsonSerializable;
/**
* Class DataSetCollection
*
* @package Artica\PHPChartJS
*/
class DataSetCollection extends ArrayAccess implements JsonSerializable
{
/**
* @return array
*/
public function getArrayCopy()
{
$rows = [];
foreach ($this->data as $row) {
/** @var DataSet $row */
$rows[] = $row->getArrayCopy();
}
return $rows;
}
/**
* @return array
*/
public function jsonSerialize()
{
$rows = [];
foreach ($this->data as $row) {
/** @var DataSet $row */
$rows[] = $row->jsonSerialize();
}
return $rows;
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace Artica\PHPChartJS;
use JsonSerializable;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\Options\Fonts;
use Artica\PHPChartJS\Options\WaterMark;
/**
* Class Defaults
*
* @package Artica\PHPChartJS
*/
class Defaults implements ChartOwnedInterface, ArraySerializableInterface, JsonSerializable
{
use ChartOwned;
use ArraySerializable;
/**
* @var Fonts
*/
private $font;
/**
* Return Font.
*
* @return Font
*/
public function getFonts()
{
if (isset($this->font) === false) {
$this->font = new Fonts();
}
return $this->font;
}
/**
* Return Watermark.
*
* @return Watermark
*/
public function getWatermark()
{
if (isset($this->watermark) === false) {
$this->watermark = new WaterMark();
}
return $this->watermark;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace Artica\PHPChartJS\Delegate;
use Artica\PHPChartJS\ArraySerializableInterface;
/**
* Class ArraySerializable
*
* @package Artica\PHPChartJS\Model
*/
trait ArraySerializable
{
/**
* Returns an array copy of the properties and their current values in this class
*
* @return array
*/
public function getArrayCopy()
{
$currentValues = array_map(function ($value) {
if (is_object($value)) {
if ($value instanceof ArraySerializableInterface) {
return $value->getArrayCopy();
}
}
return $value;
}, get_object_vars($this));
// Filter out null values and return the remaining.
return array_filter($currentValues, function ($value, $key) {
return ! is_null($value) && $key !== 'owner';
}, ARRAY_FILTER_USE_BOTH);
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace Artica\PHPChartJS\Delegate;
use Artica\PHPChartJS\ArraySerializableInterface;
use JsonSerializable as JsonSerializableInterface;
/**
* Trait JsonSerializable
*
* @package Artica\PHPChartJS\Delegate
*/
trait JsonSerializable
{
/**
* @return array
*/
public function jsonSerialize()
{
return array_map(function ($value) {
if ($value instanceof JsonSerializableInterface) {
return $value->jsonSerialize();
} elseif ($value instanceof ArraySerializableInterface) {
return $value->getArrayCopy();
}
return $value;
}, $this->getArrayCopy());
}
/**
* @return array
*/
abstract public function getArrayCopy();
}

View File

@ -0,0 +1,40 @@
<?php
namespace Artica\PHPChartJS\Delegate;
/**
* Trait NumberUtils
*
* @package Artica\PHPChartJS\Delegate
*/
trait NumberUtils
{
/**
* @param array $input
*
* @return array
*/
public function recursiveToFloat(array $input)
{
array_walk_recursive($input, function (&$value) {
$value = floatval($value);
});
return $input;
}
/**
* @param array $input
*
* @return array
*/
public function recursiveToInt(array $input)
{
array_walk_recursive($input, function (&$value) {
$value = intval($value);
});
return $input;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Artica\PHPChartJS\Delegate;
/**
* Trait StringUtils
*
* @package Artica\PHPChartJS\Delegate
*/
trait StringUtils
{
/**
* @param array $input
*
* @return array
*/
public function recursiveToString(array $input)
{
array_walk_recursive($input, function (&$value) {
$value = strval($value);
});
return $input;
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace Artica\PHPChartJS;
/**
* Class Factory
* @package Artica\PHPChartJS
*/
class Factory
{
const BAR = 'bar';
const BUBBLE = 'bubble';
const DOUGHNUT = 'doughnut';
const HORIZONTAL_BAR = 'horizontalBar';
const LINE = 'line';
const PIE = 'pie';
const POLAR_AREA = 'polarArea';
const RADAR = 'radar';
const SCATTER = 'scatter';
/**
* @param $type
*
* @return Chart
*/
public function create($type)
{
$className = ucfirst($type);
$namespace = "\\Artica\\PHPChartJS\\Chart";
$path = "{$namespace}\\{$className}";
if (! class_exists($path)) {
throw new \InvalidArgumentException("Invalid chart type. {$path} does not exist.");
}
return new $path;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Artica\PHPChartJS;
use Halfpastfour\Collection\Collection\ArrayAccess;
use JsonSerializable;
/**
* Class LabelsCollection
*
* @package Artica\PHPChartJS
*/
class LabelsCollection extends ArrayAccess implements JsonSerializable
{
/**
* @return array
*/
public function jsonSerialize()
{
return $this->data;
}
}

View File

@ -0,0 +1,335 @@
<?php
namespace Artica\PHPChartJS;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\Options\Animation;
use Artica\PHPChartJS\Options\Elements;
use Artica\PHPChartJS\Options\Hover;
use Artica\PHPChartJS\Options\Layout;
use Artica\PHPChartJS\Options\Legend;
use Artica\PHPChartJS\Options\Scales;
use Artica\PHPChartJS\Options\Title;
use Artica\PHPChartJS\Options\Tooltips;
use JsonSerializable;
use Laminas\Json\Expr;
use Artica\PHPChartJS\Options\Plugins;
/**
* Class Options
*
* @package Artica\PHPChartJS
*/
class Options implements ChartOwnedInterface, ArraySerializableInterface, JsonSerializable
{
use ChartOwned;
use ArraySerializable;
/**
* @var Layout
*/
protected $layout;
/**
* @var Title
*/
protected $title;
/**
* @var Elements
*/
protected $elements;
/**
* @var Hover
*/
protected $hover;
/**
* @var \Laminas\Json\Expr
*/
protected $onClick;
/**
* @var Scales
*/
protected $scales;
/**
* @var Animation
*/
protected $animation;
/**
* @var Legend
*/
protected $legend;
/**
* Plugins.
*
* @var Plugin
*/
protected $plugins;
/**
* @var Tooltips
*/
protected $tooltips;
/**
* @var boolean
*/
protected $maintainAspectRatio;
/**
* @var boolean
*/
protected $responsive;
/**
* @var string
*/
protected $indexAxis;
/**
* @return Layout
*/
public function getLayout()
{
if (is_null($this->layout)) {
$this->layout = new Layout();
}
return $this->layout;
}
/**
* @return Elements
*/
public function getElements()
{
if (is_null($this->elements)) {
$this->elements = new Elements();
}
return $this->elements;
}
/**
* @return Title
*/
public function getTitle()
{
if (is_null($this->title)) {
$this->title = new Title();
}
return $this->title;
}
/**
* @return Hover
*/
public function getHover()
{
if (is_null($this->hover)) {
$this->hover = new Hover();
}
return $this->hover;
}
/**
* @return \Laminas\Json\Expr
*/
public function getOnClick()
{
return $this->onClick;
}
/**
* @param string $onClick
*
* @return $this
*/
public function setOnClick($onClick)
{
$this->onClick = new Expr(strval($onClick));
return $this;
}
/**
* @return Scales
*/
public function getScales()
{
if (is_null($this->scales)) {
$this->scales = new Scales();
}
return $this->scales;
}
/**
* @return Animation
*/
public function getAnimation()
{
if (is_null($this->animation)) {
$this->animation = new Animation();
}
return $this->animation;
}
/**
* @return bool
*/
public function disableAnimation()
{
$this->animation = false;
return $this->animation;
}
/**
* @return Legend
*/
public function getLegend()
{
if (is_null($this->legend)) {
$this->legend = new Legend();
}
return $this->legend;
}
/**
* Get plugin.
*
* @return Plugin
*/
public function getPlugins()
{
if ($this->plugins === null) {
$this->plugins = new Plugins();
}
return $this->plugins;
}
/**
* @return Tooltips
*/
public function getTooltips()
{
if (is_null($this->tooltips)) {
$this->tooltips = new Tooltips();
}
return $this->tooltips;
}
/**
* @return boolean
*/
public function isResponsive()
{
if (is_null($this->responsive)) {
$this->responsive = true;
}
return $this->responsive;
}
/**
* @param boolean $flag
*
* @return $this
*/
public function setResponsive($flag)
{
$this->responsive = boolval($flag);
return $this;
}
/**
* @return boolean
*/
public function isMaintainAspectRatio()
{
if (is_null($this->maintainAspectRatio)) {
$this->maintainAspectRatio = true;
}
return $this->maintainAspectRatio;
}
/**
* @param boolean $flag
*
* @return $this
*/
public function setMaintainAspectRatio($flag)
{
$this->maintainAspectRatio = boolval($flag);
return $this;
}
/**
* Get Index axis.
*
* @return string
*/
public function getIndexAxis()
{
return $this->indexAxis;
}
/**
* Set Index Axis.
*
* @param string $indexAxis Index Axis.
*
* @return $this
*/
public function setIndexAxis($indexAxis)
{
$this->indexAxis = $indexAxis;
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,126 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
use Laminas\Json\Expr;
/**
* Class Animation
*
* @package Artica\PHPChartJS\Options
*/
class Animation implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var int
*/
private $duration;
/**
* @var string
*/
private $easing;
/**
* @var Expr
*/
private $onProgress;
/**
* @var Expr
*/
private $onComplete;
/**
* @return int
*/
public function getDuration()
{
return $this->duration;
}
/**
* @param int $duration
*
* @return $this
*/
public function setDuration($duration)
{
$this->duration = $duration;
return $this;
}
/**
* @return string
*/
public function getEasing()
{
return $this->easing;
}
/**
* @param string $easing
*
* @return $this
*/
public function setEasing($easing)
{
$this->easing = $easing;
return $this;
}
/**
* @return Expr
*/
public function getOnProgress()
{
return $this->onProgress;
}
/**
* @param string $onProgress
*
* @return $this
*/
public function setOnProgress($onProgress)
{
$this->onProgress = new Expr(strval($onProgress));
return $this;
}
/**
* @return Expr
*/
public function getOnComplete()
{
return $this->onComplete;
}
/**
* @param string $onComplete
*
* @return $this
*/
public function setOnComplete($onComplete)
{
$this->onComplete = new Expr(strval($onComplete));
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace Artica\PHPChartJS\Options\Animation;
use Artica\PHPChartJS\Options\Animation;
/**
* Class PieAnimation
* @package Artica\PHPChartJS\Options\Animation
*/
class PieAnimation extends Animation
{
/**
* @var bool
*/
private $animateRotate;
/**
* @var bool
*/
private $animateScale;
/**
* @return bool
*/
public function isAnimateRotate()
{
return $this->animateRotate;
}
/**
* @param bool $animateRotate
*
* @return PieAnimation
*/
public function setAnimateRotate($animateRotate)
{
$this->animateRotate = $animateRotate;
return $this;
}
/**
* @return bool
*/
public function isAnimateScale()
{
return $this->animateScale;
}
/**
* @param bool $animateScale
*
* @return PieAnimation
*/
public function setAnimateScale($animateScale)
{
$this->animateScale = $animateScale;
return $this;
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options\Animation\PieAnimation;
/**
* Class BarOptions
* @package Artica\PHPChartJS\Options
*/
class BarOptions extends Options
{
}

View File

@ -0,0 +1,14 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options\Animation\PieAnimation;
/**
* Class BubbleOptions
* @package Artica\PHPChartJS\Options
*/
class BubbleOptions extends Options
{
}

View File

@ -0,0 +1,264 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
use Laminas\Json\Expr;
/**
* Class DataLabel
*
* @package Artica\PHPChartJS\Options
*/
class DataLabel implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var string
*/
private $display;
/**
* @var boolean
*/
private $clip;
/**
* @var boolean
*/
private $clamp;
/**
* @var string
*/
private $color;
/**
* @var integer
*/
private $offset;
/**
* @var string
*/
private $anchor;
/**
* @var string
*/
private $align;
/**
* @var Expr
*/
private $formatter;
/**
* @var Fonts
*/
private $font;
/**
* @return boolean
*/
public function isDisplay()
{
return $this->display;
}
/**
* @param string $display
*
* @return $this
*/
public function setDisplay($display)
{
$this->display = strval($display);
return $this;
}
/**
* @return string
*/
public function getColor()
{
return $this->color;
}
/**
* @param string $color
*
* @return $this
*/
public function setColor($color)
{
$this->color = strval($color);
return $this;
}
/**
* @return string
*/
public function getAnchor()
{
return $this->anchor;
}
/**
* @param string $anchor
*
* @return $this
*/
public function setAnchor($anchor)
{
$this->anchor = strval($anchor);
return $this;
}
/**
* @return integer
*/
public function getOffset()
{
return $this->offset;
}
/**
* @param integer $offset
*
* @return $this
*/
public function setOffset($offset)
{
$this->offset = intval($offset);
return $this;
}
/**
* @return string
*/
public function getAlign()
{
return $this->align;
}
/**
* @param string $align
*
* @return $this
*/
public function setAlign($align)
{
$this->align = strval($align);
return $this;
}
/**
* @return Expr
*/
public function getFormatter()
{
return $this->formatter;
}
/**
* @param string $formatter
*
* @return $this
*/
public function setFormatter($formatter)
{
$this->formatter = new Expr(strval($formatter));
return $this;
}
/**
* @return boolean
*/
public function getClamp()
{
return $this->clamp;
}
/**
* @param boolean $clamp
*
* @return $this
*/
public function setClamp($clamp)
{
$this->clamp = boolval($clamp);
return $this;
}
/**
* @return boolean
*/
public function getClip()
{
return $this->clip;
}
/**
* @param boolean $clip
*
* @return $this
*/
public function setClip($clip)
{
$this->clip = boolval($clip);
return $this;
}
/**
* Return Font.
*
* @return Font
*/
public function getFonts()
{
if (isset($this->font) === false) {
$this->font = new Fonts();
}
return $this->font;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,129 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\Options\Elements\Arc;
use Artica\PHPChartJS\Options\Elements\Line;
use Artica\PHPChartJS\Options\Elements\Point;
use Artica\PHPChartJS\Options\Elements\Rectangle;
use JsonSerializable;
/**
* Class Elements
*
* @package Artica\PHPChartJS\Options
*/
class Elements implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var Rectangle
*/
private $rectangle;
/**
* @var Line
*/
private $line;
/**
* @var Point
*/
private $point;
/**
* @var Arc
*/
private $arc;
/**
* @return Rectangle
*/
public function getRectangle()
{
return $this->rectangle;
}
/**
* @return Rectangle
*/
public function rectangle()
{
if (is_null($this->rectangle)) {
$this->rectangle = new Rectangle();
}
return $this->rectangle;
}
/**
* @return Line
*/
public function getLine()
{
return $this->line;
}
/**
* @return Line
*/
public function line()
{
if (is_null($this->line)) {
$this->line = new Line();
}
return $this->line;
}
/**
* @return Point
*/
public function getPoint()
{
return $this->point;
}
/**
* @return Point
*/
public function point()
{
if (is_null($this->point)) {
$this->point = new Point();
}
return $this->point;
}
/**
* @return Arc
*/
public function getArc()
{
return $this->arc;
}
/**
* @return Arc
*/
public function arc()
{
if (is_null($this->arc)) {
$this->arc = new Arc();
}
return $this->arc;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Artica\PHPChartJS\Options\Elements;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
/**
* Class Arc
*
* @package Artica\PHPChartJS\Options\Elements
*/
class Arc implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* Arc fill color.
*
* @default 'rgba(0,0,0,0.1)'
* @var string
*/
private $backgroundColor;
/**
* Arc stroke color.
*
* @default '#fff'
* @var string
*/
private $borderColor;
/**
* Arc stroke width.
*
* @default 2
* @var int
*/
private $borderWidth;
/**
* @return string
*/
public function getBackgroundColor()
{
return $this->backgroundColor;
}
/**
* @param string $backgroundColor
*
* @return Arc
*/
public function setBackgroundColor($backgroundColor)
{
$this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor);
return $this;
}
/**
* @return string
*/
public function getBorderColor()
{
return $this->borderColor;
}
/**
* @param string $borderColor
*
* @return Arc
*/
public function setBorderColor($borderColor)
{
$this->borderColor = is_null($borderColor) ? null : strval($borderColor);
return $this;
}
/**
* @return int
*/
public function getBorderWidth()
{
return $this->borderWidth;
}
/**
* @param int $borderWidth
*
* @return Arc
*/
public function setBorderWidth($borderWidth)
{
$this->borderWidth = intval($borderWidth);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,323 @@
<?php
namespace Artica\PHPChartJS\Options\Elements;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
/**
* Class Line
* @package Artica\PHPChartJS\Options\Elements
*/
class Line implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap */
const CAP_STYLE_BUTT = 'butt';
const CAP_STYLE_ROUND = 'round';
const CAP_STYLE_SQUARE = 'square';
/** https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin */
const JOIN_STYLE_ROUND = 'round';
const JOIN_STYLE_BEVEL = 'bevel';
const JOIN_STYLE_MITER = 'miter';
const FILL_LOCATION_ZERO = 'zero';
const FILL_LOCATION_TOP = 'top';
const FILL_LOCATION_BOTTOM = 'bottom';
const FILL_LOCATION_TRUE = true;
const FILL_LOCATION_FALSE = false;
/**
* Bézier curve tension (0 for no Bézier curves).
* @default 0.4
* @var float
*/
private $tension;
/**
* Line fill color.
* @default 'rgba(0,0,0,0.1)'
* @var string
*/
private $backgroundColor;
/**
* Line stroke width.
* @default 3
* @var int
*/
private $borderWidth;
/**
* Line stroke color.
* @default 'rgba(0,0,0,0.1)'
* @var string
*/
private $borderColor;
/**
* Line cap style.
* @default self::CAP_STYLE_BUTT
* @var string
*/
private $borderCapStyle;
/**
* Line dash. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
* @default []
* @var int[]
*/
private $borderDash;
/**
* Line dash offset.
* @default 0
* @var float
*/
private $borderDashOffset;
/**
* Line join style.
* @default self::JOIN_STYLE_MITER
* @var string
*/
private $borderJoinStyle;
/**
* true to keep Bézier control inside the chart, false for no restriction.
* @default true
* @var bool
*/
private $capBezierPoints;
/**
* Fill location: 'zero', 'top', 'bottom', true (eq. 'zero') or false (no fill).
* @default self::FILL_LOCATION_TRUE
* @var bool|string
*/
private $fill;
/**
* true to show the line as a stepped line (tension will be ignored).
* @default false
* @var bool
*/
private $stepped;
/**
* @return float
*/
public function getTension()
{
return $this->tension;
}
/**
* @param float $tension
* @return Line
*/
public function setTension($tension)
{
$this->tension = floatval($tension);
return $this;
}
/**
* @return string
*/
public function getBackgroundColor()
{
return $this->backgroundColor;
}
/**
* @param string $backgroundColor
* @return Line
*/
public function setBackgroundColor($backgroundColor)
{
$this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor);
return $this;
}
/**
* @return int
*/
public function getBorderWidth()
{
return $this->borderWidth;
}
/**
* @param int $borderWidth
* @return Line
*/
public function setBorderWidth($borderWidth)
{
$this->borderWidth = intval($borderWidth);
return $this;
}
/**
* @return string
*/
public function getBorderColor()
{
return $this->borderColor;
}
/**
* @param string $borderColor
* @return Line
*/
public function setBorderColor($borderColor)
{
$this->borderColor = is_null($borderColor) ? null : strval($borderColor);
return $this;
}
/**
* @return string
*/
public function getBorderCapStyle()
{
return $this->borderCapStyle;
}
/**
* @param string $borderCapStyle
* @return Line
*/
public function setBorderCapStyle($borderCapStyle)
{
$this->borderCapStyle = is_null($borderCapStyle) ? null : strval($borderCapStyle);
return $this;
}
/**
* @return int[]
*/
public function getBorderDash()
{
return $this->borderDash;
}
/**
* @param int[] $borderDash
* @return Line
*/
public function setBorderDash($borderDash)
{
if (is_array($borderDash)) {
array_walk_recursive(
$borderDash,
function (&$value) {
$value = intval($value);
}
);
$this->borderDash = $borderDash;
}
return $this;
}
/**
* @return float
*/
public function getBorderDashOffset()
{
return $this->borderDashOffset;
}
/**
* @param float $borderDashOffset
* @return Line
*/
public function setBorderDashOffset($borderDashOffset)
{
$this->borderDashOffset = floatval($borderDashOffset);
return $this;
}
/**
* @return string
*/
public function getBorderJoinStyle()
{
return $this->borderJoinStyle;
}
/**
* @param string $borderJoinStyle
* @return Line
*/
public function setBorderJoinStyle($borderJoinStyle)
{
$this->borderJoinStyle = is_null($borderJoinStyle) ? null : strval($borderJoinStyle);
return $this;
}
/**
* @return bool
*/
public function isCapBezierPoints()
{
return $this->capBezierPoints;
}
/**
* @param bool $capBezierPoints
* @return Line
*/
public function setCapBezierPoints($capBezierPoints)
{
$this->capBezierPoints = boolval($capBezierPoints);
return $this;
}
/**
* @return bool|string
*/
public function getFill()
{
return $this->fill;
}
/**
* @param bool|string $fill
* @return Line
*/
public function setFill($fill)
{
$this->fill = is_null($fill) ? null : (is_bool($fill) ? $fill : strval($fill));
return $this;
}
/**
* @return bool
*/
public function isStepped()
{
return $this->stepped;
}
/**
* @param bool $stepped
* @return Line
*/
public function setStepped($stepped)
{
$this->stepped = boolval($stepped);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,288 @@
<?php
namespace Artica\PHPChartJS\Options\Elements;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
/**
* Class Point
*
* @package Artica\PHPChartJS\Options\Elements
*/
class Point implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
const STYLE_CIRCLE = 'circle';
const STYLE_CROSS = 'cross';
const STYLE_CROSS_ROT = 'crossRot';
const STYLE_DASH = 'dash';
const STYLE_LINE = 'line';
const STYLE_RECT = 'rect';
const STYLE_RECT_ROUNDED = 'rectRounded';
const STYLE_RECT_ROT = 'rectRot';
const STYLE_RECT_STAR = 'star';
const STYLE_TRIANGLE = 'triangle';
/**
* Point radius.
*
* @default 3
* @var int
*/
private $radius;
/**
* Point style.
*
* @default self::STYLE_CIRCLE
* @var string
*/
private $pointStyle;
/**
* Point rotation (in degrees).
*
* @default 0
* @var int
*/
private $rotation;
/**
* Point fill color.
*
* @default 'rgba(0,0,0,0.1)'
* @var string
*/
private $backgroundColor;
/**
* Point stroke width.
*
* @default 1
* @var int
*/
private $borderWidth;
/**
* Point stroke color.
*
* @default 'rgba(0,0,0,0.1)'
* @var string
*/
private $borderColor;
/**
* Extra radius added to point radius for hit detection.
*
* @default 1
* @var int
*/
private $hitRadius;
/**
* Point radius when hovered.
*
* @default 4
* @var int
*/
private $hoverRadius;
/**
* Stroke width when hovered.
*
* @default 1
* @var int
*/
private $hoverBorderWidth;
/**
* @return int
*/
public function getRadius()
{
return $this->radius;
}
/**
* @param int $radius
*
* @return Point
*/
public function setRadius($radius)
{
$this->radius = intval($radius);
return $this;
}
/**
* @return string
*/
public function getPointStyle()
{
return $this->pointStyle;
}
/**
* @param string $pointStyle
*
* @return Point
*/
public function setPointStyle($pointStyle)
{
$this->pointStyle = is_null($pointStyle) ? null : strval($pointStyle);
return $this;
}
/**
* @return int
*/
public function getRotation()
{
return $this->rotation;
}
/**
* @param int $rotation
*
* @return Point
*/
public function setRotation($rotation)
{
$this->rotation = intval($rotation);
return $this;
}
/**
* @return string
*/
public function getBackgroundColor()
{
return $this->backgroundColor;
}
/**
* @param string $backgroundColor
*
* @return Point
*/
public function setBackgroundColor($backgroundColor)
{
$this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor);
return $this;
}
/**
* @return int
*/
public function getBorderWidth()
{
return $this->borderWidth;
}
/**
* @param int $borderWidth
*
* @return Point
*/
public function setBorderWidth($borderWidth)
{
$this->borderWidth = intval($borderWidth);
return $this;
}
/**
* @return string
*/
public function getBorderColor()
{
return $this->borderColor;
}
/**
* @param string $borderColor
*
* @return Point
*/
public function setBorderColor($borderColor)
{
$this->borderColor = is_null($borderColor) ? null : strval($borderColor);
return $this;
}
/**
* @return int
*/
public function getHitRadius()
{
return $this->hitRadius;
}
/**
* @param int $hitRadius
*
* @return Point
*/
public function setHitRadius($hitRadius)
{
$this->hitRadius = intval($hitRadius);
return $this;
}
/**
* @return int
*/
public function getHoverRadius()
{
return $this->hoverRadius;
}
/**
* @param int $hoverRadius
*
* @return Point
*/
public function setHoverRadius($hoverRadius)
{
$this->hoverRadius = intval($hoverRadius);
return $this;
}
/**
* @return int
*/
public function getHoverBorderWidth()
{
return $this->hoverBorderWidth;
}
/**
* @param int $hoverBorderWidth
*
* @return Point
*/
public function setHoverBorderWidth($hoverBorderWidth)
{
$this->hoverBorderWidth = intval($hoverBorderWidth);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,142 @@
<?php
namespace Artica\PHPChartJS\Options\Elements;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
/**
* Class Rectangle
*
* @package Artica\PHPChartJS\Options\Elements
*/
class Rectangle implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
const BORDER_SKIPPED_BOTTOM = 'bottom';
const BORDER_SKIPPED_LEFT = 'left';
const BORDER_SKIPPED_TOP = 'top';
const BORDER_SKIPPED_RIGHT = 'right';
/**
* Bar fill color.
*
* @default 'rgba(0,0,0,0.1)'
* @var string
*/
private $backgroundColor;
/**
* Bar stroke width.
*
* @default 0
* @var int
*/
private $borderWidth;
/**
* Bar stroke color.
*
* @default 'rgba(0,0,0,0.1)'
* @var string
*/
private $borderColor;
/**
* Skipped (excluded) border: 'bottom', 'left', 'top' or 'right'.
*
* @default self::BORDER_SKIPPED_BOTTOM
* @var string
*/
private $borderSkipped;
/**
* @return string
*/
public function getBackgroundColor()
{
return $this->backgroundColor;
}
/**
* @param string $backgroundColor
*
* @return Rectangle
*/
public function setBackgroundColor($backgroundColor)
{
$this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor);
return $this;
}
/**
* @return int
*/
public function getBorderWidth()
{
return $this->borderWidth;
}
/**
* @param int $borderWidth
*
* @return Rectangle
*/
public function setBorderWidth($borderWidth)
{
$this->borderWidth = intval($borderWidth);
return $this;
}
/**
* @return string
*/
public function getBorderColor()
{
return $this->borderColor;
}
/**
* @param string $borderColor
*
* @return Rectangle
*/
public function setBorderColor($borderColor)
{
$this->borderColor = is_null($borderColor) ? null : strval($borderColor);
return $this;
}
/**
* @return string
*/
public function getBorderSkipped()
{
return $this->borderSkipped;
}
/**
* @param string $borderSkipped
*
* @return Rectangle
*/
public function setBorderSkipped($borderSkipped)
{
$this->borderSkipped = is_null($borderSkipped) ? null : strval($borderSkipped);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,163 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
/**
* Class Fonts
*
* @package Artica\PHPChartJS\Options
*/
class Fonts implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var integer
*/
private $size;
/**
* @var string
*/
private $family;
/**
* @var string
*/
private $color;
/**
* @var string
*/
private $style;
/**
* @var string
*/
private $weight;
/**
* @return integer
*/
public function getSize()
{
return $this->size;
}
/**
* @param integer $size
*
* @return $this
*/
public function setSize($size)
{
$this->size = intval($size);
return $this;
}
/**
* @return string
*/
public function getFamily()
{
return $this->family;
}
/**
* @param string $family
*
* @return $this
*/
public function setFamily($family)
{
$this->family = strval($family);
return $this;
}
/**
* @return string
*/
public function getColor()
{
return $this->color;
}
/**
* @param string $color
*
* @return $this
*/
public function setColor($color)
{
$this->color = strval($color);
return $this;
}
/**
* @return string
*/
public function getStyle()
{
return $this->style;
}
/**
* @param string $style
*
* @return $this
*/
public function setStyle($style)
{
$this->style = strval($style);
return $this;
}
/**
* @return string
*/
public function getWeight()
{
return $this->weight;
}
/**
* @param string $weight
*
* @return $this
*/
public function setWeight($weight)
{
$this->weight = strval($weight);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,134 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
use Laminas\Json\Expr;
/**
* Class Hover
*
* @package Artica\PHPChartJS\Options
*/
class Hover implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var string
*/
private $mode;
/**
* @var bool
*/
private $intersect;
/**
* @var int
*/
private $animationDuration;
/**
* @var Expr
*/
private $onHover;
/**
* @return string
*/
public function getMode()
{
return $this->mode;
}
/**
* @param string $mode
*
* @return $this
*/
public function setMode($mode)
{
$this->mode = strval($mode);
return $this;
}
/**
* @return bool
*/
public function isIntersect()
{
return $this->intersect;
}
/**
* @return bool
*/
public function getIntersect()
{
return $this->intersect;
}
/**
* @param bool $intersect
*
* @return $this
*/
public function setIntersect($intersect)
{
$this->intersect = ! ! $intersect;
return $this;
}
/**
* @return int
*/
public function getAnimationDuration()
{
return $this->animationDuration;
}
/**
* @param int $animationDuration
*
* @return $this
*/
public function setAnimationDuration($animationDuration)
{
$this->animationDuration = intval($animationDuration);
return $this;
}
/**
* @return \Laminas\Json\Expr
*/
public function getOnHover()
{
return $this->onHover;
}
/**
* @param Expr $onHover
*
* @return $this
*/
public function setOnHover($onHover)
{
$this->onHover = new Expr(strval($onHover));
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\Options\Layout\Padding;
use JsonSerializable;
/**
* Class Layout
*
* @package Artica\PHPChartJS\Options
*/
class Layout implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var int|Padding
*/
private $padding;
/**
* @param int $padding
*/
public function setPadding($padding)
{
$this->padding = intval($padding);
}
/**
* @return int|Padding
*/
public function getPadding()
{
return $this->padding;
}
/**
* @return Padding
*/
public function padding()
{
if (is_null($this->padding)) {
$this->padding = new Padding();
}
return $this->padding;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,124 @@
<?php
namespace Artica\PHPChartJS\Options\Layout;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
/**
* Class Padding
* @package Artica\PHPChartJS\Options\Layout
*/
class Padding implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var int
*/
private $bottom;
/**
* @var int
*/
private $left;
/**
* @var int
*/
private $right;
/**
* @var int
*/
private $top;
/**
* @return int
*/
public function getBottom()
{
return $this->bottom;
}
/**
* @param int $bottom
*
* @return $this
*/
public function setBottom($bottom)
{
$this->bottom = intval($bottom);
return $this;
}
/**
* @return int
*/
public function getLeft()
{
return $this->left;
}
/**
* @param int $left
*
* @return $this
*/
public function setLeft($left)
{
$this->left = intval($left);
return $this;
}
/**
* @return int
*/
public function getRight()
{
return $this->right;
}
/**
* @param int $right
*
* @return $this
*/
public function setRight($right)
{
$this->right = intval($right);
return $this;
}
/**
* @return int
*/
public function getTop()
{
return $this->top;
}
/**
* @param int $top
*
* @return $this
*/
public function setTop($top)
{
$this->top = intval($top);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,243 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\LabelsCollection;
use JsonSerializable;
use Laminas\Json\Expr;
/**
* Class Legend
*
* @package Artica\PHPChartJS\Options
*/
class Legend implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var boolean
*/
private $display;
/**
* @var string
*/
private $position;
/**
* @var boolean
*/
private $fullWidth;
/**
* @var Expr
*/
private $onClick;
/**
* @var Expr
*/
private $onHover;
/**
* @var LabelsCollection
*/
private $labels;
/**
* @var boolean
*/
private $reverse;
/**
* Align.
*
* @var string
*/
protected string $align;
/**
* @return boolean
*/
public function isDisplay()
{
return $this->display;
}
/**
* @param boolean $display
*
* @return $this
*/
public function setDisplay($display)
{
$this->display = boolval($display);
return $this;
}
/**
* @return string
*/
public function getPosition()
{
return $this->position;
}
/**
* @param string $position
*
* @return $this
*/
public function setPosition($position)
{
$this->position = strval($position);
return $this;
}
/**
* @return boolean
*/
public function isFullWidth()
{
return $this->fullWidth;
}
/**
* @param boolean $fullWidth
*
* @return $this
*/
public function setFullWidth($fullWidth)
{
$this->fullWidth = boolval($fullWidth);
return $this;
}
/**
* @return Expr
*/
public function getOnClick()
{
return $this->onClick;
}
/**
* @param string $onClick
*
* @return $this
*/
public function setOnClick($onClick)
{
$this->onClick = new Expr(strval($onClick));
return $this;
}
/**
* @return Expr
*/
public function getOnHover()
{
return $this->onHover;
}
/**
* @param string $onHover
*
* @return $this
*/
public function setOnHover($onHover)
{
$this->onHover = new Expr(strval($onHover));
return $this;
}
/**
* @return LabelsCollection
*/
public function labels()
{
if (is_null($this->labels)) {
$this->labels = new LabelsCollection();
}
return $this->labels;
}
/**
* @return boolean
*/
public function isReverse()
{
return $this->reverse;
}
/**
* @param boolean $reverse
*
* @return $this
*/
public function setReverse($reverse)
{
$this->reverse = boolval($reverse);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
/**
* Get align.
*
* @return string
*/
public function getAlign()
{
return $this->align;
}
/**
* Set align.
*
* @param string $align Align.
*
* @return $this
*/
public function setAlign(string $align)
{
$this->align = $align;
return $this;
}
}

View File

@ -0,0 +1,226 @@
<?php
namespace Artica\PHPChartJS\Options\Legend;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
use Laminas\Json\Expr;
/**
* Class PieLegend
*
* @package Artica\PHPChartJS\Options\Legend
*/
class Labels implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var int
*/
private $boxWidth;
/**
* @var int
*/
private $fontSize;
/**
* @var string
*/
private $fontStyle;
/**
* @var string
*/
private $fontColor;
/**
* @var string
*/
private $fontFamily;
/**
* @var int
*/
private $padding;
/**
* @var Expr
*/
private $generateLabels;
/**
* @var bool
*/
private $usePointStyle;
/**
* @return int
*/
public function getBoxWidth()
{
return $this->boxWidth;
}
/**
* @param int $boxWidth
*
* @return Labels
*/
public function setBoxWidth($boxWidth)
{
$this->boxWidth = intval($boxWidth);
return $this;
}
/**
* @return mixed
*/
public function getFontSize()
{
return $this->fontSize;
}
/**
* @param int $fontSize
*
* @return Labels
*/
public function setFontSize($fontSize)
{
$this->fontSize = intval($fontSize);
return $this;
}
/**
* @return string
*/
public function getFontStyle()
{
return $this->fontStyle;
}
/**
* @param string $fontStyle
*
* @return Labels
*/
public function setFontStyle($fontStyle)
{
$this->fontStyle = strval($fontStyle);
return $this;
}
/**
* @return string
*/
public function getFontColor()
{
return $this->fontColor;
}
/**
* @param string $fontColor
*
* @return Labels
*/
public function setFontColor($fontColor)
{
$this->fontColor = strval($fontColor);
return $this;
}
/**
* @return string
*/
public function getFontFamily()
{
return $this->fontFamily;
}
/**
* @param string $fontFamily
*
* @return Labels
*/
public function setFontFamily($fontFamily)
{
$this->fontFamily = strval($fontFamily);
return $this;
}
/**
* @return int
*/
public function getPadding()
{
return $this->padding;
}
/**
* @param int $padding
*
* @return Labels
*/
public function setPadding($padding)
{
$this->padding = intval($padding);
return $this;
}
/**
* @return Expr
*/
public function getGenerateLabels()
{
return $this->generateLabels;
}
/**
* @param string $generateLabels
*
* @return Labels
*/
public function setGenerateLabels($generateLabels)
{
$this->generateLabels = new Expr(strval($generateLabels));
return $this;
}
/**
* @return bool
*/
public function isUsePointStyle()
{
return $this->usePointStyle;
}
/**
* @param bool $usePointStyle
*
* @return Labels
*/
public function setUsePointStyle($usePointStyle)
{
$this->usePointStyle = ! ! $usePointStyle;
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Artica\PHPChartJS\Options\Legend;
use Artica\PHPChartJS\Options\Legend;
/**
* Class PieLegend
* @package Artica\PHPChartJS\Options\Legend
*/
class PieLegend extends Legend
{
}

View File

@ -0,0 +1,14 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options\Animation\PieAnimation;
/**
* Class LineOptions
* @package Artica\PHPChartJS\Options
*/
class LineOptions extends Options
{
}

View File

@ -0,0 +1,100 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options\Animation\PieAnimation;
/**
* Class PieOptions
* @package Artica\PHPChartJS\Options
*/
class PieOptions extends Options
{
/**
* @var int
*/
protected $cutoutPercentage;
/**
* @var float
*/
protected $rotation;
/**
* @var float
*/
protected $circumference;
/**
* @return Animation
*/
public function getAnimation()
{
if (is_null($this->animation)) {
$this->animation = new PieAnimation();
}
return $this->animation;
}
/**
* @return int
*/
public function getCutoutPercentage()
{
return $this->cutoutPercentage;
}
/**
* @param int $cutoutPercentage
*
* @return $this
*/
public function setCutoutPercentage($cutoutPercentage)
{
$this->cutoutPercentage = $cutoutPercentage;
return $this;
}
/**
* @return float
*/
public function getRotation()
{
return $this->rotation;
}
/**
* @param float $rotation
*
* @return $this
*/
public function setRotation($rotation)
{
$this->rotation = $rotation;
return $this;
}
/**
* @return float
*/
public function getCircumference()
{
return $this->circumference;
}
/**
* @param float $circumference
*
* @return $this
*/
public function setCircumference($circumference)
{
$this->circumference = $circumference;
return $this;
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\Options\Legend;
use JsonSerializable;
/**
* Undocumented class
*/
class Plugins implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* Return Legend.
*
* @return Legend
*/
public function getLegend()
{
if (isset($this->legend) === false) {
$this->legend = new Legend();
}
return $this->legend;
}
/**
* Return Title.
*
* @return Title
*/
public function getTitle()
{
if (isset($this->title) === false) {
$this->title = new Title();
}
return $this->title;
}
/**
* Return Data label.
*
* @return DataLabel
*/
public function getDataLabel()
{
if (isset($this->datalabels) === false) {
$this->datalabels = new DataLabel();
}
return $this->datalabels;
}
/**
* Serialize.
*
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options\Animation\PieAnimation;
/**
* Class PolarAreaOptions
* @package Artica\PHPChartJS\Options
*/
class PolarAreaOptions extends Options
{
}

View File

@ -0,0 +1,14 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options\Animation\PieAnimation;
/**
* Class RadarOptions
* @package Artica\PHPChartJS\Options
*/
class RadarOptions extends Options
{
}

View File

@ -0,0 +1,629 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\Options\Scales\GridLines;
use Artica\PHPChartJS\Options\Scales\ScaleLabel;
use Artica\PHPChartJS\Options\Scales\Ticks;
use JsonSerializable;
/**
* Class Scale
*
* @package Artica\PHPChartJS\Options
*/
abstract class Scale implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var string
*/
protected $type;
/**
* @var string
*/
protected $bounds;
/**
* @var bool
*/
protected $display;
/**
* @var string
*/
protected $id;
/**
* @var bool
*/
protected $stacked;
/**
* @var int
*/
protected $barThickness;
/**
* @var string
*/
protected $position;
/**
* @var string
*/
protected $beforeUpdate;
/**
* @var string
*/
protected $beforeSetDimensions;
/**
* @var string
*/
protected $afterSetDimensions;
/**
* @var string
*/
protected $beforeDataLimits;
/**
* @var string
*/
protected $afterDataLimits;
/**
* @var string
*/
protected $beforeBuildTicks;
/**
* @var string
*/
protected $afterBuildTicks;
/**
* @var string
*/
protected $beforeTickToLabelConversion;
/**
* @var string
*/
protected $afterTickToLabelConversion;
/**
* @var string
*/
protected $beforeCalculateTickRotation;
/**
* @var string
*/
protected $afterCalculateTickRotation;
/**
* @var string
*/
protected $beforeFit;
/**
* @var string
*/
protected $afterFit;
/**
* @var string
*/
protected $afterUpdate;
/**
* @var GridLines
*/
protected $grid;
/**
* @var ScaleLabel
*/
protected $scaleLabel;
/**
* @var Ticks
*/
protected $ticks;
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string $type
*
* @return $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* @return string
*/
public function getBounds()
{
return $this->bounds;
}
/**
* @param string $bounds
*
* @return $this
*/
public function setBounds($bounds)
{
$this->bounds = $bounds;
return $this;
}
/**
* @return bool
*/
public function isDisplay()
{
return $this->display;
}
/**
* @param bool $display
*
* @return $this
*/
public function setDisplay($display)
{
$this->display = $display;
return $this;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id
*
* @return $this
*/
public function setId($id)
{
$this->id = strval($id);
return $this;
}
/**
* @return bool
*/
public function isStacked()
{
return $this->stacked;
}
/**
* @param bool $stacked
*
* @return $this
*/
public function setStacked($stacked)
{
$this->stacked = ! ! $stacked;
return $this;
}
/**
* @return int
*/
public function getBarThickness()
{
return $this->barThickness;
}
/**
* @param int $barThickness
*
* @return $this
*/
public function setBarThickness($barThickness)
{
$this->barThickness = intval($barThickness);
return $this;
}
/**
* @return string
*/
public function getPosition()
{
return $this->position;
}
/**
* @param string $position
*
* @return $this
*/
public function setPosition($position)
{
$this->position = strval($position);
return $this;
}
/**
* @return string
*/
public function getBeforeUpdate()
{
return $this->beforeUpdate;
}
/**
* @param string $beforeUpdate
*
* @return $this
*/
public function setBeforeUpdate($beforeUpdate)
{
$this->beforeUpdate = strval($beforeUpdate);
return $this;
}
/**
* @return string
*/
public function getBeforeSetDimensions()
{
return $this->beforeSetDimensions;
}
/**
* @param string $beforeSetDimensions
*
* @return $this
*/
public function setBeforeSetDimensions($beforeSetDimensions)
{
$this->beforeSetDimensions = strval($beforeSetDimensions);
return $this;
}
/**
* @return string
*/
public function getAfterSetDimensions()
{
return $this->afterSetDimensions;
}
/**
* @param string $afterSetDimensions
*
* @return $this
*/
public function setAfterSetDimensions($afterSetDimensions)
{
$this->afterSetDimensions = strval($afterSetDimensions);
return $this;
}
/**
* @return string
*/
public function getBeforeDataLimits()
{
return $this->beforeDataLimits;
}
/**
* @param string $beforeDataLimits
*
* @return $this
*/
public function setBeforeDataLimits($beforeDataLimits)
{
$this->beforeDataLimits = strval($beforeDataLimits);
return $this;
}
/**
* @return string
*/
public function getAfterDataLimits()
{
return $this->afterDataLimits;
}
/**
* @param string $afterDataLimits
*
* @return $this
*/
public function setAfterDataLimits($afterDataLimits)
{
$this->afterDataLimits = strval($afterDataLimits);
return $this;
}
/**
* @return string
*/
public function getBeforeBuildTicks()
{
return $this->beforeBuildTicks;
}
/**
* @param string $beforeBuildTicks
*
* @return $this
*/
public function setBeforeBuildTicks($beforeBuildTicks)
{
$this->beforeBuildTicks = strval($beforeBuildTicks);
return $this;
}
/**
* @return string
*/
public function getAfterBuildTicks()
{
return $this->afterBuildTicks;
}
/**
* @param string $afterBuildTicks
*
* @return $this
*/
public function setAfterBuildTicks($afterBuildTicks)
{
$this->afterBuildTicks = strval($afterBuildTicks);
return $this;
}
/**
* @return string
*/
public function getBeforeTickToLabelConversion()
{
return $this->beforeTickToLabelConversion;
}
/**
* @param string $beforeTickToLabelConversion
*
* @return $this
*/
public function setBeforeTickToLabelConversion($beforeTickToLabelConversion)
{
$this->beforeTickToLabelConversion = strval($beforeTickToLabelConversion);
return $this;
}
/**
* @return string
*/
public function getAfterTickToLabelConversion()
{
return $this->afterTickToLabelConversion;
}
/**
* @param string $afterTickToLabelConversion
*
* @return $this
*/
public function setAfterTickToLabelConversion($afterTickToLabelConversion)
{
$this->afterTickToLabelConversion = strval($afterTickToLabelConversion);
return $this;
}
/**
* @return string
*/
public function getBeforeCalculateTickRotation()
{
return $this->beforeCalculateTickRotation;
}
/**
* @param string $beforeCalculateTickRotation
*
* @return $this
*/
public function setBeforeCalculateTickRotation($beforeCalculateTickRotation)
{
$this->beforeCalculateTickRotation = strval($beforeCalculateTickRotation);
return $this;
}
/**
* @return string
*/
public function getAfterCalculateTickRotation()
{
return $this->afterCalculateTickRotation;
}
/**
* @param string $afterCalculateTickRotation
*
* @return $this
*/
public function setAfterCalculateTickRotation($afterCalculateTickRotation)
{
$this->afterCalculateTickRotation = strval($afterCalculateTickRotation);
return $this;
}
/**
* @return string
*/
public function getBeforeFit()
{
return $this->beforeFit;
}
/**
* @param string $beforeFit
*
* @return $this
*/
public function setBeforeFit($beforeFit)
{
$this->beforeFit = strval($beforeFit);
return $this;
}
/**
* @return string
*/
public function getAfterFit()
{
return $this->afterFit;
}
/**
* @param string $afterFit
*
* @return $this
*/
public function setAfterFit($afterFit)
{
$this->afterFit = strval($afterFit);
return $this;
}
/**
* @return string
*/
public function getAfterUpdate()
{
return $this->afterUpdate;
}
/**
* @param string $afterUpdate
*
* @return $this
*/
public function setAfterUpdate($afterUpdate)
{
$this->afterUpdate = strval($afterUpdate);
return $this;
}
/**
* @return GridLines
*/
public function getGrid()
{
return $this->grid;
}
/**
* @return GridLines
*/
public function grid()
{
if (is_null($this->grid)) {
$this->grid = new GridLines();
}
return $this->grid;
}
/**
* @return ScaleLabel
*/
public function getScaleLabel()
{
return $this->scaleLabel;
}
/**
* @return ScaleLabel
*/
public function scaleLabel()
{
if (is_null($this->scaleLabel)) {
$this->scaleLabel = new ScaleLabel();
}
return $this->scaleLabel;
}
/**
* @return Ticks
*/
public function getTicks()
{
return $this->ticks;
}
/**
* @return Ticks
*/
public function ticks()
{
if (is_null($this->ticks)) {
$this->ticks = new Ticks();
}
return $this->ticks;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\Options\Scales\XAxis;
use Artica\PHPChartJS\Options\Scales\XAxisCollection;
use Artica\PHPChartJS\Options\Scales\YAxis;
use Artica\PHPChartJS\Options\Scales\YAxisCollection;
use JsonSerializable;
/**
* Class Scales
* @package Artica\PHPChartJS\Options
*/
class Scales implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var XAxisCollection
*/
private $x;
/**
* @var YAxisCollection
*/
private $y;
/**
* @return XAxis
*/
public function createX()
{
return new XAxis();
}
/**
* @return YAxis
*/
public function createY()
{
return new YAxis();
}
/**
* @return XAxis
*/
public function getX()
{
if (is_null($this->x)) {
$this->x = new XAxis();
}
return $this->x;
}
/**
* @return YAxis
*/
public function getY()
{
if (is_null($this->y)) {
$this->y = new YAxis();
}
return $this->y;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,339 @@
<?php
namespace Artica\PHPChartJS\Options\Scales;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\Delegate\NumberUtils;
use Artica\PHPChartJS\Delegate\StringUtils;
use JsonSerializable;
/**
* Class GridLines
*
* @package Artica\PHPChartJS\Options\Scales
*/
class GridLines implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
use StringUtils;
use NumberUtils;
/**
* @var bool
*/
private $display;
/**
* @var string|string[]
*/
private $color;
/**
* @var float[]|null
*/
private $borderDash;
/**
* @var float
*/
private $borderDashOffset;
/**
* @var int|int[]
*/
private $lineWidth;
/**
* @var bool
*/
private $drawBorder;
/**
* @var bool
*/
private $drawOnChartArea;
/**
* @var bool
*/
private $drawTicks;
/**
* @var int
*/
private $tickMarkLength;
/**
* @var int
*/
private $zeroLineWidth;
/**
* @var string
*/
private $zeroLineColor;
/**
* @var bool
*/
private $offsetGridLines;
/**
* @return bool
*/
public function isDisplay()
{
return $this->display;
}
/**
* @param bool $display
*
* @return $this
*/
public function setDisplay($display)
{
$this->display = $display;
return $this;
}
/**
* @return string|string[]
*/
public function getColor()
{
return $this->color;
}
/**
* @param string|string[] $color
*
* @return $this
*/
public function setColor($color)
{
if (is_array($color)) {
$this->color = $this->recursiveToString($color);
} else {
$this->color = is_null($color) ? null : strval($color);
}
return $this;
}
/**
* @return float[]|null
*/
public function getBorderDash()
{
return $this->borderDash;
}
/**
* @param float[] $borderDash
*
* @return $this
*/
public function setBorderDash($borderDash)
{
if (is_array($borderDash)) {
$this->borderDash = $this->recursiveToFloat($borderDash);
}
return $this;
}
/**
* @return float
*/
public function getBorderDashOffset()
{
return $this->borderDashOffset;
}
/**
* @param float $borderDashOffset
*
* @return $this
*/
public function setBorderDashOffset($borderDashOffset)
{
$this->borderDashOffset = floatval($borderDashOffset);
return $this;
}
/**
* @return int|int[]
*/
public function getLineWidth()
{
return $this->lineWidth;
}
/**
* @param int|int[] $lineWidth
*
* @return $this
*/
public function setLineWidth($lineWidth)
{
if (is_array($lineWidth)) {
$this->lineWidth = $this->recursiveToInt($lineWidth);
} else {
$this->lineWidth = is_null($lineWidth) ? null : intval($lineWidth);
}
return $this;
}
/**
* @return bool
*/
public function isDrawBorder()
{
return $this->drawBorder;
}
/**
* @param bool $drawBorder
*
* @return $this
*/
public function setDrawBorder($drawBorder)
{
$this->drawBorder = boolval($drawBorder);
return $this;
}
/**
* @return bool
*/
public function isDrawOnChartArea()
{
return $this->drawOnChartArea;
}
/**
* @param bool $drawOnChartArea
*
* @return $this
*/
public function setDrawOnChartArea($drawOnChartArea)
{
$this->drawOnChartArea = boolval($drawOnChartArea);
return $this;
}
/**
* @return bool
*/
public function isDrawTicks()
{
return $this->drawTicks;
}
/**
* @param bool $drawTicks
*
* @return $this
*/
public function setDrawTicks($drawTicks)
{
$this->drawTicks = boolval($drawTicks);
return $this;
}
/**
* @return int
*/
public function getTickMarkLength()
{
return $this->tickMarkLength;
}
/**
* @param int $tickMarkLength
*
* @return $this
*/
public function setTickMarkLength($tickMarkLength)
{
$this->tickMarkLength = intval($tickMarkLength);
return $this;
}
/**
* @return int
*/
public function getZeroLineWidth()
{
return $this->zeroLineWidth;
}
/**
* @param int $zeroLineWidth
*
* @return $this
*/
public function setZeroLineWidth($zeroLineWidth)
{
$this->zeroLineWidth = intval($zeroLineWidth);
return $this;
}
/**
* @return string
*/
public function getZeroLineColor()
{
return $this->zeroLineColor;
}
/**
* @param string $zeroLineColor
*
* @return $this
*/
public function setZeroLineColor($zeroLineColor)
{
$this->zeroLineColor = is_null($zeroLineColor) ? null : strval($zeroLineColor);
return $this;
}
/**
* @return bool
*/
public function isOffsetGridLines()
{
return $this->offsetGridLines;
}
/**
* @param bool $offsetGridLines
*
* @return $this
*/
public function setOffsetGridLines($offsetGridLines)
{
$this->offsetGridLines = boolval($offsetGridLines);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,175 @@
<?php
namespace Artica\PHPChartJS\Options\Scales;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
/**
* Class ScaleLabel
*
* @package Artica\PHPChartJS\Options\Scales
*/
class ScaleLabel implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var bool
*/
private $display;
/**
* @var string
*/
private $labelString;
/**
* @var string
*/
private $fontColor;
/**
* @var string
*/
private $fontFamily;
/**
* @var int
*/
private $fontSize;
/**
* @var string
*/
private $fontStyle;
/**
* @return bool
*/
public function isDisplay()
{
return $this->display;
}
/**
* @param bool $display
*
* @return $this
*/
public function setDisplay($display)
{
$this->display = ! ! $display;
return $this;
}
/**
* @return string
*/
public function getLabelString()
{
return $this->labelString;
}
/**
* @param string $labelString
*
* @return $this
*/
public function setLabelString($labelString)
{
$this->labelString = strval($labelString);
return $this;
}
/**
* @return string
*/
public function getFontColor()
{
return $this->fontColor;
}
/**
* @param string $fontColor
*
* @return $this
*/
public function setFontColor($fontColor)
{
$this->fontColor = strval($fontColor);
return $this;
}
/**
* @return string
*/
public function getFontFamily()
{
return $this->fontFamily;
}
/**
* @param string $fontFamily
*
* @return $this
*/
public function setFontFamily($fontFamily)
{
$this->fontFamily = strval($fontFamily);
return $this;
}
/**
* @return int
*/
public function getFontSize()
{
return $this->fontSize;
}
/**
* @param int $fontSize
*
* @return $this
*/
public function setFontSize($fontSize)
{
$this->fontSize = intval($fontSize);
return $this;
}
/**
* @return string
*/
public function getFontStyle()
{
return $this->fontStyle;
}
/**
* @param string $fontStyle
*
* @return $this
*/
public function setFontStyle($fontStyle)
{
$this->fontStyle = strval($fontStyle);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,396 @@
<?php
namespace Artica\PHPChartJS\Options\Scales;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
use Laminas\Json\Expr;
use Artica\PHPChartJS\Options\Fonts;
/**
* Class Ticks
*
* @package Artica\PHPChartJS\Options\Scales
*/
class Ticks implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var float
*/
private $suggestedMin;
/**
* @var bool
*/
private $beginAtZero;
/**
* @var float
*/
private $stepSize;
/**
* @var bool
*/
private $autoSkip;
/**
* @var int
*/
private $autoSkipPadding;
/**
* @var Expr
*/
private $callback;
/**
* @var bool
*/
private $display;
/**
* @var Font
*/
private $font;
/**
* @var int
*/
private $labelOffset;
/**
* @var int
*/
private $maxRotation;
/**
* @var int
*/
private $minRotation;
/**
* @var bool
*/
private $mirror;
/**
* @var int
*/
private $padding;
/**
* @var bool
*/
private $reverse;
/**
* @var int
*/
private $max;
/**
* @return float
*/
public function getSuggestedMin()
{
return $this->suggestedMin;
}
/**
* @param float $suggestedMin
*
* @return $this
*/
public function setSuggestedMin($suggestedMin)
{
$this->suggestedMin = floatval($suggestedMin);
return $this;
}
/**
* @return bool
*/
public function isBeginAtZero()
{
return $this->beginAtZero;
}
/**
* @param bool $beginAtZero
*
* @return $this
*/
public function setBeginAtZero($beginAtZero)
{
$this->beginAtZero = boolval($beginAtZero);
return $this;
}
/**
* @return float
*/
public function getStepSize()
{
return $this->stepSize;
}
/**
* @param float $stepSize
*
* @return $this
*/
public function setStepSize($stepSize)
{
$this->stepSize = floatval($stepSize);
return $this;
}
/**
* @return bool
*/
public function isAutoSkip()
{
return $this->autoSkip;
}
/**
* @param bool $autoSkip
*
* @return $this
*/
public function setAutoSkip($autoSkip)
{
$this->autoSkip = boolval($autoSkip);
return $this;
}
/**
* @return int
*/
public function getAutoSkipPadding()
{
return $this->autoSkipPadding;
}
/**
* @param int $autoSkipPadding
*
* @return $this
*/
public function setAutoSkipPadding($autoSkipPadding)
{
$this->autoSkipPadding = intval($autoSkipPadding);
return $this;
}
/**
* @return Expr
*/
public function getCallback()
{
return $this->callback;
}
/**
* @param string $callback
*
* @return $this
*/
public function setCallback($callback)
{
$this->callback = new Expr(strval($callback));
return $this;
}
/**
* @return bool
*/
public function isDisplay()
{
return $this->display;
}
/**
* @param bool $display
*
* @return $this
*/
public function setDisplay($display)
{
$this->display = boolval($display);
return $this;
}
/**
* Return Font.
*
* @return Font
*/
public function getFonts()
{
if (isset($this->font) === false) {
$this->font = new Fonts();
}
return $this->font;
}
/**
* @return int
*/
public function getLabelOffset()
{
return $this->labelOffset;
}
/**
* @param int $labelOffset
*
* @return $this
*/
public function setLabelOffset($labelOffset)
{
$this->labelOffset = intval($labelOffset);
return $this;
}
/**
* @return int
*/
public function getMaxRotation()
{
return $this->maxRotation;
}
/**
* @param int $maxRotation
*
* @return $this
*/
public function setMaxRotation($maxRotation)
{
$this->maxRotation = intval($maxRotation);
return $this;
}
/**
* @return int
*/
public function getMinRotation()
{
return $this->minRotation;
}
/**
* @param int $minRotation
*
* @return $this
*/
public function setMinRotation($minRotation)
{
$this->minRotation = intval($minRotation);
return $this;
}
/**
* @return bool
*/
public function isMirror()
{
return $this->mirror;
}
/**
* @param bool $mirror
*
* @return $this
*/
public function setMirror($mirror)
{
$this->mirror = boolval($mirror);
return $this;
}
/**
* @return int
*/
public function getPadding()
{
return $this->padding;
}
/**
* @param int $padding
*
* @return $this
*/
public function setPadding($padding)
{
$this->padding = intval($padding);
return $this;
}
/**
* @return bool
*/
public function isReverse()
{
return $this->reverse;
}
/**
* @param bool $reverse
*
* @return $this
*/
public function setReverse($reverse)
{
$this->reverse = boolval($reverse);
return $this;
}
/**
* @return int
*/
public function getMax()
{
return $this->max;
}
/**
* @param int $max
*
* @return $this
*/
public function setMax($max)
{
$this->max = intval($max);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace Artica\PHPChartJS\Options\Scales;
use Artica\PHPChartJS\Options\Scale;
/**
* Class XAxis
*
* @package Artica\PHPChartJS\Options\Scales
*/
class XAxis extends Scale
{
/**
* @var float
*/
private $categoryPercentage;
/**
* @var float
*/
private $barPercentage;
/**
* @return float
*/
public function getCategoryPercentage()
{
return $this->categoryPercentage;
}
/**
* @param float $categoryPercentage
*
* @return $this
*/
public function setCategoryPercentage($categoryPercentage)
{
$this->categoryPercentage = floatval($categoryPercentage);
return $this;
}
/**
* @return float
*/
public function getBarPercentage()
{
return $this->barPercentage;
}
/**
* @param float $barPercentage
*
* @return $this
*/
public function setBarPercentage($barPercentage)
{
$this->barPercentage = floatval($barPercentage);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace Artica\PHPChartJS\Options\Scales;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\ArraySerializableInterface;
use JsonSerializable;
/**
* Class XAxisCollection
*
* @package Artica\PHPChartJS\Collection
*/
class XAxisCollection extends ArrayAccess implements ArraySerializableInterface, JsonSerializable
{
/**
* @return array
*/
public function getArrayCopy()
{
$rows = [];
foreach ($this->data as $row) {
/** @var XAxis $row */
$rows[] = $row->getArrayCopy();
}
return $rows;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Artica\PHPChartJS\Options\Scales;
use Artica\PHPChartJS\Options\Scale;
/**
* Class YAxis
* @package Artica\PHPChartJS\Options\Scales
*/
class YAxis extends Scale
{
}

View File

@ -0,0 +1,37 @@
<?php
namespace Artica\PHPChartJS\Options\Scales;
use Halfpastfour\Collection\Collection\ArrayAccess;
use Artica\PHPChartJS\ArraySerializableInterface;
use JsonSerializable;
/**
* Class YAxisCollection
*
* @package Artica\PHPChartJS\Collection
*/
class YAxisCollection extends ArrayAccess implements ArraySerializableInterface, JsonSerializable
{
/**
* @return array
*/
public function getArrayCopy()
{
$rows = [];
foreach ($this->data as $row) {
/** @var YAxis $row */
$rows[] = $row->getArrayCopy();
}
return $rows;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\Options;
/**
* Class ScatterOptions
* @package Artica\PHPChartJS\Options
*/
class ScatterOptions extends Options
{
}

View File

@ -0,0 +1,210 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
/**
* Class LineOptions
*
* @package Artica\PHPChartJS\Options
*/
class Title implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var boolean
*/
private $display;
/**
* @var string
*/
private $position;
/**
* @var string
*/
private $color;
/**
* @var boolean
*/
private $fullWidth;
/**
* @var integer
*/
private $padding;
/**
* @var string
*/
private $text;
/**
* @var Fonts
*/
private $font;
/**
* @return boolean
*/
public function isDisplay()
{
return $this->display;
}
/**
* @param boolean $display
*
* @return $this
*/
public function setDisplay($display)
{
$this->display = boolval($display);
return $this;
}
/**
* @return string
*/
public function getPosition()
{
return $this->position;
}
/**
* @param string $position
*
* @return $this
*/
public function setPosition($position)
{
$this->position = strval($position);
return $this;
}
/**
* @return string
*/
public function getColor()
{
return $this->color;
}
/**
* @param string $color
*
* @return $this
*/
public function setColor($color)
{
$this->color = strval($color);
return $this;
}
/**
* @return boolean
*/
public function isFullWidth()
{
return $this->fullWidth;
}
/**
* @param boolean $fullWidth
*
* @return $this
*/
public function setFullWidth($fullWidth)
{
$this->fullWidth = boolval($fullWidth);
return $this;
}
/**
* @return integer
*/
public function getPadding()
{
return $this->padding;
}
/**
* @param integer $padding
*
* @return $this
*/
public function setPadding($padding)
{
$this->padding = intval($padding);
return $this;
}
/**
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* @param string $text
*
* @return $this
*/
public function setText($text)
{
$this->text = strval($text);
return $this;
}
/**
* Return Font.
*
* @return Font
*/
public function getFonts()
{
if (isset($this->font) === false) {
$this->font = new Fonts();
}
return $this->font;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,819 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use Artica\PHPChartJS\Options\Tooltips\Callbacks;
use JsonSerializable;
use Laminas\Json\Expr;
/**
* Class Tooltips
*
* @package Artica\PHPChartJS\Options
*/
class Tooltips implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var bool
*/
private $enabled;
/**
* @var Expr
*/
private $custom;
/**
* @var string
*/
private $mode;
/**
* @var bool
*/
private $intersect;
/**
* @var string
*/
private $position;
/**
* @var Expr
*/
private $itemSort;
/**
* @var Expr
*/
private $filter;
/**
* @var string
*/
private $backgroundColor;
/**
* @var string
*/
private $titleFontFamily;
/**
* @var int
*/
private $titleFontSize;
/**
* @var string
*/
private $titleFontStyle;
/**
* @var string
*/
private $titleFontColor;
/**
* @var int
*/
private $titleSpacing;
/**
* @var int
*/
private $titleMarginBottom;
/**
* @var string
*/
private $bodyFontFamily;
/**
* @var int
*/
private $bodyFontSize;
/**
* @var string
*/
private $bodyFontStyle;
/**
* @var string
*/
private $bodyFontColor;
/**
* @var int
*/
private $bodySpacing;
/**
* @var string
*/
private $footerFontFamily;
/**
* @var int
*/
private $footerFontSize;
/**
* @var string
*/
private $footerFontStyle;
/**
* @var string
*/
private $footerFontColor;
/**
* @var int
*/
private $footerSpacing;
/**
* @var int
*/
private $footerMarginTop;
/**
* @var int
*/
private $xPadding;
/**
* @var int
*/
private $yPadding;
/**
* @var int
*/
private $caretSize;
/**
* @var int
*/
private $cornerRadius;
/**
* @var string
*/
private $multiKeyBackground;
/**
* @var bool
*/
private $displayColors;
/**
* @var Callbacks
*/
private $callbacks;
/**
* @return bool
*/
public function isEnabled()
{
return $this->enabled;
}
/**
* @param bool $enabled
*
* @return $this
*/
public function setEnabled($enabled)
{
$this->enabled = boolval($enabled);
return $this;
}
/**
* @return \Laminas\Json\Expr
*/
public function getCustom()
{
return $this->custom;
}
/**
* @param \Laminas\Json\Expr $custom
*
* @return $this
*/
public function setCustom($custom)
{
$this->custom = $custom;
return $this;
}
/**
* @return string
*/
public function getMode()
{
return $this->mode;
}
/**
* @param string $mode
*
* @return $this
*/
public function setMode($mode)
{
$this->mode = strval($mode);
return $this;
}
/**
* @return bool
*/
public function isIntersect()
{
return $this->intersect;
}
/**
* @param bool $intersect
*
* @return $this
*/
public function setIntersect($intersect)
{
$this->intersect = boolval($intersect);
return $this;
}
/**
* @return string
*/
public function getPosition()
{
return $this->position;
}
/**
* @param string $position
*
* @return $this
*/
public function setPosition($position)
{
$this->position = strval($position);
return $this;
}
/**
* @return Expr
*/
public function getItemSort()
{
return $this->itemSort;
}
/**
* @param Expr $itemSort
*
* @return $this
*/
public function setItemSort($itemSort)
{
$this->itemSort = new Expr(strval($itemSort));
return $this;
}
/**
* @return Expr
*/
public function getFilter()
{
return $this->filter;
}
/**
* @param Expr $filter
*
* @return $this
*/
public function setFilter($filter)
{
$this->filter = new Expr(strval($filter));
return $this;
}
/**
* @return string
*/
public function getBackgroundColor()
{
return $this->backgroundColor;
}
/**
* @param string $backgroundColor
*
* @return $this
*/
public function setBackgroundColor($backgroundColor)
{
$this->backgroundColor = strval($backgroundColor);
return $this;
}
/**
* @return string
*/
public function getTitleFontFamily()
{
return $this->titleFontFamily;
}
/**
* @param string $titleFontFamily
*
* @return $this
*/
public function setTitleFontFamily($titleFontFamily)
{
$this->titleFontFamily = strval($titleFontFamily);
return $this;
}
/**
* @return int
*/
public function getTitleFontSize()
{
return $this->titleFontSize;
}
/**
* @param int $titleFontSize
*
* @return $this
*/
public function setTitleFontSize($titleFontSize)
{
$this->titleFontSize = intval($titleFontSize);
return $this;
}
/**
* @return string
*/
public function getTitleFontStyle()
{
return $this->titleFontStyle;
}
/**
* @param string $titleFontStyle
*
* @return $this
*/
public function setTitleFontStyle($titleFontStyle)
{
$this->titleFontStyle = strval($titleFontStyle);
return $this;
}
/**
* @return string
*/
public function getTitleFontColor()
{
return $this->titleFontColor;
}
/**
* @param string $titleFontColor
*
* @return $this
*/
public function setTitleFontColor($titleFontColor)
{
$this->titleFontColor = strval($titleFontColor);
return $this;
}
/**
* @return int
*/
public function getTitleSpacing()
{
return $this->titleSpacing;
}
/**
* @param int $titleSpacing
*
* @return $this
*/
public function setTitleSpacing($titleSpacing)
{
$this->titleSpacing = intval($titleSpacing);
return $this;
}
/**
* @return int
*/
public function getTitleMarginBottom()
{
return $this->titleMarginBottom;
}
/**
* @param int $titleMarginBottom
*
* @return $this
*/
public function setTitleMarginBottom($titleMarginBottom)
{
$this->titleMarginBottom = intval($titleMarginBottom);
return $this;
}
/**
* @return string
*/
public function getBodyFontFamily()
{
return $this->bodyFontFamily;
}
/**
* @param string $bodyFontFamily
*
* @return $this
*/
public function setBodyFontFamily($bodyFontFamily)
{
$this->bodyFontFamily = strval($bodyFontFamily);
return $this;
}
/**
* @return int
*/
public function getBodyFontSize()
{
return $this->bodyFontSize;
}
/**
* @param int $bodyFontSize
*
* @return $this
*/
public function setBodyFontSize($bodyFontSize)
{
$this->bodyFontSize = intval($bodyFontSize);
return $this;
}
/**
* @return string
*/
public function getBodyFontStyle()
{
return $this->bodyFontStyle;
}
/**
* @param string $bodyFontStyle
*
* @return $this
*/
public function setBodyFontStyle($bodyFontStyle)
{
$this->bodyFontStyle = strval($bodyFontStyle);
return $this;
}
/**
* @return string
*/
public function getBodyFontColor()
{
return $this->bodyFontColor;
}
/**
* @param string $bodyFontColor
*
* @return $this
*/
public function setBodyFontColor($bodyFontColor)
{
$this->bodyFontColor = strval($bodyFontColor);
return $this;
}
/**
* @return int
*/
public function getBodySpacing()
{
return $this->bodySpacing;
}
/**
* @param int $bodySpacing
*
* @return $this
*/
public function setBodySpacing($bodySpacing)
{
$this->bodySpacing = intval($bodySpacing);
return $this;
}
/**
* @return string
*/
public function getFooterFontFamily()
{
return $this->footerFontFamily;
}
/**
* @param string $footerFontFamily
*
* @return $this
*/
public function setFooterFontFamily($footerFontFamily)
{
$this->footerFontFamily = strval($footerFontFamily);
return $this;
}
/**
* @return int
*/
public function getFooterFontSize()
{
return $this->footerFontSize;
}
/**
* @param int $footerFontSize
*
* @return $this
*/
public function setFooterFontSize($footerFontSize)
{
$this->footerFontSize = intval($footerFontSize);
return $this;
}
/**
* @return string
*/
public function getFooterFontStyle()
{
return $this->footerFontStyle;
}
/**
* @param string $footerFontStyle
*
* @return $this
*/
public function setFooterFontStyle($footerFontStyle)
{
$this->footerFontStyle = strval($footerFontStyle);
return $this;
}
/**
* @return string
*/
public function getFooterFontColor()
{
return $this->footerFontColor;
}
/**
* @param string $footerFontColor
*
* @return $this
*/
public function setFooterFontColor($footerFontColor)
{
$this->footerFontColor = strval($footerFontColor);
return $this;
}
/**
* @return int
*/
public function getFooterSpacing()
{
return $this->footerSpacing;
}
/**
* @param int $footerSpacing
*
* @return $this
*/
public function setFooterSpacing($footerSpacing)
{
$this->footerSpacing = intval($footerSpacing);
return $this;
}
/**
* @return int
*/
public function getFooterMarginTop()
{
return $this->footerMarginTop;
}
/**
* @param int $footerMarginTop
*
* @return $this
*/
public function setFooterMarginTop($footerMarginTop)
{
$this->footerMarginTop = intval($footerMarginTop);
return $this;
}
/**
* @return int
*/
public function getXPadding()
{
return $this->xPadding;
}
/**
* @param int $xPadding
*
* @return $this
*/
public function setXPadding($xPadding)
{
$this->xPadding = intval($xPadding);
return $this;
}
/**
* @return int
*/
public function getYPadding()
{
return $this->yPadding;
}
/**
* @param int $yPadding
*
* @return $this
*/
public function setYPadding($yPadding)
{
$this->yPadding = intval($yPadding);
return $this;
}
/**
* @return int
*/
public function getCaretSize()
{
return $this->caretSize;
}
/**
* @param int $caretSize
*
* @return $this
*/
public function setCaretSize($caretSize)
{
$this->caretSize = intval($caretSize);
return $this;
}
/**
* @return int
*/
public function getCornerRadius()
{
return $this->cornerRadius;
}
/**
* @param int $cornerRadius
*
* @return $this
*/
public function setCornerRadius($cornerRadius)
{
$this->cornerRadius = intval($cornerRadius);
return $this;
}
/**
* @return string
*/
public function getMultiKeyBackground()
{
return $this->multiKeyBackground;
}
/**
* @param string $multiKeyBackground
*
* @return $this
*/
public function setMultiKeyBackground($multiKeyBackground)
{
$this->multiKeyBackground = strval($multiKeyBackground);
return $this;
}
/**
* @return bool
*/
public function isDisplayColors()
{
return $this->displayColors;
}
/**
* @param bool $displayColors
*
* @return $this
*/
public function setDisplayColors($displayColors)
{
$this->displayColors = boolval($displayColors);
return $this;
}
/**
* @return Callbacks
*/
public function callbacks()
{
if (is_null($this->callbacks)) {
$this->callbacks = new Callbacks();
}
return $this->callbacks;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,326 @@
<?php
namespace Artica\PHPChartJS\Options\Tooltips;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
use Laminas\Json\Expr;
/**
* Class Callbacks
*
* @package Artica\PHPChartJS\Tooltips
*/
class Callbacks implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var Expr
*/
private $beforeTitle;
/**
* @var Expr
*/
private $title;
/**
* @var Expr
*/
private $afterTitle;
/**
* @var Expr
*/
private $beforeLabel;
/**
* @var Expr
*/
private $label;
/**
* @var Expr
*/
private $labelColor;
/**
* @var Expr
*/
private $afterLabel;
/**
* @var Expr
*/
private $afterBody;
/**
* @var Expr
*/
private $beforeFooter;
/**
* @var Expr
*/
private $footer;
/**
* @var Expr
*/
private $afterFooter;
/**
* @var Expr
*/
private $dataPoints;
/**
* @return Expr
*/
public function getBeforeTitle()
{
return $this->beforeTitle;
}
/**
* @param string $beforeTitle
*
* @return $this
*/
public function setBeforeTitle($beforeTitle)
{
$this->beforeTitle = new Expr(strval($beforeTitle));
return $this;
}
/**
* @return Expr
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*
* @return $this
*/
public function setTitle($title)
{
$this->title = new Expr(strval($title));
return $this;
}
/**
* @return Expr
*/
public function getAfterTitle()
{
return $this->afterTitle;
}
/**
* @param string $afterTitle
*
* @return $this
*/
public function setAfterTitle($afterTitle)
{
$this->afterTitle = new Expr(strval($afterTitle));
return $this;
}
/**
* @return Expr
*/
public function getBeforeLabel()
{
return $this->beforeLabel;
}
/**
* @param string $beforeLabel
*
* @return $this
*/
public function setBeforeLabel($beforeLabel)
{
$this->beforeLabel = new Expr(strval($beforeLabel));
return $this;
}
/**
* @return Expr
*/
public function getLabel()
{
return $this->label;
}
/**
* @param string $label
*
* @return $this
*/
public function setLabel($label)
{
$this->label = new Expr(strval($label));
return $this;
}
/**
* @return Expr
*/
public function getLabelColor()
{
return $this->labelColor;
}
/**
* @param string $labelColor
*
* @return $this
*/
public function setLabelColor($labelColor)
{
$this->labelColor = new Expr(strval($labelColor));
return $this;
}
/**
* @return Expr
*/
public function getAfterLabel()
{
return $this->afterLabel;
}
/**
* @param string $afterLabel
*
* @return $this
*/
public function setAfterLabel($afterLabel)
{
$this->afterLabel = new Expr(strval($afterLabel));
return $this;
}
/**
* @return Expr
*/
public function getAfterBody()
{
return $this->afterBody;
}
/**
* @param string $afterBody
*
* @return $this
*/
public function setAfterBody($afterBody)
{
$this->afterBody = new Expr(strval($afterBody));
return $this;
}
/**
* @return Expr
*/
public function getBeforeFooter()
{
return $this->beforeFooter;
}
/**
* @param string $beforeFooter
*
* @return $this
*/
public function setBeforeFooter($beforeFooter)
{
$this->beforeFooter = new Expr(strval($beforeFooter));
return $this;
}
/**
* @return Expr
*/
public function getFooter()
{
return $this->footer;
}
/**
* @param string $footer
*
* @return $this
*/
public function setFooter($footer)
{
$this->footer = new Expr(strval($footer));
return $this;
}
/**
* @return Expr
*/
public function getAfterFooter()
{
return $this->afterFooter;
}
/**
* @param string $afterFooter
*
* @return $this
*/
public function setAfterFooter($afterFooter)
{
$this->afterFooter = new Expr(strval($afterFooter));
return $this;
}
/**
* @return Expr
*/
public function getDataPoints()
{
return $this->dataPoints;
}
/**
* @param string $dataPoints
*
* @return $this
*/
public function setDataPoints($dataPoints)
{
$this->dataPoints = new Expr(strval($dataPoints));
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,162 @@
<?php
namespace Artica\PHPChartJS\Options;
use Artica\PHPChartJS\ArraySerializableInterface;
use Artica\PHPChartJS\Delegate\ArraySerializable;
use JsonSerializable;
/**
* Class WaterMark
*
* @package Artica\PHPChartJS\Options
*/
class WaterMark implements ArraySerializableInterface, JsonSerializable
{
use ArraySerializable;
/**
* @var float
*/
private $width;
/**
* @var float
*/
private $height;
/**
* @var string
*/
private $src;
/**
* @var string
*/
private $position;
/**
* @var string
*/
private $align;
/**
* @return float
*/
public function getWidth()
{
return $this->width;
}
/**
* @param float $width
*
* @return $this
*/
public function setWidth($width)
{
$this->width = intval($width);
return $this;
}
/**
* @return float
*/
public function getHeight()
{
return $this->height;
}
/**
* @param float $height
*
* @return $this
*/
public function setHeight($height)
{
$this->height = intval($height);
return $this;
}
/**
* @return string
*/
public function getSrc()
{
return $this->src;
}
/**
* @param string $src
*
* @return $this
*/
public function setSrc($src)
{
$this->src = strval($src);
return $this;
}
/**
* @return string
*/
public function getPosition()
{
return $this->position;
}
/**
* @param string $position
*
* @return $this
*/
public function setPosition($position)
{
$this->position = strval($position);
return $this;
}
/**
* @return string
*/
public function getAlign()
{
return $this->align;
}
/**
* @param string $align
*
* @return $this
*/
public function setAlign($align)
{
$this->align = strval($align);
return $this;
}
/**
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Artica\PHPChartJS;
use Halfpastfour\Collection\Collection\ArrayAccess;
use JsonSerializable;
/**
* Class PluginsCollection
*
* @package Artica\PHPChartJS
*/
class PluginsCollection extends ArrayAccess implements JsonSerializable
{
/**
* @return array
*/
public function jsonSerialize()
{
return $this->data;
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace Artica\PHPChartJS\Renderer;
use DOMDocument;
/**
* Class Renderer
*
* @package Artica\PHPChartJS
*/
class Html extends Renderer
{
/**
* Renders the necessary HTML for the chart to function in the frontend.
*
* @param int|null $flags
*
* @return string
*/
public function render($flags = null)
{
$dom = new DOMDocument();
// Render canvas HTML element
$canvas = $dom->createElement('canvas');
$canvas->setAttribute('id', $this->chart->getId());
// Add title, height and width if applicable
if ($this->chart->getTitle()) {
$canvas->setAttribute('title', $this->chart->getTitle());
}
if ($this->chart->getHeight()) {
$canvas->setAttribute('height', $this->chart->getHeight());
}
if ($this->chart->getWidth()) {
$canvas->setAttribute('width', $this->chart->getWidth());
}
$dom->appendChild($canvas);
// Render JavaScript
$scriptRenderer = new JavaScript($this->chart);
$script = $dom->createElement('script', $scriptRenderer->render($flags));
$dom->appendChild($script);
return $dom->saveHTML();
}
}

View File

@ -0,0 +1,125 @@
<?php
namespace Artica\PHPChartJS\Renderer;
/**
* Class JavaScript
*
* @package Artica\PHPChartJS\Renderer
*/
class JavaScript extends Renderer
{
/**
* Renders the necessary JavaScript for the chart to function in the frontend.
*
* @param integer|null $flags
*
* @return string
*/
public function render($flags=null)
{
$script = [];
// First, setup the canvas context
$script[] = "var ctx = document.getElementById( \"{$this->chart->getId()}\" ).getContext( \"2d\" );";
// Now, setup the chart instance
$jsonRenderer = new Json($this->chart);
$json = $jsonRenderer->render($flags);
// Watermark.
if (empty($this->chart->defaults()->getWatermark()) === false) {
$script[] = 'const chart_watermark_'.$this->chart->getId().' = {
id: "chart_watermark_'.$this->chart->getId().'",
afterDraw: (chart) => {
const image = new Image();
image.src = "'.$this->chart->defaults()->getWatermark()->getSrc().'";
if (image.complete) {
const image_height = '.($this->chart->defaults()->getWatermark()->getHeight() ?? 20).';
const image_width = '.($this->chart->defaults()->getWatermark()->getWidth() ?? 100).';
const ctx = chart.ctx;
let x = 0;
let y = 0;
switch ("'.$this->chart->defaults()->getWatermark()->getPosition().'") {
case "start":
x = 0;
break;
case "center":
x = (chart.width / 2) - image_width;
break;
default:
case "end":
x = chart.width - image_width;
break;
}
switch ("'.$this->chart->defaults()->getWatermark()->getAlign().'") {
default:
case "top":
y = 0;
break;
case "center":
y = (chart.height / 2) + image_height;
break;
case "bottom":
y = chart.height + image_height;
break;
}
ctx.globalAlpha = 1;
ctx.drawImage(image, x, y, image_width, image_height);
ctx.globalAlpha = 1;
} else {
image.onload = () => chart.draw();
}
}
};';
$script[] = 'Chart.register(chart_watermark_'.$this->chart->getId().');';
}
// Create chart.
$script[] = 'try {';
$script[] = " var chart = new Chart( ctx, {$json} );";
// Defaults values.
$script[] = ' Chart.defaults.font.size = '.($this->chart->defaults()->getFonts()->getSize() ?? 8).';';
$script[] = ' Chart.defaults.font.family = "'.($this->chart->defaults()->getFonts()->getFamily() ?? 'Lato, sans-serif').'";';
$script[] = ' Chart.defaults.font.style = "'.($this->chart->defaults()->getFonts()->getStyle() ?? 'normal').'";';
$script[] = ' Chart.defaults.font.weight = "'.($this->chart->defaults()->getFonts()->getWeight() ?? '').'";';
$script[] = '} catch (error) {';
$script[] = ' console.error(error);';
$script[] = '}';
$scriptString = implode("\n", $script);
return $scriptString;
// Return the script
return <<<JS
window.onload=(function(oldLoad){return function(){
if (oldLoad) {
oldLoad();
}
{$scriptString};
if (! window.hasOwnProperty('chartInstances')) {
window.chartInstances = {};
}
window.chartInstances['{$this->chart->getId()}'] = chart;
}})(window.onload);
JS;
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace Artica\PHPChartJS\Renderer;
use Laminas\Json\Json as JsonHelper;
/**
* Class Json
*
* @package Artica\PHPChartJS\Renderer
*/
class Json extends Renderer
{
/**
* Render the necessary JSON for the chart to function in the frontend.
*
* @param integer|false $flags
*
* @return string
*/
public function render($flags=null)
{
$config = [
'type' => constant(get_class($this->chart).'::TYPE'),
'data' => [],
];
$labels = $this->chart->labels()->jsonSerialize();
if ($labels) {
$config['data']['labels'] = $labels;
}
$dataSets = $this->chart->dataSets()->jsonSerialize();
if ($dataSets) {
$config['data']['datasets'] = $dataSets;
}
$options = $this->chart->options()->jsonSerialize();
if (! empty($options)) {
$config['options'] = $options;
}
$defaults = $this->chart->defaults()->jsonSerialize();
if (! empty($defaults)) {
$config['defaults'] = $defaults;
}
$plugins = $this->chart->plugins()->jsonSerialize();
if (! empty($plugins)) {
$config['plugins'] = $plugins;
}
$output = JsonHelper::encode($config, false, ['enableJsonExprFinder' => true]);
if (($flags & Renderer::RENDER_PRETTY)) {
$output = JsonHelper::prettyPrint($output);
}
return $output;
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace Artica\PHPChartJS\Renderer;
use Artica\PHPChartJS\Chart;
/**
* Class Renderer
* @package Artica\PHPChartJS\Renderer
*/
abstract class Renderer implements RendererInterface
{
/**
* Flag used for rendering JSON in pretty mode.
*/
const RENDER_PRETTY = 1;
/**
* @var Chart The chart that needs to be rendered.
*/
protected $chart;
/**
* RendererInterface constructor. Expects an instance of a chart.
*
* @param Chart $chart The Chart that needs to be rendered.
*/
public function __construct(Chart $chart)
{
$this->chart = $chart;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Artica\PHPChartJS\Renderer;
use Artica\PHPChartJS\Chart;
/**
* Interface RendererInterface
*/
interface RendererInterface
{
/**
* RendererInterface constructor. Expects an instance of a chart.
*
* @param Chart $chart
*/
public function __construct(Chart $chart);
/**
* Render the chart with the current strategy, returning a string.
*
* @param int|null $flags
*
* @return string
*/
public function render($flags = null);
}

View File

@ -0,0 +1,83 @@
<?php
namespace Test;
use Laminas\Json\Expr;
use RuntimeException;
/**
* Class TestUtils
* @package Test
*/
class TestUtils
{
/**
* this method sets all defined attributes from the input array
* $input_data in the $obj and calls the setter.
*
* @param $obj
* @param array $data
*/
public static function setAttributes($obj, array $data)
{
if (! is_object($obj)) {
throw new RuntimeException("First param should be an object. ");
}
foreach ($data as $key => $value) {
$function = 'set' . ucfirst($key);
if (! is_null($value) && method_exists($obj, $function)) {
$obj->$function($value);
}
}
}
/**
* this method reads all defined attributes from the input array
* $input_data and calls the getter. It returns the resulting array.
*
* @param $obj
* @param array $dataTypes is an associative array that refers fieldnames to values.
* The values could be any primitive type, including an array.
*
* @return array
*/
public static function getAttributes($obj, array $dataTypes)
{
if (! is_object($obj)) {
throw new RuntimeException("First param should be an object. ");
}
$array = [];
foreach ($dataTypes as $key => $value) {
$function = ( gettype($value) == "boolean" ? 'is' : 'get' ) . ucfirst($key);
if (method_exists($obj, $function)) {
$getResult = $obj->$function($value);
$getResult = $getResult instanceof Expr ? $getResult->__toString() : $getResult;
$array[ $key ] = $getResult;
}
}
return $array;
}
/**
* @param $input_array
*
* @return mixed
*/
public static function removeNullsFromArray($input_array)
{
$array = $input_array;
$keys = array_keys($array);
foreach ($keys as $key) {
if (is_null($array[ $key ])) {
unset($array[ $key ]);
}
}
return $array;
}
}

View File

@ -0,0 +1,3 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';

View File

@ -0,0 +1,40 @@
<?php
require_once '../../vendor/autoload.php';
use Artica\PHPChartJS\Chart\Bar;
$bar = new Bar();
$bar->setId('myChart');
// Set labels
$bar->labels()->exchangeArray(["M", "T", "W", "T", "F", "S", "S"]);
// Add Datasets
$apples = $bar->createDataSet();
$apples->setLabel("apples")
->setBackgroundColor("rgba( 0, 150, 0, .5 )")
->data()->exchangeArray([12, 19, 3, 17, 28, 24, 7]);
$bar->addDataSet($apples);
$oranges = $bar->createDataSet();
$oranges->setLabel("oranges")
->setBackgroundColor('rgba( 255, 153, 0, .5 )')
->data()->exchangeArray([30, 29, 5, 5, 20, 3, 10]);
$bar->addDataSet($oranges);
?>
<!doctype html>
<html lang="en">
<head>
<title>Bar</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
</head>
<body>
<?php
// Render the chart
echo $bar->render();
?>
</body>
</html>

View File

@ -0,0 +1,72 @@
<?php
require_once '../../vendor/autoload.php';
use Artica\PHPChartJS\DataSet\LineDataSet;
use Artica\PHPChartJS\Factory;
$factory = new Factory();
/** @var \Artica\PHPChartJS\Chart\Line $bar */
$bar = $factory->create($factory::BAR);
// Set labels
$bar->labels()->exchangeArray(["January", "February", "March", "April", "May", "June", "July"]);
// Add Datasets
$dataSet = new LineDataSet();
$dataSet->setLabel('My First dataset')
->setType('line')
->setFill(false)
->setLineTension(0.1)
->setBackgroundColor('rgba(75,192,192,0.4)')
->setBorderColor('rgba(75,192,192,1)')
->setBorderCapStyle('butt')
->setBorderDash([])
->setBorderDashOffset(0.0)
->setBorderJoinStyle('miter')
->setPointBorderColor('rgba(75,192,192,1)')
->setPointBackgroundColor('#fff')
->setPointBorderWidth(1)
->setPointHoverRadius(5)
->setPointHoverBackgroundColor('rgba(75,192,192,1)')
->setPointHoverBorderColor('rgba(220,220,220,1)')
->setPointHoverBorderWidth(2)
->setPointRadius(1)
->setPointHitRadius(10)
->data()->exchangeArray([65, 59, 80, 81, 56, 55, 40]);
$bar->addDataSet($dataSet);
// Set mode to stacked
$scales = $bar->options()->getScales();
$scales->getYAxes()->append($scales->createYAxis()->setStacked(true))
->append($scales->createYAxis()->setPosition('right')->setId('y2'));
// Add even more data
$apples = $bar->createDataSet();
$apples->setLabel('apples')
->setYAxisID('y2')
->setBackgroundColor('rgba( 0, 150, 0, .5 )')
->data()->exchangeArray([12, 19, 3, 17, 28, 24, 7]);
$bar->addDataSet($apples);
$oranges = $bar->createDataSet();
$oranges->setLabel('oranges')
->setYAxisID('y2')
->setBackgroundColor('rgba( 255, 153, 0, .5 )')
->data()->exchangeArray([30, 29, 5, 5, 20, 3, 10]);
$bar->addDataSet($oranges);
?>
<!doctype html>
<html lang="en">
<head>
<title>Bar & line</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
</head>
<body>
<?php
// Render the chart
echo $bar->render();
?>
</body>
</html>

View File

@ -0,0 +1,52 @@
<?php
require_once '../../vendor/autoload.php';
use Artica\PHPChartJS\Chart\Bar;
use Artica\PHPChartJS\Options\BarOptions;
$bar = new Bar();
$bar->setId('myChart');
// Set labels
$bar->labels()->exchangeArray(["M", "T", "W", "T", "F", "S", "S"]);
// Add Datasets
$apples = $bar->createDataSet();
$apples->setLabel("apples")
->setBackgroundColor("rgba( 0, 150, 0, .5 )")
->data()->exchangeArray([12, 19, 3, 17, 28, 24, 7]);
$bar->addDataSet($apples);
$oranges = $bar->createDataSet();
$oranges->setLabel("oranges")
->setBackgroundColor('rgba( 255, 153, 0, .5 )')
->data()->exchangeArray([30, 29, 5, 5, 20, 3, 10]);
$bar->addDataSet($oranges);
/** @var BarOptions $options */
$options = $bar->options();
$xAxis = $options->getScales()->createXAxis();
$yAxis = $options->getScales()->createYAxis();
$xAxis->setDisplay(false);
$yAxis->setDisplay(false);
$options->getScales()->getXAxes()->append($xAxis);
$options->getScales()->getYAxes()->append($yAxis);
?>
<!doctype html>
<html lang="en">
<head>
<title>Bar without scales</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
</head>
<body>
<?php
// Render the chart
echo $bar->render();
?>
</body>
</html>

View File

@ -0,0 +1,54 @@
<?php
require_once '../../vendor/autoload.php';
use Artica\PHPChartJS\Factory;
$factory = new Factory();
/** @var \Artica\PHPChartJS\Chart\Bubble $bubble */
$bubble = $factory->create($factory::BUBBLE);
// Set labels
$bubble->labels()->exchangeArray(["M", "T", "W", "T", "F", "S", "S"]);
// Add Datasets
$apples = $bubble->createDataSet();
$apples->setLabel('My first dataset')
->setBackgroundColor('rgba( 0, 150, 0, .5 )')
->data()->exchangeArray([
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
]);
$bubble->addDataSet($apples);
$oranges = $bubble->createDataSet();
$oranges->setLabel('My second dataset')
->setBackgroundColor('rgba( 255, 153, 0, .5 )')
->data()->exchangeArray([
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
]);
$bubble->addDataSet($oranges);
?>
<!doctype html>
<html lang="en">
<head>
<title>Bubble</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
</head>
<body>
<?php
// Render the chart
echo $bubble->render();
?>
</body>
</html>

View File

@ -0,0 +1,57 @@
<?php
require_once '../../vendor/autoload.php';
use Artica\PHPChartJS\Factory;
$factory = new Factory();
/** @var \Artica\PHPChartJS\Chart\Bubble $bubble */
$bubble = $factory->create($factory::BUBBLE);
// Set labels
$bubble->labels()->exchangeArray(["M", "T", "W", "T", "F", "S", "S"]);
// Add Datasets
$apples = $bubble->createDataSet();
$apples->setLabel('My first dataset')
->setBackgroundColor('rgba( 0, 150, 0, .5 )')
->data()->exchangeArray([
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
]);
$bubble->addDataSet($apples);
$oranges = $bubble->createDataSet();
$oranges->setLabel('My second dataset')
->setBackgroundColor('rgba( 255, 153, 0, .5 )')
->data()->exchangeArray([
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
['x' => rand(0, 40), 'y' => rand(0, 30), 'r' => rand(0, 50)],
]);
$bubble->addDataSet($oranges);
$bubble->options()->setMaintainAspectRatio(false);
$bubble->setHeight(250);
?>
<!doctype html>
<html lang="en">
<head>
<title>Disable aspect ratio</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
</head>
<body>
<?php
// Render the chart
echo $bubble->render();
?>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More