Merge branch 'ent-9554-nuevas-graficas-de-tarta-que-reemplazar-a-las-actuales-3' into 'develop'

new chart chartjs pandora_enterprise#9554

See merge request artica/pandorafms!5328
This commit is contained in:
Rafael Ameijeiras 2022-12-27 16:01:42 +00:00
commit f6048737d3
627 changed files with 87208 additions and 4541 deletions

View File

@ -258,6 +258,7 @@ console_dependencies=" \
mod_ssl \ mod_ssl \
libzstd \ libzstd \
openldap-clients \ openldap-clients \
chromium \
http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm" http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm"
execute_cmd "yum install -y $console_dependencies" "Installing Pandora FMS Console dependencies" execute_cmd "yum install -y $console_dependencies" "Installing Pandora FMS Console dependencies"

View File

@ -312,6 +312,7 @@ console_dependencies=" \
mod_ssl \ mod_ssl \
libzstd \ libzstd \
openldap-clients \ openldap-clients \
chromium \
http://firefly.artica.es/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \ http://firefly.artica.es/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \
http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm \ http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm \
http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm" http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm"

View File

@ -271,6 +271,8 @@ echo -en "${cyan}Installing phantomjs...${reset}"
/usr/bin/phantomjs --version &>> "$LOGFILE" /usr/bin/phantomjs --version &>> "$LOGFILE"
check_cmd_status "Error Installing phanromjs" check_cmd_status "Error Installing phanromjs"
# Chromium
execute_cmd "apt install -y chromium-browser" "Instaling chromium browser"
# SDK VMware perl dependencies # SDK VMware perl dependencies
vmware_dependencies=" \ vmware_dependencies=" \

View File

@ -262,13 +262,11 @@ RUN dnf install -y --setopt=tsflags=nodocs \
http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm
# Install utils # Install utils
RUN dnf install -y supervisor crontabs http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm --setopt=tsflags=nodocs RUN dnf install -y supervisor chromium crontabs http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm --setopt=tsflags=nodocs
# SDK VMware perl dependencies # SDK VMware perl dependencies
RUN dnf install -y http://firefly.artica.es/centos8/perl-Crypt-OpenSSL-AES-0.02-1.el8.x86_64.rpm http://firefly.artica.es/centos8/perl-Crypt-SSLeay-0.73_07-1.gf.el8.x86_64.rpm perl-Net-HTTP perl-libwww-perl openssl-devel perl-Crypt-CBC perl-Bytes-Random-Secure perl-Crypt-Random-Seed perl-Math-Random-ISAAC perl-JSON http://firefly.artica.es/centos8/VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.rpm RUN dnf install -y http://firefly.artica.es/centos8/perl-Crypt-OpenSSL-AES-0.02-1.el8.x86_64.rpm http://firefly.artica.es/centos8/perl-Crypt-SSLeay-0.73_07-1.gf.el8.x86_64.rpm perl-Net-HTTP perl-libwww-perl openssl-devel perl-Crypt-CBC perl-Bytes-Random-Secure perl-Crypt-Random-Seed perl-Math-Random-ISAAC perl-JSON http://firefly.artica.es/centos8/VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.rpm
# Instant client Oracle # Instant client Oracle
RUN dnf install -y https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm RUN dnf install -y https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm
# Install Phantom
RUN dnf install -y supervisor crontabs http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm --setopt=tsflags=nodocs
EXPOSE 80 443 41121 162/udp EXPOSE 80 443 41121 162/udp

View File

@ -9,13 +9,24 @@
], ],
"config": { "config": {
"platform": { "platform": {
"php": "7.2.0" "php": "8.0.0"
} }
}, },
"require": { "require": {
"mpdf/mpdf": "^8.0.15", "mpdf/mpdf": "^8.0.15",
"swiftmailer/swiftmailer": "^6.0", "swiftmailer/swiftmailer": "^6.0",
"amphp/parallel-functions": "^1.0" "amphp/parallel-functions": "^1.0",
"chrome-php/chrome": "^1.7.1",
"artica/phpchartjs": "^1.0"
},
"repositories": {
"phpchartjs": {
"type": "path",
"url": "../../../phpchartjs",
"options": {
"symlink": false
}
}
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "643ac0dc8a8e1f129104399054f8dd0c", "content-hash": "be2ad3d9d4df55d7ccb87981e82c4932",
"packages": [ "packages": [
{ {
"name": "amphp/amp", "name": "amphp/amp",
@ -549,6 +549,205 @@
], ],
"time": "2021-10-25T18:29:10+00:00" "time": "2021-10-25T18:29:10+00:00"
}, },
{
"name": "artica/phpchartjs",
"version": "v1.0.2",
"dist": {
"type": "path",
"url": "../../../phpchartjs",
"reference": "4957e7cd699e50cee8e0ba7304e1423aafb2cad2"
},
"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",
"source": {
"type": "git",
"url": "https://github.com/chrome-php/chrome.git",
"reference": "5783c749b2ee385d1c481b0906f1b8acef0296e4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/chrome-php/chrome/zipball/5783c749b2ee385d1c481b0906f1b8acef0296e4",
"reference": "5783c749b2ee385d1c481b0906f1b8acef0296e4",
"shasum": ""
},
"require": {
"chrome-php/wrench": "^1.3",
"evenement/evenement": "^3.0.1",
"monolog/monolog": "^1.27.1 || ^2.8 || ^3.2",
"php": "^7.3 || ^8.0",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"symfony/filesystem": "^4.4 || ^5.0 || ^6.0",
"symfony/polyfill-mbstring": "^1.26",
"symfony/process": "^4.4 || ^5.0 || ^6.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.1",
"phpunit/phpunit": "^9.5.23",
"symfony/var-dumper": "^4.4 || ^5.0 || ^6.0"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"psr-4": {
"HeadlessChromium\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Enrico Dias",
"email": "enrico@enricodias.com",
"homepage": "https://github.com/enricodias"
}
],
"description": "Instrument headless chrome/chromium instances from PHP",
"keywords": [
"browser",
"chrome",
"chromium",
"crawl",
"headless",
"pdf",
"puppeteer",
"screenshot"
],
"support": {
"issues": "https://github.com/chrome-php/chrome/issues",
"source": "https://github.com/chrome-php/chrome/tree/v1.7.1"
},
"time": "2022-09-04T21:11:00+00:00"
},
{
"name": "chrome-php/wrench",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/chrome-php/wrench.git",
"reference": "68b8282d5d0d54a519c3212ee3e4c35bef40b7d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/chrome-php/wrench/zipball/68b8282d5d0d54a519c3212ee3e4c35bef40b7d9",
"reference": "68b8282d5d0d54a519c3212ee3e4c35bef40b7d9",
"shasum": ""
},
"require": {
"ext-sockets": "*",
"php": "^7.3 || ^8.0",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"symfony/polyfill-php80": "^1.26"
},
"conflict": {
"wrench/wrench": "*"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.1",
"phpunit/phpunit": "^9.5.23"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"psr-4": {
"Wrench\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
}
],
"description": "A simple PHP WebSocket implementation",
"keywords": [
"WebSockets",
"hybi",
"websocket"
],
"support": {
"issues": "https://github.com/chrome-php/wrench/issues",
"source": "https://github.com/chrome-php/wrench/tree/v1.3.0"
},
"time": "2022-08-28T11:42:16+00:00"
},
{ {
"name": "doctrine/lexer", "name": "doctrine/lexer",
"version": "1.2.2", "version": "1.2.2",
@ -693,6 +892,265 @@
], ],
"time": "2021-10-11T09:18:27+00:00" "time": "2021-10-11T09:18:27+00:00"
}, },
{
"name": "evenement/evenement",
"version": "v3.0.1",
"source": {
"type": "git",
"url": "https://github.com/igorw/evenement.git",
"reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7",
"reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7",
"shasum": ""
},
"require": {
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Evenement": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch"
}
],
"description": "Événement is a very simple event dispatching library for PHP",
"keywords": [
"event-dispatcher",
"event-emitter"
],
"support": {
"issues": "https://github.com/igorw/evenement/issues",
"source": "https://github.com/igorw/evenement/tree/master"
},
"time": "2017-07-23T21:35:13+00:00"
},
{
"name": "halfpastfouram/collection",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/halfpastfouram/collection.git",
"reference": "0862d0b431fef9dc2245518dc06b86ff00dcd102"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/halfpastfouram/collection/zipball/0862d0b431fef9dc2245518dc06b86ff00dcd102",
"reference": "0862d0b431fef9dc2245518dc06b86ff00dcd102",
"shasum": ""
},
"require": {
"php": ">=5.6.0 || ^7.0"
},
"require-dev": {
"codeclimate/php-test-reporter": "dev-master",
"phpunit/phpunit": "5.2.*"
},
"type": "package",
"autoload": {
"psr-4": {
"Test\\": "test/",
"Halfpastfour\\Collection\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"AGPL 3.0"
],
"authors": [
{
"name": "Bob Kruithof"
}
],
"description": "A flexible PHP Collection complete with custom Iterator.",
"homepage": "http://github.com/halfpastfouram/collection",
"keywords": [
"collection",
"php"
],
"support": {
"issues": "https://github.com/halfpastfouram/collection/issues",
"source": "https://github.com/halfpastfouram/collection/tree/master"
},
"time": "2016-12-18T13:04:48+00:00"
},
{
"name": "laminas/laminas-json",
"version": "3.5.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-json.git",
"reference": "7a8a1d7bf2d05dd6c1fbd7c0868d3848cf2b57ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-json/zipball/7a8a1d7bf2d05dd6c1fbd7c0868d3848cf2b57ec",
"reference": "7a8a1d7bf2d05dd6c1fbd7c0868d3848cf2b57ec",
"shasum": ""
},
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0"
},
"conflict": {
"zendframework/zend-json": "*"
},
"require-dev": {
"laminas/laminas-coding-standard": "~2.4.0",
"laminas/laminas-stdlib": "^2.7.7 || ^3.1",
"phpunit/phpunit": "^9.5.25"
},
"suggest": {
"laminas/laminas-json-server": "For implementing JSON-RPC servers",
"laminas/laminas-xml2json": "For converting XML documents to JSON"
},
"type": "library",
"autoload": {
"psr-4": {
"Laminas\\Json\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP",
"homepage": "https://laminas.dev",
"keywords": [
"json",
"laminas"
],
"support": {
"chat": "https://laminas.dev/chat",
"docs": "https://docs.laminas.dev/laminas-json/",
"forum": "https://discourse.laminas.dev",
"issues": "https://github.com/laminas/laminas-json/issues",
"rss": "https://github.com/laminas/laminas-json/releases.atom",
"source": "https://github.com/laminas/laminas-json"
},
"funding": [
{
"url": "https://funding.communitybridge.org/projects/laminas-project",
"type": "community_bridge"
}
],
"time": "2022-10-17T04:06:45+00:00"
},
{
"name": "monolog/monolog",
"version": "2.8.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "720488632c590286b88b80e62aa3d3d551ad4a50"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/720488632c590286b88b80e62aa3d3d551ad4a50",
"reference": "720488632c590286b88b80e62aa3d3d551ad4a50",
"shasum": ""
},
"require": {
"php": ">=7.2",
"psr/log": "^1.0.1 || ^2.0 || ^3.0"
},
"provide": {
"psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"elasticsearch/elasticsearch": "^7 || ^8",
"ext-json": "*",
"graylog2/gelf-php": "^1.4.2",
"guzzlehttp/guzzle": "^7.4",
"guzzlehttp/psr7": "^2.2",
"mongodb/mongodb": "^1.8",
"php-amqplib/php-amqplib": "~2.4 || ^3",
"phpspec/prophecy": "^1.15",
"phpstan/phpstan": "^0.12.91",
"phpunit/phpunit": "^8.5.14",
"predis/predis": "^1.1 || ^2.0",
"rollbar/rollbar": "^1.3 || ^2 || ^3",
"ruflin/elastica": "^7",
"swiftmailer/swiftmailer": "^5.3|^6.0",
"symfony/mailer": "^5.4 || ^6",
"symfony/mime": "^5.4 || ^6"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler",
"ext-mbstring": "Allow to work properly with unicode symbols",
"ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
"ext-openssl": "Required to send log messages using SSL",
"ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "https://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "https://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.8.0"
},
"funding": [
{
"url": "https://github.com/Seldaek",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/monolog/monolog",
"type": "tidelift"
}
],
"time": "2022-07-24T11:55:47+00:00"
},
{ {
"name": "mpdf/mpdf", "name": "mpdf/mpdf",
"version": "v8.0.15", "version": "v8.0.15",
@ -940,30 +1398,30 @@
}, },
{ {
"name": "psr/log", "name": "psr/log",
"version": "1.1.4", "version": "2.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/log.git", "url": "https://github.com/php-fig/log.git",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11" "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11", "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.0" "php": ">=8.0.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.1.x-dev" "dev-master": "2.0.x-dev"
} }
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Psr\\Log\\": "Psr/Log/" "Psr\\Log\\": "src"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -984,9 +1442,9 @@
"psr-3" "psr-3"
], ],
"support": { "support": {
"source": "https://github.com/php-fig/log/tree/1.1.4" "source": "https://github.com/php-fig/log/tree/2.0.0"
}, },
"time": "2021-05-03T11:20:27+00:00" "time": "2021-07-14T16:41:46+00:00"
}, },
{ {
"name": "setasign/fpdi", "name": "setasign/fpdi",
@ -1136,6 +1594,152 @@
"abandoned": "symfony/mailer", "abandoned": "symfony/mailer",
"time": "2021-10-18T15:26:12+00:00" "time": "2021-10-18T15:26:12+00:00"
}, },
{
"name": "symfony/filesystem",
"version": "v5.4.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "ac09569844a9109a5966b9438fc29113ce77cf51"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/ac09569844a9109a5966b9438fc29113ce77cf51",
"reference": "ac09569844a9109a5966b9438fc29113ce77cf51",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.8",
"symfony/polyfill-php80": "^1.16"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Filesystem\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v5.4.13"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-09-21T19:53:16+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "5bbc823adecdae860bb64756d639ecfec17b050a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a",
"reference": "5bbc823adecdae860bb64756d639ecfec17b050a",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"provide": {
"ext-ctype": "*"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-11-03T14:55:06+00:00"
},
{ {
"name": "symfony/polyfill-iconv", "name": "symfony/polyfill-iconv",
"version": "v1.24.0", "version": "v1.24.0",
@ -1392,16 +1996,16 @@
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.24.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
"reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1416,7 +2020,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.23-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -1424,12 +2028,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
] ],
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -1455,7 +2059,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -1471,7 +2075,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-11-30T18:21:41+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-php72", "name": "symfony/polyfill-php72",
@ -1548,6 +2152,232 @@
} }
], ],
"time": "2021-05-27T09:17:38+00:00" "time": "2021-05-27T09:17:38+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ion Bazan",
"email": "ion.bazan@gmail.com"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "symfony/process",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "6e75fe6874cbc7e4773d049616ab450eff537bf1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/6e75fe6874cbc7e4773d049616ab450eff537bf1",
"reference": "6e75fe6874cbc7e4773d049616ab450eff537bf1",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/polyfill-php80": "^1.16"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Process\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v5.4.11"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-06-27T16:58:25+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v3.4.47",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "0719f6cf4633a38b2c1585140998579ce23b4b7d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/0719f6cf4633a38b2c1585140998579ce23b4b7d",
"reference": "0719f6cf4633a38b2c1585140998579ce23b4b7d",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
},
"require-dev": {
"ext-iconv": "*",
"twig/twig": "~1.34|~2.4"
},
"suggest": {
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-intl": "To show region name in time zone dump",
"ext-symfony_debug": ""
},
"type": "library",
"autoload": {
"files": [
"Resources/functions/dump.php"
],
"psr-4": {
"Symfony\\Component\\VarDumper\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony mechanism for exploring and dumping PHP variables",
"homepage": "https://symfony.com",
"keywords": [
"debug",
"dump"
],
"support": {
"source": "https://github.com/symfony/var-dumper/tree/v3.4.47"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-24T10:57:07+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],
@ -1559,7 +2389,7 @@
"platform": [], "platform": [],
"platform-dev": [], "platform-dev": [],
"platform-overrides": { "platform-overrides": {
"php": "7.2.0" "php": "8.0.0"
}, },
"plugin-api-version": "2.3.0" "plugin-api-version": "2.3.0"
} }

View File

@ -1685,3 +1685,5 @@ enterprise/operation/agentes/manage_transmap.php
enterprise/operation/agentes/manage_transmap_creation.php enterprise/operation/agentes/manage_transmap_creation.php
enterprise/operation/agentes/manage_transmap_creation_phases_data.php enterprise/operation/agentes/manage_transmap_creation_phases_data.php
enterprise/operation/agentes/transactional_map.php enterprise/operation/agentes/transactional_map.php
include/test.js
include/web2image.js

View File

@ -684,23 +684,6 @@ $table_other->data[$i++][1] = html_print_input_text(
true true
); );
if (enterprise_installed() === true) {
$table_other->data[$i][0] = __('PhantomJS cache cleanup ').$tip;
$table_other->data[$i++][1] = html_print_input(
[
'type' => 'select',
'name' => 'phantomjs_cache_interval',
'return' => true,
'fields' => [
PHANTOM_CACHE_CLEANUP_ONCE => __('No scheduled'),
PHANTOM_CACHE_CLEANUP_WEEKLY => __('Each week'),
PHANTOM_CACHE_CLEANUP_DAILY => __('Each day'),
],
'selected' => ($config['phantomjs_cache_interval'] ?? PHANTOM_CACHE_CLEANUP_ONCE),
]
);
}
// Agent Wizard defaults. // Agent Wizard defaults.
$defaultAgentWizardOptions = json_decode(io_safe_output($config['agent_wizard_defaults'])); $defaultAgentWizardOptions = json_decode(io_safe_output($config['agent_wizard_defaults']));
$tableSnmpWizard = new stdClass(); $tableSnmpWizard = new stdClass();

View File

@ -95,11 +95,11 @@ $table->data[$i++][1] = html_print_input_text(
true true
); );
$table->data[$i][0] = __('Phantomjs bin directory'); $table->data[$i][0] = __('Chromium path');
$table->data[$i++][1] = html_print_input_text( $table->data[$i++][1] = html_print_input_text(
'phantomjs_bin', 'chromium_path',
io_safe_output( io_safe_output(
$config['phantomjs_bin'] $config['chromium_path']
), ),
'', '',
30, 30,

View File

@ -2031,8 +2031,10 @@ if ($total_event_graph) {
include_once $config['homedir'].'/include/functions_graph.php'; include_once $config['homedir'].'/include/functions_graph.php';
$prueba = grafico_eventos_total('', 280, 150, false, true); $out = '<div style="flex: 0 0 300px; width:99%; height:100%;">';
echo $prueba; $out .= grafico_eventos_total('', 0, 0, false, true);
$out .= '<div>';
echo $out;
return; return;
} }
@ -2041,8 +2043,10 @@ if ($graphic_event_group) {
include_once $config['homedir'].'/include/functions_graph.php'; include_once $config['homedir'].'/include/functions_graph.php';
$prueba = grafico_eventos_grupo(280, 150, '', false, true); $out = '<div style="flex: 0 0 300px; width:99%; height:100%;">';
echo $prueba; $out .= grafico_eventos_grupo(0, 0, '', false, true);
$out .= '<div>';
echo $out;
return; return;
} }

View File

@ -42,40 +42,23 @@ require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_tags.php'; require_once $config['homedir'].'/include/functions_tags.php';
$data_raw = get_parameter('data'); $data_raw = get_parameter('data');
$data_decoded = json_decode(base64_decode($data_raw), true); $data_decoded = json_decode(io_safe_output($data_raw), true);
if (json_last_error() === JSON_ERROR_NONE) { if (json_last_error() === JSON_ERROR_NONE) {
$data = urldecode($data_decoded['data']); $data = $data_decoded['data'];
$session_id = urldecode($data_decoded['session_id']); $session_id = $data_decoded['session_id'];
$data_combined = urldecode($data_decoded['data_combined']); $type_graph_pdf = $data_decoded['type_graph_pdf'];
$data_module_list = urldecode($data_decoded['data_module_list']);
$type_graph_pdf = urldecode($data_decoded['type_graph_pdf']); $data_combined = [];
$viewport_width = urldecode($data_decoded['viewport_width']); if (isset($data_decoded['data_combined']) === true) {
$data_combined = $data_decoded['data_combined'];
} }
$data_module_list = [];
/** if (isset($data_decoded['data_module_list']) === true) {
* Echo to stdout a PhantomJS callback call. $data_module_list = $data_decoded['data_module_list'];
*
* @return void
*/
function echoPhantomCallback()
{
?>
<script type="text/javascript">
$('document').ready(function () {
setTimeout(function () {
try {
var status = window.callPhantom({ status: "loaded" });
} catch (error) {
console.log("CALLBACK ERROR", error.message)
} }
}, 100);
});
</script>
<?php
} }
// Initialize session. // Initialize session.
global $config; global $config;
@ -99,7 +82,6 @@ if (check_login(false) === false) {
</head> </head>
<body> <body>
<h1>Access is not granted</h1> <h1>Access is not granted</h1>
<?php echoPhantomCallback(); ?>
</body> </body>
</html> </html>
@ -108,10 +90,16 @@ if (check_login(false) === false) {
} }
// Access granted. // Access granted.
$params = json_decode($data, true); $params = $data;
if (isset($params['backgroundColor']) === false) {
$params['backgroundColor'] = 'inherit';
}
// Metaconsole connection to the node. // Metaconsole connection to the node.
$server_id = 0;
if (isset($params['server_id']) === true) {
$server_id = $params['server_id']; $server_id = $params['server_id'];
}
if (is_metaconsole() === true && empty($server_id) === false) { if (is_metaconsole() === true && empty($server_id) === false) {
$server = metaconsole_get_connection_by_id($server_id); $server = metaconsole_get_connection_by_id($server_id);
@ -124,7 +112,6 @@ if (is_metaconsole() === true && empty($server_id) === false) {
ui_print_error_message( ui_print_error_message(
__('There was a problem connecting with the node') __('There was a problem connecting with the node')
); );
echoPhantomCallback();
?> ?>
</body> </body>
</html> </html>
@ -133,7 +120,6 @@ if (is_metaconsole() === true && empty($server_id) === false) {
} }
} }
$user_language = get_user_language($config['id_user']); $user_language = get_user_language($config['id_user']);
if (file_exists('languages/'.$user_language.'.mo') === true) { if (file_exists('languages/'.$user_language.'.mo') === true) {
$cfr = new CachedFileReader('languages/'.$user_language.'.mo'); $cfr = new CachedFileReader('languages/'.$user_language.'.mo');
@ -146,16 +132,16 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pandora FMS Graph (<?php echo agents_get_alias($agent_id).' - '.$interface_name; ?>)</title> <title>Pandora FMS Graph</title>
<link rel="stylesheet" href="styles/pandora.css" type="text/css" /> <link rel="stylesheet" href="styles/pandora.css" type="text/css" />
<link rel="stylesheet" href="styles/pandora_minimal.css" type="text/css" /> <link rel="stylesheet" href="styles/pandora_minimal.css" type="text/css" />
<link rel="stylesheet" href="styles/js/jquery-ui.min.css" type="text/css" /> <link rel="stylesheet" href="styles/js/jquery-ui.min.css" type="text/css" />
<link rel="stylesheet" href="styles/js/jquery-ui_custom.css" type="text/css" /> <link rel="stylesheet" href="styles/js/jquery-ui_custom.css" type="text/css" />
<script language="javascript" type='text/javascript' src='javascript/pandora.js'></script>
<script language="javascript" type='text/javascript' src='javascript/pandora_ui.js'></script> <script language="javascript" type='text/javascript' src='javascript/pandora_ui.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery.current.js'></script> <script language="javascript" type='text/javascript' src='javascript/jquery.current.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery.pandora.js'></script> <script language="javascript" type='text/javascript' src='javascript/jquery.pandora.js'></script>
<script language="javascript" type='text/javascript' src='javascript/jquery-ui.min.js'></script> <script language="javascript" type='text/javascript' src='javascript/jquery-ui.min.js'></script>
<script language="javascript" type='text/javascript' src='javascript/pandora.js'></script>
<script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.js"></script> <script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.min.js"></script> <script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.min.js"></script>
<script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.time.js"></script> <script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.time.js"></script>
@ -170,48 +156,46 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
<script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.exportdata.pandora.js"></script> <script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.exportdata.pandora.js"></script>
<script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.axislabels.js"></script> <script language="javascript" type="text/javascript" src="graphs/flot/jquery.flot.axislabels.js"></script>
<script language="javascript" type="text/javascript" src="graphs/flot/pandora.flot.js"></script> <script language="javascript" type="text/javascript" src="graphs/flot/pandora.flot.js"></script>
<script language="javascript" type="text/javascript" src="graphs/chartjs/chart.js"></script>
<script language="javascript" type="text/javascript" src="graphs/chartjs/chartjs-plugin-datalabels.min.js"></script>
</head> </head>
<body style='background-color: <?php echo $params['backgroundColor']; ?>;'> <body style='width:794px; margin: 0px; background-color: <?php echo $params['backgroundColor']; ?>;'>
<?php <?php
$params['only_image'] = false; $params['only_image'] = false;
$params['menu'] = false; $params['menu'] = false;
$params['disable_black'] = true; $params['disable_black'] = true;
$params_combined = json_decode($data_combined, true); $params_combined = $data_combined;
$module_list = json_decode($data_module_list, true); $module_list = $data_module_list;
if (isset($params['vconsole']) === false || $params['vconsole'] === false) { $viewport = [
if ((int) $viewport_width > 0) { 'width' => 0,
$params['width'] = (int) $viewport_width; 'height' => 0,
];
$style = 'width:100%;';
if (isset($params['options']['viewport']) === true) {
$viewport = $params['options']['viewport'];
if (empty($viewport['width']) === false) {
$style .= 'width:'.$viewport['width'].'px;';
} }
if ((isset($params['width']) === false if (empty($viewport['height']) === false) {
|| ($params['width'] <= 0)) $style .= 'height:'.$viewport['height'].'px;';
) {
if ((int) $params['width'] <= 0) {
$params['width'] = 650;
}
if ((int) $params['landscape'] === 1) {
$params['width'] = 850;
}
if ($type_graph_pdf === 'slicebar') {
$params['width'] = 100;
$params['height'] = 70;
}
} }
} }
echo '<div>'; echo '<div id="container-chart-generator-item" style="'.$style.' margin:0px;">';
switch ($type_graph_pdf) { switch ($type_graph_pdf) {
case 'combined': case 'combined':
$params['pdf'] = true; $params['pdf'] = true;
echo graphic_combined_module( $result = graphic_combined_module(
$module_list, $module_list,
$params, $params,
$params_combined $params_combined
); );
echo $result;
break; break;
case 'sparse': case 'sparse':
@ -219,67 +203,40 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
echo grafico_modulo_sparse($params); echo grafico_modulo_sparse($params);
break; break;
case 'pie_chart': case 'pie_graph':
$params['pdf'] = true; $params['pdf'] = true;
echo flot_pie_chart( $chart = get_build_setup_charts(
$params['values'], 'PIE',
$params['keys'], $params['options'],
$params['width'], $params['chart_data']
$params['height'],
$params['water_mark_url'],
$params['font'],
$config['font_size'],
$params['legend_position'],
$params['colors'],
$params['hide_labels']
); );
echo $chart->render(true);
break; break;
case 'vbar': case 'vbar_graph':
$params['pdf'] = true; $params['pdf'] = true;
echo flot_vcolumn_chart($params); $chart = get_build_setup_charts(
break; 'BAR',
$params['options'],
case 'hbar': $params['chart_data']
$params['pdf'] = true;
echo flot_hcolumn_chart(
$params['chart_data'],
$params['width'],
$params['height'],
$params['water_mark_url'],
$params['font'],
$config['font_size'],
$params['backgroundColor'],
$params['tick_color'],
$params['val_min'],
$params['val_max'],
$params['pdf']
); );
echo $chart->render(true);
break; break;
case 'ring_graph': case 'ring_graph':
$params['pdf'] = true; $params['pdf'] = true;
echo flot_custom_pie_chart( $params['options']['width'] = 500;
$params['chart_data'], $params['options']['height'] = 500;
$params['width'],
$params['height'], $chart = get_build_setup_charts(
$params['colors'], 'DOUGHNUT',
$params['module_name_list'], $params['options'],
$params['long_index'], $params['chart_data']
$params['no_data'],
false,
'',
$params['water_mark'],
$params['font'],
$config['font_size'],
$params['unit'],
$params['ttl'],
$params['homeurl'],
$params['background_color'],
$params['legend_position'],
$params['background_color'],
$params['pdf']
); );
echo $chart->render(true);
break; break;
case 'slicebar': case 'slicebar':
@ -313,7 +270,6 @@ if (file_exists('languages/'.$user_language.'.mo') === true) {
} }
echo '</div>'; echo '</div>';
echoPhantomCallback();
?> ?>
</body> </body>
</html> </html>

View File

@ -167,7 +167,7 @@ class ConsoleSupervisor
* NOTIF.PHP.UPLOAD_MAX_FILESIZE * NOTIF.PHP.UPLOAD_MAX_FILESIZE
* NOTIF.PHP.MEMORY_LIMIT * NOTIF.PHP.MEMORY_LIMIT
* NOTIF.PHP.DISABLE_FUNCTIONS * NOTIF.PHP.DISABLE_FUNCTIONS
* NOTIF.PHP.PHANTOMJS * NOTIF.PHP.CHROMIUM
* NOTIF.PHP.VERSION * NOTIF.PHP.VERSION
*/ */
@ -349,7 +349,7 @@ class ConsoleSupervisor
* NOTIF.PHP.UPLOAD_MAX_FILESIZE * NOTIF.PHP.UPLOAD_MAX_FILESIZE
* NOTIF.PHP.MEMORY_LIMIT * NOTIF.PHP.MEMORY_LIMIT
* NOTIF.PHP.DISABLE_FUNCTIONS * NOTIF.PHP.DISABLE_FUNCTIONS
* NOTIF.PHP.PHANTOMJS * NOTIF.PHP.CHROMIUM
* NOTIF.PHP.VERSION * NOTIF.PHP.VERSION
*/ */
@ -528,11 +528,7 @@ class ConsoleSupervisor
*/ */
public function maintenanceOperations() public function maintenanceOperations()
{ {
/*
* Process cache clean if needed.
*/
$this->checkCleanPhantomCache();
} }
@ -688,7 +684,7 @@ class ConsoleSupervisor
case 'NOTIF.PHP.UPLOAD_MAX_FILESIZE': case 'NOTIF.PHP.UPLOAD_MAX_FILESIZE':
case 'NOTIF.PHP.MEMORY_LIMIT': case 'NOTIF.PHP.MEMORY_LIMIT':
case 'NOTIF.PHP.DISABLE_FUNCTIONS': case 'NOTIF.PHP.DISABLE_FUNCTIONS':
case 'NOTIF.PHP.PHANTOMJS': case 'NOTIF.PHP.CHROMIUM':
case 'NOTIF.PHP.VERSION': case 'NOTIF.PHP.VERSION':
case 'NOTIF.HISTORYDB': case 'NOTIF.HISTORYDB':
case 'NOTIF.PANDORADB': case 'NOTIF.PANDORADB':
@ -1431,9 +1427,9 @@ class ConsoleSupervisor
$PHPmemory_limit_min = config_return_in_bytes('-1'); $PHPmemory_limit_min = config_return_in_bytes('-1');
} }
// PhantomJS status. // Chromium status.
$phantomjs_dir = io_safe_output($config['phantomjs_bin']); $chromium_dir = io_safe_output($config['chromium_path']);
$result_ejecution = exec($phantomjs_dir.'/phantomjs --version'); $result_ejecution = exec($chromium_dir.' --version');
// PHP version checks. // PHP version checks.
$php_version = phpversion(); $php_version = phpversion();
@ -1577,21 +1573,20 @@ class ConsoleSupervisor
} }
if (!isset($result_ejecution) || $result_ejecution == '') { if (!isset($result_ejecution) || $result_ejecution == '') {
$url = 'https://pandorafms.com/manual/en/documentation/02_installation/04_configuration#Phantomjs'; $url = 'https://www.chromium.org/getting-involved/download-chromium/';
if ($config['language'] == 'es') { // if ($config['language'] == 'es') {
$url = 'https://pandorafms.com/manual/es/documentation/02_installation/04_configuration#Phantomjs'; // $url = 'https://pandorafms.com/manual/es/documentation/02_installation/04_configuration#Phantomjs';
} // }
$this->notify( $this->notify(
[ [
'type' => 'NOTIF.PHP.PHANTOMJS', 'type' => 'NOTIF.PHP.CHROMIUM',
'title' => __('PhantomJS is not installed'), 'title' => __('chromium is not installed'),
'message' => __('To be able to create images of the graphs for PDFs, please install the PhantomJS extension. For that, it is necessary to follow these steps:'), 'message' => __('To be able to create images of the graphs for PDFs, please install the chromium extension. For that, it is necessary to follow these steps:'),
'url' => $url, 'url' => $url,
] ]
); );
} else { } else {
$this->cleanNotifications('NOTIF.PHP.PHANTOMJS'); $this->cleanNotifications('NOTIF.PHP.CHROMIUM');
} }
if ($php_version_array[0] < 8) { if ($php_version_array[0] < 8) {
@ -2698,34 +2693,6 @@ class ConsoleSupervisor
} }
/**
* Clean Phantom cache if needed.
*
* @return void
*/
public function checkCleanPhantomCache()
{
global $config;
if (isset($config['clean_phantomjs_cache']) !== true
|| (int) $config['clean_phantomjs_cache'] !== 1
) {
return;
}
$cache_dir = $config['homedir'].'/attachment/cache';
if (is_dir($cache_dir) === true) {
Files::rmrf($cache_dir);
}
// Clean process has ended.
config_update_value(
'clean_phantomjs_cache',
0
);
}
/** /**
* Verifies the status of synchronization queue and warns if something is * Verifies the status of synchronization queue and warns if something is
* not working as expected. * not working as expected.

View File

@ -113,13 +113,6 @@ define('SECONDS_1YEAR', 31536000);
define('SECONDS_2YEARS', 63072000); define('SECONDS_2YEARS', 63072000);
define('SECONDS_3YEARS', 94608000); define('SECONDS_3YEARS', 94608000);
// PhantomJS Cache cleanup intervals.
define('PHANTOM_CACHE_CLEANUP_ONCE', 0);
define('PHANTOM_CACHE_CLEANUP_WEEKLY', SECONDS_1WEEK);
define('PHANTOM_CACHE_CLEANUP_DAILY', SECONDS_1DAY);
// Separator constats. // Separator constats.
define('SEPARATOR_COLUMN', ';'); define('SEPARATOR_COLUMN', ';');
define('SEPARATOR_ROW', chr(10)); define('SEPARATOR_ROW', chr(10));

View File

@ -16,7 +16,11 @@
* @subpackage Generic_Functions * @subpackage Generic_Functions
*/ */
/** use HeadlessChromium\BrowserFactory;
use HeadlessChromium\Clip;
use HeadlessChromium\Page;
/*
* Include the html and ui functions. * Include the html and ui functions.
*/ */
require_once 'functions_html.php'; require_once 'functions_html.php';
@ -4212,7 +4216,6 @@ function generator_chart_to_pdf(
$hack_metaconsole = ''; $hack_metaconsole = '';
} }
$file_js = $config['homedir'].'/include/web2image.js';
$url = ui_get_full_url(false).$hack_metaconsole.'/include/chart_generator.php'; $url = ui_get_full_url(false).$hack_metaconsole.'/include/chart_generator.php';
if (!$params['return_img_base_64']) { if (!$params['return_img_base_64']) {
@ -4221,65 +4224,89 @@ function generator_chart_to_pdf(
$img_url = ui_get_full_url(false).$hack_metaconsole.'/attachment/'.$img_file; $img_url = ui_get_full_url(false).$hack_metaconsole.'/attachment/'.$img_file;
} }
if ($type_graph_pdf === 'vbar') {
$width_img = $params['generals']['pdf']['width'];
$height_img = $params['generals']['pdf']['height'];
} else if ($type_graph_pdf === 'combined'
&& $params_combined['stacked'] == CUSTOM_GRAPH_VBARS
) {
$width_img = 650;
$height_img = ($params['height'] + 50);
} else if ($type_graph_pdf === 'hbar' || $type_graph_pdf === 'pie_chart') {
$width_img = ($params['width'] ?? 550);
$height_img = $params['height'];
} else {
$width_img = 550;
$height_img = $params['height'];
if ((int) $params['landscape'] === 1) {
$height_img = 150;
$params['height'] = 150;
}
}
$params_encode_json = urlencode(json_encode($params));
if ($params_combined) {
$params_combined = urlencode(json_encode($params_combined));
}
if ($module_list) {
$module_list = urlencode(json_encode($module_list));
}
$session_id = session_id(); $session_id = session_id();
$cache_dir = $config['homedir'].'/attachment/cache'; if ($type_graph_pdf === 'combined') {
$data = [
'data' => $params,
'session_id' => $session_id,
'type_graph_pdf' => $type_graph_pdf,
'data_module_list' => $module_list,
'data_combined' => $params_combined,
];
} else {
$data = [
'data' => $params,
'session_id' => $session_id,
'type_graph_pdf' => $type_graph_pdf,
];
}
$cmd = '"'.io_safe_output($config['phantomjs_bin']); // If not install chromium avoid 500 convert tu images no data to show.
$cmd .= DIRECTORY_SEPARATOR.'phantomjs" '; $chromium_dir = io_safe_output($config['chromium_path']);
$cmd .= ' --disk-cache=true --disk-cache-path="'.$cache_dir.'"'; $result_ejecution = exec($chromium_dir.' --version');
$cmd .= ' --max-disk-cache-size=10000 '; if (empty($result_ejecution) === true) {
$cmd .= ' --ssl-protocol=any --ignore-ssl-errors=true '; if ($params['return_img_base_64']) {
$cmd .= '"'.$file_js.'" "'.$url.'" "'.$type_graph_pdf.'"'; $params['base64'] = true;
$cmd .= ' "'.$params_encode_json.'" "'.$params_combined.'"'; }
$cmd .= ' "'.$module_list.'" "'.$img_path.'"';
$cmd .= ' "'.$width_img.'" "'.$height_img.'"';
$cmd .= ' "'.$session_id.'" "'.$params['return_img_base_64'].'"';
$result = null; return graph_nodata_image($params);
$retcode = null; }
exec($cmd, $result, $retcode);
$img_content = join("\n", $result); try {
$browserFactory = new BrowserFactory($chromium_dir);
// Starts headless chrome.
$browser = $browserFactory->createBrowser(['noSandbox' => true]);
// Creates a new page.
$page = $browser->createPage();
// Navigate to an URL.
$navigation = $page->navigate($url.'?data='.urlencode(json_encode($data)));
$navigation->waitForNavigation(Page::DOM_CONTENT_LOADED);
// Dynamic.
$dynamic_height = $page->evaluate('document.getElementById("container-chart-generator-item").clientHeight')->getReturnValue();
if (empty($dynamic_height) === true) {
$dynamic_height = 200;
}
if (isset($params['options']['viewport']) === true
&& isset($params['options']['viewport']['height']) === true
&& empty($params['options']['viewport']['height']) === false
) {
$dynamic_height = $params['options']['viewport']['height'];
}
$dynamic_width = $page->evaluate('document.getElementById("container-chart-generator-item").clientWidth')->getReturnValue();
if (empty($dynamic_width) === true) {
$dynamic_width = 794;
}
if (isset($params['options']['viewport']) === true
&& isset($params['options']['viewport']['width']) === true
&& empty($params['options']['viewport']['width']) === false
) {
$dynamic_width = $params['options']['viewport']['width'];
}
$clip = new Clip(0, 0, $dynamic_width, $dynamic_height);
if ($params['return_img_base_64']) { if ($params['return_img_base_64']) {
$b64 = $page->screenshot(['clip' => $clip])->getBase64();
// To be used in alerts. // To be used in alerts.
return $img_content; return $b64;
} else { } else {
// To be used in PDF files. // To be used in PDF files.
$b64 = $page->screenshot(['clip' => $clip])->saveToFile($img_path);
$config['temp_images'][] = $img_path; $config['temp_images'][] = $img_path;
return '<img src="'.$img_url.'" />'; return '<img src="'.$img_url.'" />';
} }
} catch (\Throwable $th) {
error_log($th);
} finally {
$browser->close();
}
} }

View File

@ -184,8 +184,8 @@ function config_update_config()
$error_update[] = __('Remote config directory'); $error_update[] = __('Remote config directory');
} }
if (config_update_value('phantomjs_bin', (string) get_parameter('phantomjs_bin'), true) === false) { if (config_update_value('chromium_path', (string) get_parameter('chromium_path'), true) === false) {
$error_update[] = __('phantomjs config directory'); $error_update[] = __('Chromium config directory');
} }
if (config_update_value('loginhash_pwd', io_input_password((string) get_parameter('loginhash_pwd')), true) === false) { if (config_update_value('loginhash_pwd', io_input_password((string) get_parameter('loginhash_pwd')), true) === false) {
@ -935,25 +935,6 @@ function config_update_config()
if (config_update_value('agent_wizard_defaults', json_encode($selectedAgentWizardOptions), true) === false) { if (config_update_value('agent_wizard_defaults', json_encode($selectedAgentWizardOptions), true) === false) {
$error_update[] = __('SNMP Interface Agent Wizard'); $error_update[] = __('SNMP Interface Agent Wizard');
} }
$pjs = get_parameter('phantomjs_cache_interval');
switch ($pjs) {
case $config['phantomjs_cache_interval']:
default;
// No changes.
break;
case PHANTOM_CACHE_CLEANUP_ONCE:
case PHANTOM_CACHE_CLEANUP_DAILY:
case PHANTOM_CACHE_CLEANUP_WEEKLY:
enterprise_hook('phantomjs_cache_interval_schedule', [$pjs]);
break;
}
if (config_update_value('phantomjs_cache_interval', get_parameter('phantomjs_cache_interval'), true) === false
) {
$error_update[] = __('PhantomJS cache interval');
}
break; break;
case 'vis': case 'vis':
@ -1984,14 +1965,9 @@ function config_process_config()
config_update_value('remote_config', $default); config_update_value('remote_config', $default);
} }
if (!isset($config['phantomjs_bin'])) { if (isset($config['chromium_path']) === false) {
if ($is_windows) { $default = '/usr/bin/chromium-browser';
$default = 'C:\PandoraFMS\Pandora_Server\bin'; config_update_value('chromium_path', $default);
} else {
$default = '/usr/bin';
}
config_update_value('phantomjs_bin', $default);
} }
if (!isset($config['date_format'])) { if (!isset($config['date_format'])) {

View File

@ -2634,27 +2634,6 @@ function events_print_event_table(
$events_table = html_print_table($table, true); $events_table = html_print_table($table, true);
$out = $events_table; $out = $events_table;
if (!$tactical_view) {
$out .= '<table width="100%"><tr><td class="w90p align-top pdd_t_0px">';
if ($agent_id != 0) {
$out .= '</td><td class="w200px align-top">';
$out .= '<table cellpadding=0 cellspacing=0 class="databox"><tr><td>';
$out .= '<fieldset class="databox tactical_set">
<legend>'.__('Events -by module-').'</legend>'.graph_event_module(180, 100, $event['id_agente']).'</fieldset>';
$out .= '</td></tr></table>';
} else {
$out .= '</td><td class="w200px align-top">';
$out .= '<table cellpadding=0 cellspacing=0 class="databox"><tr><td>';
$out .= '<fieldset class="databox tactical_set">
<legend>'.__('Event graph').'</legend>'.grafico_eventos_total('', 180, 60).'</fieldset>';
$out .= '<fieldset class="databox tactical_set">
<legend>'.__('Event graph by agent').'</legend>'.grafico_eventos_grupo(180, 60).'</fieldset>';
$out .= '</td></tr></table>';
}
$out .= '</td></tr></table>';
}
unset($table); unset($table);
if ($return) { if ($return) {
@ -5212,7 +5191,7 @@ function events_get_count_events_validated_by_user($data)
) { ) {
foreach ($fullnames as $value) { foreach ($fullnames as $value) {
if (isset($data_graph_by_user[$value['id_user']]) === true) { if (isset($data_graph_by_user[$value['id_user']]) === true) {
$data_graph_by_user[$value['fullname']] = $data_graph_by_user[$value['id_user']]; $data_graph_by_user[io_safe_output($value['fullname'])] = $data_graph_by_user[$value['id_user']];
unset($data_graph_by_user[$value['id_user']]); unset($data_graph_by_user[$value['id_user']]);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1479,7 +1479,7 @@ function netflow_draw_item(
} }
if ($output === 'HTML' || $output === 'PDF') { if ($output === 'HTML' || $output === 'PDF') {
return graph_nodata_image(300, 110, 'data'); return graph_nodata_image(['height' => 110]);
} }
} }

View File

@ -134,7 +134,7 @@ function notifications_get_subtypes(?string $source=null)
'NOTIF.PHP.UPLOAD_MAX_FILESIZE', 'NOTIF.PHP.UPLOAD_MAX_FILESIZE',
'NOTIF.PHP.MEMORY_LIMIT', 'NOTIF.PHP.MEMORY_LIMIT',
'NOTIF.PHP.DISABLE_FUNCTIONS', 'NOTIF.PHP.DISABLE_FUNCTIONS',
'NOTIF.PHP.PHANTOMJS', 'NOTIF.PHP.CHROMIUM',
'NOTIF.PHP.VERSION', 'NOTIF.PHP.VERSION',
'NOTIF.HISTORYDB', 'NOTIF.HISTORYDB',
'NOTIF.PANDORADB', 'NOTIF.PANDORADB',

File diff suppressed because it is too large Load Diff

View File

@ -961,7 +961,7 @@ function reporting_html_top_n($table, $item, $pdf=0)
$table->data['top_n']['cell'] = html_print_table($table1, true); $table->data['top_n']['cell'] = html_print_table($table1, true);
} }
if (!empty($item['charts']['pie'])) { if (empty($item['charts']['pie']) === false) {
if ($pdf !== 0) { if ($pdf !== 0) {
$return_pdf .= $item['charts']['pie']; $return_pdf .= $item['charts']['pie'];
} else { } else {
@ -970,16 +970,15 @@ function reporting_html_top_n($table, $item, $pdf=0)
} }
} }
if (!empty($item['charts']['bars'])) { if (empty($item['charts']['bars']) === false) {
if ($pdf !== 0) { if ($pdf !== 0) {
$return_pdf .= $item['charts']['bars']; $return_pdf .= $item['charts']['bars'];
} else { } else {
// $table->colspan['char_bars']['cell'] = 3;
$table->data['char_pie'][1] = $item['charts']['bars']; $table->data['char_pie'][1] = $item['charts']['bars'];
} }
} }
if (!empty($item['resume'])) { if (empty($item['resume']) === false) {
$table1 = new stdClass(); $table1 = new stdClass();
$table1->width = '99%'; $table1->width = '99%';
@ -5141,7 +5140,17 @@ function reporting_get_stats_summary($data, $graph_width, $graph_height)
// Fixed width non interactive charts. // Fixed width non interactive charts.
$status_chart_width = $graph_width; $status_chart_width = $graph_width;
$tdata[0] = '<div style="margin: auto; width: '.$graph_width.'px;"><div id="status_pie" style="margin: auto; width: '.$graph_width.'">'.graph_agent_status(false, $graph_width, $graph_height, true, true).'</div></div>'; $tdata[0] = '<div style="margin: auto; width: '.$graph_width.'px;">';
$tdata[0] .= '<div id="status_pie" style="margin: auto; width: '.$graph_width.'">';
$tdata[0] .= graph_agent_status(
false,
$graph_width,
$graph_height,
true,
true
);
$tdata[0] .= '</div>';
$tdata[0] .= '</div>';
} else { } else {
$tdata[2] = html_print_image( $tdata[2] = html_print_image(
'images/image_problem_area_small.png', 'images/image_problem_area_small.png',
@ -5151,7 +5160,16 @@ function reporting_get_stats_summary($data, $graph_width, $graph_height)
} }
if ($data['monitor_alerts'] > 0) { if ($data['monitor_alerts'] > 0) {
$tdata[2] = '<div style="margin: auto; width: '.$graph_width.'px;">'.graph_alert_status($data['monitor_alerts'], $data['monitor_alerts_fired'], $graph_width, $graph_height, true, true).'</div>'; $tdata[2] = '<div style="margin: auto; width: '.$graph_width.'px;">';
$tdata[2] .= graph_alert_status(
$data['monitor_alerts'],
$data['monitor_alerts_fired'],
$graph_width,
$graph_height,
true,
true
);
$tdata[2] .= '</div>';
} else { } else {
$tdata[2] = html_print_image( $tdata[2] = html_print_image(
'images/image_problem_area_small.png', 'images/image_problem_area_small.png',

View File

@ -1227,7 +1227,7 @@ function visual_map_print_item(
$module_data = get_bars_module_data( $module_data = get_bars_module_data(
$id_module, $id_module,
($layoutData['type_graph'] !== 'horizontal') $layoutData['type_graph']
); );
$options = []; $options = [];
$options['generals']['rotate'] = true; $options['generals']['rotate'] = true;
@ -2344,7 +2344,7 @@ function get_if_module_is_image($id_module)
} }
function get_bars_module_data($id_module, $vBars=false) function get_bars_module_data($id_module, $typeGraph='horizontal')
{ {
// This charts is only serialize graphs. // This charts is only serialize graphs.
// In other string show image no data to show. // In other string show image no data to show.
@ -2355,7 +2355,7 @@ function get_bars_module_data($id_module, $vBars=false)
); );
$values = false; $values = false;
// avoid showing the image type modules. WUX // Avoid showing the image type modules. WUX.
if (strpos($mod_values, 'data:image/png;base64') !== 0) { if (strpos($mod_values, 'data:image/png;base64') !== 0) {
if (preg_match("/\r\n/", $mod_values)) { if (preg_match("/\r\n/", $mod_values)) {
$values = explode("\r\n", $mod_values); $values = explode("\r\n", $mod_values);
@ -2364,26 +2364,28 @@ function get_bars_module_data($id_module, $vBars=false)
} }
} }
$values_to_return = [];
$index = 0;
$color_index = 0;
$total = 0;
if (!$values) { if (!$values) {
return false; return false;
} }
if ($vBars === false) { $values_to_return = [];
foreach ($values as $val) { foreach ($values as $val) {
$data = explode(',', $val); $data = explode(',', $val);
$values_to_return[$data[0]] = ['g' => $data[1]];
if ($data[0] === $val) {
continue;
} }
$values_to_return['labels'][] = io_safe_output($data[0]);
if ($typeGraph === 'horizontal') {
$values_to_return['data'][] = [
'y' => io_safe_output($data[0]),
'x' => $data[1],
];
} else { } else {
foreach ($values as $val) { $values_to_return['data'][] = [
$data = explode(',', $val); 'x' => io_safe_output($data[0]),
$values_to_return[] = [ 'y' => $data[1],
'tick' => $data[0],
'data' => $data[1],
]; ];
} }
} }
@ -2842,73 +2844,22 @@ function get_donut_module_data($id_module)
$no_data_to_show = true; $no_data_to_show = true;
} }
$colors = [];
$colors[] = '#aa3333';
$colors[] = '#045FB4';
$colors[] = '#8181F7';
$colors[] = '#F78181';
$colors[] = '#D0A9F5';
$colors[] = '#BDBDBD';
$colors[] = '#6AB277';
$max_elements = 6;
$values_to_return = []; $values_to_return = [];
$index = 0;
$total = 0;
foreach ($values as $val) { foreach ($values as $val) {
if ($index < $max_elements) {
$data = explode(',', $val); $data = explode(',', $val);
if ($data[0] === $val) {
continue;
}
if ($no_data_to_show) { if ($no_data_to_show) {
$values_to_return[$index]['tag_name'] = $data[0]; $values_to_return['labels'][] = $data[0];
} else { } else {
$values_to_return[$index]['tag_name'] = $data[0].': '.$data[1]; $values_to_return['labels'][] = $data[0].': '.$data[1];
} }
$values_to_return[$index]['color'] = $colors[$index]; $values_to_return['data'][] = (int) $data[1];
$values_to_return[$index]['value'] = (int) $data[1];
$total += (int) $data[1];
$index++;
} else {
$data = explode(',', $val);
$values_to_return[$index]['tag_name'] = __('Others').': '.$data[1];
$values_to_return[$index]['color'] = $colors[$index];
$values_to_return[$index]['value'] += (int) $data[1];
$total += (int) $data[1];
} }
}
foreach ($values_to_return as $ind => $donut_data) {
$values_to_return[$ind]['percent'] = (($donut_data['value'] * 100) / $total);
}
// sort array
$new_values_to_return = [];
while (!empty($values_to_return)) {
$first = true;
$max_elem = 0;
$max_elem_array = [];
$index_to_del = 0;
foreach ($values_to_return as $i => $val) {
if ($first) {
$max_elem = $val['value'];
$max_elem_array = $val;
$index_to_del = $i;
$first = false;
} else {
if ($val['value'] > $max_elem) {
$max_elem = $val['value'];
$max_elem_array = $val;
$index_to_del = $i;
}
}
}
$new_values_to_return[] = $max_elem_array;
unset($values_to_return[$index_to_del]);
}
$values_to_return = $new_values_to_return;
return $values_to_return; return $values_to_return;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -756,71 +756,3 @@ function print_clock_digital_1($time_format, $timezone, $clock_animation, $width
return $output; return $output;
} }
/**
* Print dougnhnut.
*
* @param array $colors Colors.
* @param integer $width Width.
* @param integer $height Height.
* @param array $data Data.
* @param mixed $data_total Data_total.
*
* @return string HTML.
*/
function print_donut_narrow_graph(
array $colors,
$width,
$height,
array $data,
$data_total
) {
global $config;
if (empty($data)) {
return graph_nodata_image($width, $height, 'pie');
}
$series = count($data);
if (($series != count($colors)) || ($series == 0)) {
return '';
}
$data = json_encode($data);
$colors = json_encode($colors);
$graph_id = uniqid('graph_');
// This is for "Style template" in visual styles.
switch ($config['style']) {
case 'pandora':
$textColor = '#000';
$strokeColor = '#fff';
break;
case 'pandora_black':
$textColor = '#fff';
$strokeColor = '#222';
break;
default:
$textColor = '#000';
$strokeColor = '#fff';
break;
}
$textColor = json_encode($textColor);
$strokeColor = json_encode($strokeColor);
$out = "<div id='$graph_id'></div>";
$out .= include_javascript_d3(true);
$out .= "<script type='text/javascript'>
donutNarrowGraph($colors, $width, $height, $data_total, $textColor, $strokeColor)
.donutbody(d3.select($graph_id))
.data($data)
.render();
</script>";
return $out;
}

View File

@ -52,6 +52,11 @@ function include_javascript_dependencies_flot_graph($return=false, $mobile=false
<script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/flot/jquery.flot.exportdata.pandora.js').'"></script> <script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/flot/jquery.flot.exportdata.pandora.js').'"></script>
<script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/flot/jquery.flot.axislabels.js').'"></script> <script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/flot/jquery.flot.axislabels.js').'"></script>
<script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/flot/pandora.flot.js').'"></script>'; <script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/flot/pandora.flot.js').'"></script>';
// Chartjs.
$output .= '<script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/chartjs/chart.js').'"></script>';
$output .= '<script language="javascript" type="text/javascript" src="'.ui_get_full_url($metaconsole_hack.'/include/graphs/chartjs/chartjs-plugin-datalabels.min.js').'"></script>';
$output .= " $output .= "
<script type='text/javascript'> <script type='text/javascript'>
var precision_graph = ".$config['graph_precision']."; var precision_graph = ".$config['graph_precision'].";

View File

@ -2797,229 +2797,3 @@ function valueToBytes(value) {
// This will actually do the rounding and the decimals. // This will actually do the rounding and the decimals.
return value.toFixed(2) + shorts[pos] + "B"; return value.toFixed(2) + shorts[pos] + "B";
} }
function donutNarrowGraph(
colores,
width,
height,
total,
textColor,
strokeColor
) {
// Default settings
var donutbody = d3.select("body");
var data = {};
// var showTitle = true;
if (width == "") {
width = 180;
}
if (height == "") {
height = 180;
}
var radius = Math.min(width, height) / 2;
var currentVal;
//var color = d3.scale.category20();
var colores_index = [];
var colores_value = [];
$.each(colores, function(index, value) {
colores_index.push(index);
colores_value.push(value);
});
var color = d3.scale
.ordinal()
.domain(colores_index)
.range(colores_value);
var pie = d3.layout
.pie()
.sort(null)
.value(function(d) {
return d.value;
});
var svg, g, arc;
var object = {};
// Method for render/refresh graph
object.render = function() {
if (!svg) {
// Show normal status by default. This variable must be initialized here, before clearing data.
var normal_status = data.Normal;
// Don't draw 0 or invalid values. console.log(data);
var data_map = $.map(data, function(value, index) {
if (value == 0 || isNaN(value)) {
return index;
}
});
$.each(data_map, function(i, val) {
delete data[val];
});
//New data: console.log(data);
arc = d3.svg
.arc()
.outerRadius(radius)
.innerRadius(radius - radius / 4);
svg = donutbody
.append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
g = svg
.selectAll(".arc")
.data(pie(d3.entries(data)))
.enter()
.append("g")
.attr("class", "arc");
g.append("path")
// Attach current value to g so that we can use it for animation
.each(function(d) {
this._current = d;
})
.attr("d", arc)
.attr("stroke", strokeColor)
.style("fill", function(d) {
return color(d.data.key);
});
// This is to show labels on the graph
/* g.append("text")
.attr("transform", function(d) {
return "translate(" + arc.centroid(d) + ")";
})
.attr("dy", ".35em")
.style("text-anchor", "middle");
g.select("text").text(function(d) {
return d.data.key;
});*/
// Show normal status by default.
var percentage_normal;
svg
.append("text")
.datum(data)
.attr("x", 0)
.attr("y", 0 + radius / 10)
.attr("class", "text-tooltip")
.style("text-anchor", "middle")
.attr("fill", textColor)
.style("font-size", function(d) {
if (normal_status) {
percentage_normal = (normal_status * 100) / total;
if (Number.isInteger(percentage_normal)) {
percentage_normal = percentage_normal.toFixed(0);
return radius / 3 + "px";
} else {
percentage_normal = percentage_normal.toFixed(1);
return radius / 3.5 + "px";
}
}
})
.text(function(d) {
if (normal_status) {
return percentage_normal + "%";
} else {
return "0%";
}
});
g.on("mouseover", function(obj) {
//console.log(obj);
var percentage;
svg
.select("text.text-tooltip")
// This is to paint the text of the corresponding color.
/* .attr("fill", function(d) {
return color(obj.data.key);
})*/
.attr("fill", textColor)
.style("font-size", function(d) {
percentage = (d[obj.data.key] * 100) / total;
if (Number.isInteger(percentage)) {
percentage = percentage.toFixed(0);
return radius / 3 + "px";
} else {
percentage = percentage.toFixed(1);
return radius / 3.5 + "px";
}
})
.text(percentage + "%");
});
g.on("mouseout", function(obj) {
svg.select("text.text-tooltip").text(function(d) {
if (normal_status) {
return percentage_normal + "%";
} else {
return "0%";
}
});
// .attr("fill", "#82b92e");
});
} else {
g.data(pie(d3.entries(data)))
.exit()
.remove();
g.select("path")
.transition()
.duration(200)
.attrTween("d", function(a) {
var i = d3.interpolate(this._current, a);
this._current = i(0);
return function(t) {
return arc(i(t));
};
});
g.select("text").attr("transform", function(d) {
return "translate(" + arc.centroid(d) + ")";
});
svg.select("text.text-tooltip").datum(data);
}
return object;
};
// Getter and setter methods
object.data = function(value) {
if (!arguments.length) return data;
data = value;
return object;
};
object.donutbody = function(value) {
if (!arguments.length) return donutbody;
donutbody = value;
return object;
};
object.width = function(value) {
if (!arguments.length) return width;
width = value;
radius = Math.min(width, height) / 2;
return object;
};
object.height = function(value) {
if (!arguments.length) return height;
height = value;
radius = Math.min(width, height) / 2;
return object;
};
return object;
}

View File

@ -2199,3 +2199,44 @@ function loadPasswordConfig(id, value) {
} }
}); });
} }
var formatterDataLabelPie = function(value, ctx) {
let datasets = ctx.chart.data.datasets;
if (datasets.indexOf(ctx.dataset) === datasets.length - 1) {
let sum = datasets[0].data.reduce((a, b) => parseInt(a) + parseInt(b), 0);
let percentage = ((value * 100) / sum).toFixed(1) + "%";
return percentage;
}
};
var formatterDataHorizontalBar = function(value, ctx) {
let datasets = ctx.chart.data.datasets;
if (datasets.indexOf(ctx.dataset) === datasets.length - 1) {
let sum = datasets[0].data.reduce(
(a, b) => {
if (a != undefined && b != undefined) {
return { x: parseInt(a.x) + parseInt(b.x) };
}
},
{ x: 0 }
);
let percentage = ((value.x * 100) / sum.x).toFixed(1) + "%";
return percentage;
}
};
var formatterDataVerticalBar = function(value, ctx) {
let datasets = ctx.chart.data.datasets;
if (datasets.indexOf(ctx.dataset) === datasets.length - 1) {
let sum = datasets[0].data.reduce(
(a, b) => {
if (a != undefined && b != undefined) {
return { y: parseInt(a.y) + parseInt(b.y) };
}
},
{ y: 0 }
);
let percentage = ((value.y * 100) / sum.y).toFixed(1) + "%";
return percentage;
}
};

View File

@ -444,7 +444,7 @@ class TopNWidget extends Widget
metaconsole_restore_db(); metaconsole_restore_db();
} }
} else { } else {
$modules = @db_get_all_rows_sql( $modules = db_get_all_rows_sql(
$sql, $sql,
$search_in_history_db $search_in_history_db
); );
@ -462,6 +462,7 @@ class TopNWidget extends Widget
} }
$data_hbar = []; $data_hbar = [];
$labels = [];
$valueMax = 0; $valueMax = 0;
$valueMin = 0; $valueMin = 0;
$booleanModulesCount = 0; $booleanModulesCount = 0;
@ -476,7 +477,12 @@ class TopNWidget extends Widget
foreach ($modules as $module) { foreach ($modules as $module) {
$module['aliasAgent'] = ui_print_truncate_text($module['aliasAgent'], 20, false, true, false); $module['aliasAgent'] = ui_print_truncate_text($module['aliasAgent'], 20, false, true, false);
$item_name = $module['aliasAgent'].' - '.$module['nameModule']; $item_name = $module['aliasAgent'].' - '.$module['nameModule'];
$data_hbar[$item_name]['g'] = $module[$display]; $labels[] = io_safe_output($item_name);
$data_hbar[] = [
'x' => $module[$display],
'y' => io_safe_output($item_name),
];
// Calculation of max-min values for show in graph. // Calculation of max-min values for show in graph.
$calc = (ceil((5 * (float) $module[$display]) / 100) + $module[$display]); $calc = (ceil((5 * (float) $module[$display]) / 100) + $module[$display]);
// Set of max-min values for graph. // Set of max-min values for graph.
@ -498,26 +504,24 @@ class TopNWidget extends Widget
$height = (count($data_hbar) * 25 + 35); $height = (count($data_hbar) * 25 + 35);
$output .= '<div class="container-center">'; $output .= '<div class="container-center">';
$output .= hbar_graph( $options = [
array_reverse($data_hbar), 'height' => $height,
$size['width'], 'axis' => 'y',
$height, 'legend' => ['display' => false],
[], 'scales' => [
[], 'x' => [
'', 'grid' => ['display' => false],
'', ],
'', 'y' => [
'', 'grid' => ['display' => false],
$config['homedir'].'/images/logo_vertical_water.png', ],
$config['fontpath'], ],
$config['font_size'], 'labels' => $labels,
true, ];
1,
$config['homeurl'], $output .= vbar_graph(
'white', $data_hbar,
'#DFDFDF', $options
$valueMin,
$valueMax
); );
$output .= '</div>'; $output .= '</div>';

View File

@ -424,6 +424,7 @@ class TopNEventByGroupWidget extends Widget
return $output; return $output;
} else { } else {
$data_pie = []; $data_pie = [];
$labels = [];
foreach ($result as $row) { foreach ($result as $row) {
if ($row['id_agente'] == 0) { if ($row['id_agente'] == 0) {
$name = __('System'); $name = __('System');
@ -444,7 +445,8 @@ class TopNEventByGroupWidget extends Widget
$name .= ' ('.$row['count'].')'; $name .= ' ('.$row['count'].')';
$data_pie[$name] = $row['count']; $labels[] = io_safe_output($name);
$data_pie[] = $row['count'];
} }
} }
@ -474,17 +476,14 @@ class TopNEventByGroupWidget extends Widget
$output .= pie_graph( $output .= pie_graph(
$data_pie, $data_pie,
$width, [
$height, 'legend' => [
__('other'), 'display' => true,
'', 'position' => 'right',
false, 'align' => 'center',
$config['fontpath'], ],
$config['font_size'], 'labels' => $labels,
1, ]
$this->values['legendPosition'],
'',
false
); );
} }

View File

@ -427,6 +427,7 @@ class TopNEventByModuleWidget extends Widget
$output .= '</div>'; $output .= '</div>';
return $output; return $output;
} else { } else {
$labels = [];
$data_pie = []; $data_pie = [];
foreach ($result as $row) { foreach ($result as $row) {
if ($row['id_agentmodule'] == 0) { if ($row['id_agentmodule'] == 0) {
@ -479,7 +480,8 @@ class TopNEventByModuleWidget extends Widget
); );
} }
$data_pie[$event_name.' [ '.$name.' ] ('.$row['count'].')'] = $row['count']; $labels[] = $event_name.' [ '.$name.' ] ('.$row['count'].')';
$data_pie[] = $row['count'];
} }
} }
@ -509,17 +511,14 @@ class TopNEventByModuleWidget extends Widget
$output = pie_graph( $output = pie_graph(
$data_pie, $data_pie,
$width, [
$height, 'legend' => [
__('other'), 'display' => true,
'', 'position' => 'right',
false, 'align' => 'center',
$config['fontpath'], ],
$config['font_size'], 'labels' => $labels,
1, ]
$this->values['legendPosition'],
'',
false
); );
} }

View File

@ -175,7 +175,7 @@ class WuxWidget extends Widget
// Must be configured before using. // Must be configured before using.
$this->configurationRequired = false; $this->configurationRequired = false;
if (empty($this->options) === true) { if (empty($this->values['agentId']) === true) {
$this->configurationRequired = true; $this->configurationRequired = true;
} }

View File

@ -538,7 +538,7 @@ final class Container extends Model
'OR' 'OR'
); );
if ($rows === false) { if ($row === false) {
return ''; return '';
} }

View File

@ -226,85 +226,6 @@ final class BarsGraph extends Item
$moduleId = $linkedModule['moduleId']; $moduleId = $linkedModule['moduleId'];
$metaconsoleId = $linkedModule['metaconsoleId']; $metaconsoleId = $linkedModule['metaconsoleId'];
// Add colors that will use the graphics.
$color = [];
$color[0] = [
'border' => '#000000',
'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[1] = [
'border' => '#000000',
'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[2] = [
'border' => '#000000',
'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[3] = [
'border' => '#000000',
'color' => $config['graph_color4'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[4] = [
'border' => '#000000',
'color' => $config['graph_color5'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[5] = [
'border' => '#000000',
'color' => $config['graph_color6'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[6] = [
'border' => '#000000',
'color' => $config['graph_color7'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[7] = [
'border' => '#000000',
'color' => $config['graph_color8'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[8] = [
'border' => '#000000',
'color' => $config['graph_color9'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[9] = [
'border' => '#000000',
'color' => $config['graph_color10'],
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[11] = [
'border' => '#000000',
'color' => COL_GRAPH9,
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[12] = [
'border' => '#000000',
'color' => COL_GRAPH10,
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[13] = [
'border' => '#000000',
'color' => COL_GRAPH11,
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[14] = [
'border' => '#000000',
'color' => COL_GRAPH12,
'alpha' => CHART_DEFAULT_ALPHA,
];
$color[15] = [
'border' => '#000000',
'color' => COL_GRAPH13,
'alpha' => CHART_DEFAULT_ALPHA,
];
// Maybe connect to node. // Maybe connect to node.
$nodeConnected = false; $nodeConnected = false;
if (\is_metaconsole() === true && $metaconsoleId !== null) { if (\is_metaconsole() === true && $metaconsoleId !== null) {
@ -320,13 +241,15 @@ final class BarsGraph extends Item
} }
} }
$moduleData = \get_bars_module_data( $width = (int) $data['width'];
$moduleId, $height = (int) $data['height'];
($typeGraph !== 'horizontal') $moduleData = \get_bars_module_data($moduleId, $typeGraph);
);
if ($moduleData !== false && is_array($moduleData) === true) { if (empty($moduleData) === true) {
array_pop($moduleData); $graph = graph_nodata_image(['width' => $width, 'height' => $height]);
} } else {
array_pop($moduleData['labels']);
array_pop($moduleData['data']);
$waterMark = [ $waterMark = [
'file' => $config['homedir'].'/images/logo_vertical_water.png', 'file' => $config['homedir'].'/images/logo_vertical_water.png',
@ -357,66 +280,49 @@ final class BarsGraph extends Item
if ($rc !== false) { if ($rc !== false) {
$graph = base64_encode($rc); $graph = base64_encode($rc);
} else { } else {
$graph = graph_nodata_image( $graph = graph_nodata_image(['height' => $height]);
// Width.
$width,
// Height.
$height,
// Type.
'hbar',
// Text.
'',
// Percent.
false,
// Base64.
true
);
} }
} else { } else {
if ($typeGraph === 'horizontal') { $size = $config['font_size'];
$graph = \hbar_graph(
$moduleData,
$width,
$height,
$color,
[],
[],
'images/image_problem_area.png',
'',
'',
$waterMark,
$config['fontpath'],
$config['fontsize'],
'',
2,
$config['homeurl'],
$backGroundColor,
$gridColor,
null,
null,
true
);
} else {
$options = [];
$options['generals']['rotate'] = true;
$options['generals']['forceTicks'] = true;
$options['generals']['arrayColors'] = $color;
$options['grid']['backgroundColor'] = $backGroundColor;
$options['y']['color'] = $backGroundColor;
$options['x']['color'] = $backGroundColor;
if ($ratio != 0) { if ($ratio != 0) {
$options['x']['font']['size'] = (($config['font_size'] * $ratio) + 1); $size = ($config['font_size'] * $ratio);
$options['x']['font']['color'] = $gridColor;
$options['y']['font']['size'] = (($config['font_size'] * $ratio) + 1);
$options['y']['font']['color'] = $gridColor;
} }
$options['generals']['pdf']['width'] = $width; $options = [
$options['generals']['pdf']['width'] = $width; 'width' => $width,
$options['generals']['pdf']['height'] = $height; 'height' => $height,
$options['x']['labelWidth'] = $sizeLabelTickWidth; 'waterMark' => $waterMark,
$graph = vbar_graph($moduleData, $options, 2); 'legend' => ['display' => false],
'scales' => [
'x' => [
'grid' => [
'display' => true,
'color' => $gridColor,
],
'ticks' => [
'fonts' => ['size' => $size],
],
],
'y' => [
'grid' => [
'display' => true,
'color' => $gridColor,
],
'ticks' => [
'fonts' => ['size' => $size],
],
],
],
'labels' => $moduleData['labels'],
];
if ($typeGraph === 'horizontal') {
$options['axis'] = 'y';
}
$graph = '<div style="background-color:'.$backGroundColor.'">';
$graph .= vbar_graph($moduleData['data'], $options);
$graph .= '</div>';
} }
} }
@ -425,10 +331,7 @@ final class BarsGraph extends Item
\metaconsole_restore_db(); \metaconsole_restore_db();
} }
$imgbase64 = 'data:image/png;base64,'; $data['html'] = $graph;
$imgbase64 .= $graph;
$data['html'] = $imgbase64;
return $data; return $data;
} }

View File

@ -72,7 +72,7 @@ final class DonutGraph extends Item
'border_color', 'border_color',
] ]
), ),
'#000000' '#ffffff'
); );
} }
@ -103,13 +103,11 @@ final class DonutGraph extends Item
// Load side libraries. // Load side libraries.
global $config; global $config;
include_once $config['homedir'].'/include/functions_visual_map.php'; include_once $config['homedir'].'/include/functions_visual_map.php';
include_once $config['homedir'].'/include/graphs/functions_d3.php';
if (is_metaconsole()) { if (is_metaconsole()) {
\enterprise_include_once('include/functions_metaconsole.php'); \enterprise_include_once('include/functions_metaconsole.php');
} }
// Extract needed properties. // Extract needed properties.
$legendBackGroundColor = static::extractLegendBackgroundColor($data);
// Get the linked agent and module Ids. // Get the linked agent and module Ids.
$linkedModule = static::extractLinkedModule($data); $linkedModule = static::extractLinkedModule($data);
$agentId = $linkedModule['agentId']; $agentId = $linkedModule['agentId'];
@ -158,32 +156,27 @@ final class DonutGraph extends Item
if ($isString === true) { if ($isString === true) {
$graphData = \get_donut_module_data($moduleId); $graphData = \get_donut_module_data($moduleId);
if (empty($graphData) || $graphData === null) {
$aux = [];
$aux[0]['tag_name'] = 'No data to show';
$aux[0]['color'] = '#aa3333';
$aux[0]['value'] = 1;
$aux[0]['percent'] = 100;
$graphData = $aux;
}
$data['html'] = \d3_donut_graph( if (empty($graphData) === true) {
(int) $data['id'], $data['html'] = graph_nodata_image(['width' => $width, 'height' => $height]);
$width,
$height,
$graphData,
$legendBackGroundColor
);
} else { } else {
$src = 'images/console/signes/wrong_donut_graph.png'; array_pop($graphData['labels']);
if (\is_metaconsole() === true) { array_pop($graphData['data']);
$src = '../../'.$src;
$options = [
'waterMark' => false,
'legend' => [
'display' => true,
'position' => 'right',
'align' => 'center',
],
'labels' => $graphData['labels'],
];
$data['html'] = \ring_graph($graphData['data'], $options);
} }
} else {
$src = ui_get_full_url($src); $data['html'] = graph_nodata_image(['width' => $width, 'height' => $height]);
$style = 'width:'.$width.'px; height:'.$height.'px;';
$data['html'] = '<img src="'.$src.'" style="'.$style.'">';
} }
// Restore connection. // Restore connection.
@ -255,12 +248,12 @@ final class DonutGraph extends Item
// Resume data color. // Resume data color.
$inputs[] = [ $inputs[] = [
'label' => __('Resume data color'), 'label' => __('Background color'),
'arguments' => [ 'arguments' => [
'wrapper' => 'div', 'wrapper' => 'div',
'name' => 'legendBackgroundColor', 'name' => 'legendBackgroundColor',
'type' => 'color', 'type' => 'color',
'value' => $values['legendBackgroundColor'], 'value' => (($values['legendBackgroundColor']) ?? '#ffffff'),
'return' => true, 'return' => true,
], ],
]; ];

View File

@ -285,8 +285,6 @@ final class ModuleGraph extends Item
\enterprise_include_once('include/functions_metaconsole.php'); \enterprise_include_once('include/functions_metaconsole.php');
} }
$imageOnly = false;
$backgroundType = static::extractBackgroundType($data); $backgroundType = static::extractBackgroundType($data);
$period = static::extractPeriod($data); $period = static::extractPeriod($data);
$showLegend = static::extractShowLegend($data); $showLegend = static::extractShowLegend($data);
@ -367,7 +365,7 @@ final class ModuleGraph extends Item
'title' => '', 'title' => '',
'unit_name' => null, 'unit_name' => null,
'show_alerts' => false, 'show_alerts' => false,
'only_image' => $imageOnly, 'only_image' => false,
'vconsole' => true, 'vconsole' => true,
'backgroundColor' => $backgroundType, 'backgroundColor' => $backgroundType,
'show_legend' => $showLegend, 'show_legend' => $showLegend,
@ -384,11 +382,7 @@ final class ModuleGraph extends Item
'modules_series' => $customGraph['modules_series'], 'modules_series' => $customGraph['modules_series'],
]; ];
if ($imageOnly !== false) { $chart = \graphic_combined_module(
$imgbase64 = 'data:image/png;base64,';
}
$imgbase64 .= \graphic_combined_module(
false, false,
$params, $params,
$paramsCombined $paramsCombined
@ -417,7 +411,7 @@ final class ModuleGraph extends Item
$moduleId $moduleId
), ),
'unit' => \modules_get_unit($moduleId), 'unit' => \modules_get_unit($moduleId),
'only_image' => $imageOnly, 'only_image' => false,
'menu' => false, 'menu' => false,
'backgroundColor' => $backgroundType, 'backgroundColor' => $backgroundType,
'type_graph' => $graphType, 'type_graph' => $graphType,
@ -429,14 +423,10 @@ final class ModuleGraph extends Item
'server_id' => $metaconsoleId, 'server_id' => $metaconsoleId,
]; ];
if ($imageOnly !== false) { $chart = \grafico_modulo_sparse($params);
$imgbase64 = 'data:image/png;base64,';
} }
$imgbase64 .= \grafico_modulo_sparse($params); $data['html'] = $chart;
}
$data['html'] = $imgbase64;
// Restore connection. // Restore connection.
if ($nodeConnected === true) { if ($nodeConnected === true) {
\metaconsole_restore_db(); \metaconsole_restore_db();

View File

@ -450,7 +450,8 @@ class View extends \HTML
$data['metaconsoleId'] = \get_parameter('metaconsoleId'); $data['metaconsoleId'] = \get_parameter('metaconsoleId');
$data['moduleId'] = \get_parameter('moduleId'); $data['moduleId'] = \get_parameter('moduleId');
$data['legendBackgroundColor'] = \get_parameter( $data['legendBackgroundColor'] = \get_parameter(
'legendBackgroundColor' 'legendBackgroundColor',
'#ffffff'
); );
break; break;

View File

@ -1,19 +0,0 @@
var webPage = require("webpage");
var page = webPage.create();
var url =
"http://nova/pandora_console/operation/agentes/stat_win.php?type=sparse&period=86400&id=136574&label=QXJ0aWNhJiN4MjA7d2ViJiN4MjA7cGFnZSYjeDIwO2V4YW1wbGU%3D&refresh=600&draw_events=0";
var r = page.addCookie({
name: "PHPSESSID" /* required property */,
value: "23qu7l1sgb3iq3bkaedr724hp3" /* required property */,
path: "/pandora_console",
domain: "nova"
});
console.log(r);
page.viewportSize = { width: 750, height: 350 };
page.open(url, function start(status) {
page.render("output.jpeg", { format: "jpeg", quality: "100" });
phantom.exit();
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,189 +0,0 @@
var system = require("system");
/* global phantom */
if (system.args.length < 3 || system.args.length > 11) {
phantom.exit(1);
}
var url = system.args[1];
var type_graph_pdf = system.args[2];
var url_params = system.args[3];
var url_params_comb = system.args[4];
var url_module_list = system.args[5];
var output_filename = system.args[6];
var viewport_width = system.args[7];
var viewport_height = system.args[8];
var session_id = system.args[9];
var base_64 = system.args[10];
var post_data = "";
if (!viewport_width) {
viewport_width = 750;
}
if (!viewport_height) {
viewport_height = 350;
}
if (type_graph_pdf == "combined") {
post_data = {
data: url_params,
session_id: session_id,
type_graph_pdf: type_graph_pdf,
data_module_list: url_module_list,
data_combined: url_params_comb
};
} else {
post_data = {
data: url_params,
session_id: session_id,
type_graph_pdf: type_graph_pdf
};
}
/* DEBUG
page.onAlert = function() {
console.log("onAlert");
};
page.onCallback = function() {
console.log("onCallback");
};
page.onClosing = function() {
console.log("onClosing");
};
page.onConfirm = function() {
console.log("onConfirm");
};
page.onConsoleMessage = function() {
console.log("onConsoleMessage");
};
page.onError = function() {
console.log("onError");
};
page.onFilePicker = function() {
console.log("onFilePicker");
};
page.onInitialized = function() {
console.log("onInitialized");
};
page.onLoadFinished = function() {
console.log("onLoadFinished");
};
page.onLoadStarted = function() {
console.log("onLoadStarted");
};
page.onNavigationRequested = function() {
console.log("onNavigationRequested");
};
page.onPageCreated = function() {
console.log("onPageCreated");
};
page.onPrompt = function() {
console.log("onPrompt");
};
page.onResourceError = function() {
console.log("onResourceError");
};
page.onResourceReceived = function(res) {
console.log("onResourceReceived" + ";" + res.url + ";" + res.status);
};
page.onResourceRequested = function(res) {
console.log("onResourceRequested" + ";" + res.url);
};
page.onResourceTimeout = function() {
console.log("onResourceTimeout");
};
page.onUrlChanged = function(url) {
console.log("onUrlChanged" + ";" + url);
};
*/
var page = require("webpage").create();
page.onResourceError = function(resourceError) {
console.log(
"Unable to load resource (#" +
resourceError.id +
"URL:" +
resourceError.url +
")"
);
console.log(
"Error code: " +
resourceError.errorCode +
". Description: " +
resourceError.errorString
);
phantom.exit(1);
};
// Not supposed to be prompted messages.
page.onPrompt = function() {
console.log("Prompt message detected.");
phantom.exit(1);
};
page.viewportSize = {
width: viewport_width,
height: viewport_height
};
page.zoomFactor = 1;
page.settings.userAgent =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36";
page.settings.resourceTimeout = 120000;
page.settings.localToRemoteUrlAccessEnabled = true;
page.onConsoleMessage = function(msg) {
console.log(msg);
page.close();
phantom.exit();
};
page.onError = function(msg) {
console.log(msg);
page.close();
phantom.exit();
};
page.onCallback = function() {
if (!base_64) {
page.render(output_filename, { format: "png" });
} else {
page.settings.loadImages = false;
var base64 = page.renderBase64("png");
// do not remove this console.output
console.log(base64);
}
phantom.exit();
};
page.open(url, "POST", "data=" + btoa(JSON.stringify(post_data)), function(
status
) {
if (status == "fail") {
console.out("Failed to generate chart.");
phantom.exit();
}
});
phantom.onError = function(msg, trace) {
var msgStack = ["PHANTOM ERROR: " + msg];
if (trace && trace.length) {
msgStack.push("TRACE:");
trace.forEach(function(t) {
msgStack.push(
" -> " +
(t.file || t.sourceURL) +
": " +
t.line +
(t.function ? " (in function " + t.function + ")" : "")
);
});
}
console.log(msgStack.join("\n"));
phantom.exit(1);
};

View File

@ -55,6 +55,7 @@ if ($force_refresh == 1) {
db_process_sql('UPDATE tgroup_stat SET utimestamp = 0'); db_process_sql('UPDATE tgroup_stat SET utimestamp = 0');
} }
$updated_time = '';
if ($config['realtimestats'] == 0) { if ($config['realtimestats'] == 0) {
$updated_time = "<a href='index.php?sec=estado&sec2=operation/agentes/tactical&force_refresh=1'>"; $updated_time = "<a href='index.php?sec=estado&sec2=operation/agentes/tactical&force_refresh=1'>";
$updated_time .= __('Last update').' : '.ui_print_timestamp(db_get_sql('SELECT min(utimestamp) FROM tgroup_stat'), true); $updated_time .= __('Last update').' : '.ui_print_timestamp(db_get_sql('SELECT min(utimestamp) FROM tgroup_stat'), true);
@ -240,10 +241,12 @@ if ($is_admin) {
include $config['homedir'].'/godmode/servers/servers.build_table.php'; include $config['homedir'].'/godmode/servers/servers.build_table.php';
} }
$out = '<table cellpadding=0 cellspacing=0 class="databox pies mrgn_top_15px" width=100%><tr><td>'; $out = '<table cellpadding=0 cellspacing=0 class="databox pies mrgn_top_15px" width=100%><tr><td style="width:50%;">';
$out .= '<fieldset class="padding-0 databox tactical_set" id="total_event_graph"> $out .= '<fieldset class="padding-0 databox tactical_set" id="total_event_graph">';
<legend>'.__('Event graph').'</legend>'.html_print_image('images/spinner.gif', true, ['id' => 'spinner_total_event_graph']).'</fieldset>'; $out .= '<legend>'.__('Event graph').'</legend>';
$out .= '</td><td>'; $out .= html_print_image('images/spinner.gif', true, ['id' => 'spinner_total_event_graph']);
$out .= '</fieldset>';
$out .= '</td><td style="width:50%;">';
$out .= '<fieldset class="padding-0 databox tactical_set" id="graphic_event_group"> $out .= '<fieldset class="padding-0 databox tactical_set" id="graphic_event_group">
<legend>'.__('Event graph by agent').'</legend>'.html_print_image('images/spinner.gif', true, ['id' => 'spinner_graphic_event_group']).'</fieldset>'; <legend>'.__('Event graph by agent').'</legend>'.html_print_image('images/spinner.gif', true, ['id' => 'spinner_graphic_event_group']).'</fieldset>';
$out .= '</td></tr></table>'; $out .= '</td></tr></table>';

View File

@ -26,16 +26,16 @@ if (!$config['integria_enabled']) {
} }
echo '<table width="90%"> echo '<table width="90%">
<tr><td valign="top"><h3>'.__('Incidents by status').'</h3>'; <tr><td valign="top" style="width:50%;"><h3>'.__('Incidents by status').'</h3>';
echo graph_incidents_status(); echo graph_incidents_status();
echo '<td valign="top"><h3>'.__('Incidents by priority').'</h3>'; echo '<td valign="top" style="width:50%;"><h3>'.__('Incidents by priority').'</h3>';
echo grafico_incidente_prioridad(); echo grafico_incidente_prioridad();
echo '<tr><td><h3>'.__('Incidents by group').'</h3>'; echo '<tr><td style="width:50%;"><h3>'.__('Incidents by group').'</h3>';
echo graphic_incident_group(); echo graphic_incident_group();
echo '<td><h3>'.__('Incidents by user').'</h3>'; echo '<td style="width:50%;"><h3>'.__('Incidents by user').'</h3>';
echo graphic_incident_user(); echo graphic_incident_user();
echo '</table>'; echo '</table>';

View File

@ -269,6 +269,7 @@ if (!empty($main_value)) {
// Print the data and build the chart. // Print the data and build the chart.
$table->data = []; $table->data = [];
$chart_data = []; $chart_data = [];
$labels = [];
$hide_filter = !empty($main_value) && ($action === 'udp' || $action === 'tcp'); $hide_filter = !empty($main_value) && ($action === 'udp' || $action === 'tcp');
foreach ($data as $item) { foreach ($data as $item) {
$row = []; $row = [];
@ -294,19 +295,20 @@ foreach ($data as $item) {
$table->data[] = $row; $table->data[] = $row;
$labels[] = io_safe_output($item['host']);
// Build the pie graph data structure. // Build the pie graph data structure.
switch ($order_by) { switch ($order_by) {
case 'pkts': case 'pkts':
$chart_data[$item['host']] = $item['sum_bytes']; $chart_data[] = $item['sum_bytes'];
break; break;
case 'flows': case 'flows':
$chart_data[$item['host']] = $item['sum_flows']; $chart_data[] = $item['sum_flows'];
break; break;
case 'bytes': case 'bytes':
default: default:
$chart_data[$item['host']] = $item['sum_bytes']; $chart_data[] = $item['sum_bytes'];
break; break;
} }
} }
@ -317,13 +319,21 @@ if (empty($data)) {
echo '<div class="flex mrgn_top_10px">'; echo '<div class="flex mrgn_top_10px">';
html_print_table($table); html_print_table($table);
$options = [
'height' => 230,
'legend' => [
'display' => true,
'position' => 'right',
'align' => 'center',
],
'labels' => $labels,
];
// Print the graph. // Print the graph.
echo '<div class="mrgn_top_50px w40p">'; echo '<div class="mrgn_top_50px w40p">';
echo pie_graph( echo pie_graph(
$chart_data, $chart_data,
320, $options
200,
__('Others')
); );
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';

View File

@ -307,34 +307,6 @@ if ($view_graph) {
return; return;
} }
if ($graph_return) {
echo "<table id='graph-container' class='databox filters' cellpadding='0' cellspacing='0' width='100%'>";
echo '<tr><td>';
if (!is_ajax()) {
echo '<div id="spinner_loading" class="loading invisible" style="display:flex;flex-direction:column-reverse;justify-content:center;align-items:center">';
echo html_print_image('images/spinner.gif', true, ['width' => '20px']);
echo __('Loading').'&hellip;';
echo '</div>';
}
if ($stacked == CUSTOM_GRAPH_VBARS) {
echo '<div class="w100p height_600px">';
echo '<div id="div-container" class="w100p height_600px">';
} else {
echo '<div id="div-container">';
}
echo $graph_return;
echo '</div>';
if ($stacked == CUSTOM_GRAPH_VBARS) {
echo '</div>';
}
echo '</td></tr></table>';
} else {
ui_print_info_message([ 'no_close' => true, 'message' => __('No data.') ]);
}
if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD) { if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD) {
$stacked = 4; $stacked = 4;
} }
@ -403,6 +375,31 @@ if ($view_graph) {
echo '</table>'; echo '</table>';
echo '</form>'; echo '</form>';
if ($graph_return) {
echo "<table id='graph-container' class='databox filters' cellpadding='0' cellspacing='0' style='height:100%;width:100%;overflow:hidden;'>";
echo '<tr><td>';
if (!is_ajax()) {
echo '<div id="spinner_loading" class="loading invisible" style="display:flex;flex-direction:column-reverse;justify-content:center;align-items:center">';
echo html_print_image('images/spinner.gif', true, ['width' => '20px']);
echo __('Loading').'&hellip;';
echo '</div>';
}
echo '<div id="div-container" class="w100p" style="height:100%;">';
echo '<div style="position: relative; display: flex; flex-direction:row; justify-content: center; align-items: center; align-content: center; width:100%; height:50vh;">';
echo '<div style="flex: 0 0 auto; width:99%; height:100%;">';
echo $graph_return;
echo '</div>';
echo '</div>';
echo '</div>';
echo '</td></tr></table>';
} else {
ui_print_info_message([ 'no_close' => true, 'message' => __('No data.') ]);
}
/* /*
We must add javascript here. Otherwise, the date picker won't We must add javascript here. Otherwise, the date picker won't
work if the date is not correct because php is returning. work if the date is not correct because php is returning.

View File

@ -184,7 +184,7 @@ $table_source_data->head['num'] = __('Number');
$table_source_data->data = []; $table_source_data->data = [];
$table_source_graph_data = []; $table_source_graph_data = [];
$labels = [];
foreach ($traps_generated_by_source as $trap) { foreach ($traps_generated_by_source as $trap) {
$row = []; $row = [];
@ -202,25 +202,30 @@ foreach ($traps_generated_by_source as $trap) {
$table_source_data->data[] = $row; $table_source_data->data[] = $row;
$table_source_graph_data[$trap['source']] = (int) $trap['num']; $labels[] = io_safe_output($trap['source']);
$table_source_graph_data[] = (int) $trap['num'];
} }
$table_source_row['table'] = html_print_table($table_source_data, true); $table_source_row['table'] = html_print_table($table_source_data, true);
unset($table_source_data); unset($table_source_data);
if (empty($table_source_graph_data)) { if (empty($table_source_graph_data)) {
$table_source_graph = graph_nodata_image(); $table_source_graph = graph_nodata_image([]);
} else { } else {
$options = [
'height' => 200,
'waterMark' => $water_mark,
'legend' => [
'display' => true,
'position' => 'right',
'align' => 'center',
],
'labels' => $labels,
];
$table_source_graph = pie_graph( $table_source_graph = pie_graph(
$table_source_graph_data, $table_source_graph_data,
400, $options
550,
__('Other'),
'',
$water_mark,
$config['fontpath'],
$config['font_size'],
1
); );
} }
@ -252,32 +257,36 @@ $table_oid_data->head['num'] = __('Number');
$table_oid_data->data = []; $table_oid_data->data = [];
$table_oid_graph_data = []; $table_oid_graph_data = [];
$labels = [];
foreach ($traps_generated_by_oid as $trap) { foreach ($traps_generated_by_oid as $trap) {
$table_oid_data->data[] = [ $table_oid_data->data[] = [
'oid' => $trap['oid'], 'oid' => $trap['oid'],
'num' => (int) $trap['num'], 'num' => (int) $trap['num'],
]; ];
$labels[] = io_safe_output($trap['oid']);
$table_oid_graph_data[$trap['oid']] = (int) $trap['num']; $table_oid_graph_data[] = (int) $trap['num'];
} }
$table_oid_row['table'] = html_print_table($table_oid_data, true); $table_oid_row['table'] = html_print_table($table_oid_data, true);
unset($table_oid_data); unset($table_oid_data);
if (empty($table_oid_graph_data)) { if (empty($table_oid_graph_data)) {
$table_oid_graph = graph_nodata_image(); $table_oid_graph = graph_nodata_image([]);
} else { } else {
$options = [
'height' => 200,
'waterMark' => $water_mark,
'legend' => [
'display' => true,
'position' => 'right',
'align' => 'center',
],
'labels' => $labels,
];
$table_oid_graph = pie_graph( $table_oid_graph = pie_graph(
$table_oid_graph_data, $table_oid_graph_data,
400, $options
550,
__('Other'),
'',
$water_mark,
$config['fontpath'],
$config['font_size'],
1
); );
} }

View File

@ -112,10 +112,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''), ('custom_report_front_header', ''),
('custom_report_front_footer', ''), ('custom_report_front_footer', ''),
('MR', 59), ('MR', 60),
('identification_reminder', 1), ('identification_reminder', 1),
('identification_reminder_timestamp', 0), ('identification_reminder_timestamp', 0),
('current_package', 767), ('current_package', 768),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.00097656250000":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'), ('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.00097656250000":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'), ('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'), ('custom_support_logo', 'default_support.png'),
@ -146,7 +146,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('gotty', '/usr/bin/gotty'), ('gotty', '/usr/bin/gotty'),
('custom_module_units', '{"bytes":"bytes","entries":"entries","files":"files","hits":"hits","sessions":"sessions","users":"users","ºC":"ºC","ºF":"ºF"}'), ('custom_module_units', '{"bytes":"bytes","entries":"entries","files":"files","hits":"hits","sessions":"sessions","users":"users","ºC":"ºC","ºF":"ºF"}'),
('server_unique_identifier', replace(uuid(),'-','')), ('server_unique_identifier', replace(uuid(),'-','')),
('lts_name', 'Hope'); ('lts_name', '');
UNLOCK TABLES; UNLOCK TABLES;
-- --

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.2",
"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
{
}

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