diff --git a/README.txt b/README.txt index f70eb5aa0e0119bff31f8907dbf3417e85d11415..05732d0836432b240192d956e76daa4da7368da7 100644 --- a/README.txt +++ b/README.txt @@ -37,24 +37,16 @@ particular advantages and disadvantages. Installing Libraries --------------------- -The 8.x version of Charts is designed to be used with Composer. After you -enable a sub-module (charts_c3, charts_google, or charts_highcharts), you need -to download the library. Here's how I would do it for C3 (starting in my Drupal -root directory: +Using Composer: -cd modules/charts/modules/charts_c3 -composer install - -This will set up the following directory structure within your charts_c3 -directory: - -vendor - - cthree - - css - - c3.min.css - - c3.min.js - - dthree - - d3.v3.min.js +1: Ensure that you have the `composer/installers` package installed. +2: Ensure you have an installer-paths for the drupal-library type. Such as in + the composer.json of + https://github.com/drupal-composer/drupal-project/blob/8.x/composer.json +3: In each sub-module, there is a README.txt file that you can use to copy the + info inside the composer.json of your project. +4: Run 'composer install' or 'composer update' or the 'composer require' command + specified in each README.txt on your project composer.json. There are numerous tutorials on Drupal.org and elsewhere on the web if you are looking for more information about how to use Composer with Drupal 8. @@ -103,17 +95,6 @@ A major difference between the Drupal 7 and Drupal 8 versions of this module is that the Drupal 8 module uses a Chart Attachment plugin for creating a separate chart series that can be attached to a parent display. -As of the -alpha release, there is a lot of work needed here. The following are -identified questions/issues, which we would like your help with: - -1) Is a Chart Attachment (previously Chart Add-on) display still needed with -the improvements made to the module in Drupal 8? -2) Todo: determine how to respect the "Create Secondary Axis" option on the -Chart Attachment -3) Todo: determine how to respect the selection of a different chart type (for -example, the display could be a bar graph and the attachment could be a line -graph) - Support ------- diff --git a/modules/charts_c3/.gitignore b/modules/charts_c3/.gitignore deleted file mode 100644 index 4f4acd356ffd7eabb0eec871e7edb678ffe6f6b0..0000000000000000000000000000000000000000 --- a/modules/charts_c3/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -vendor/ -composer.lock \ No newline at end of file diff --git a/modules/charts_c3/README.txt b/modules/charts_c3/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..019c40c387bf0ae5777954b77e3e062206f60430 --- /dev/null +++ b/modules/charts_c3/README.txt @@ -0,0 +1,52 @@ +Installation using Composer (recommended) +======================================== + +If you use Composer to manage dependencies, edit "/composer.json" as follows. + + 1. Run "composer require --prefer-dist composer/installers" to ensure that you + have the "composer/installers" package installed. This package facilitates + the installation of packages into directories other than "/vendor" (e.g. + "/libraries") using Composer. + + 2. Add the following to the "installer-paths" section of "composer.json": + +"libraries/{$name}": ["type:drupal-library"], + + 3. Add the following to the "repositories" section of "composer.json": + + { + "type": "package", + "package": { + "name": "c3js/c3", + "version": "v0.4.18", + "type": "drupal-library", + "extra": { + "installer-name": "c3" + }, + "dist": { + "url": "https://github.com/c3js/c3/archive/v0.4.18.zip", + "type": "zip" + } + } + }, + { + "type": "package", + "package": { + "name": "d3/d3", + "version": "v3.5.17", + "type": "drupal-library", + "extra": { + "installer-name": "d3" + }, + "dist": { + "url": "https://github.com/d3/d3/archive/v3.5.17.zip", + "type": "zip" + }, + "require": { + "composer/installers": "~1.0" + } + } + } + +4. Run "composer require --prefer-dist c3js/c3:0.4.18 d3/d3:3.5.17" - you should find that new directories have been created +under "/libraries" diff --git a/modules/charts_c3/charts_c3.libraries.yml b/modules/charts_c3/charts_c3.libraries.yml index f9bbac24958a82e5dc1866fbdb2462b12d88fffc..cc5cad47907781d2d682fb87d74a5469cbd03bec 100644 --- a/modules/charts_c3/charts_c3.libraries.yml +++ b/modules/charts_c3/charts_c3.libraries.yml @@ -14,19 +14,19 @@ d3: url: 'https://en.wikipedia.org/wiki/BSD_licenses' gpl-compatible: false js: - vendor/dthree/d3.v3.min.js: { } + /libraries/d3/d3.min.js: { } c3: - remote: 'https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.js' - version: 0.4.11 + remote: 'https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.18/c3.min.js' + version: 0.4.18 license: name: MIT url: 'https://opensource.org/licenses/MIT' gpl-compatible: true css: theme: - vendor/cthree/css/c3.min.css: { } + /libraries/c3/c3.min.css: { } js: - vendor/cthree/c3.min.js: { } + /libraries/c3/c3.min.js: { } dependencies: - charts_c3/charts_c3 - charts_c3/d3 diff --git a/modules/charts_c3/composer.json b/modules/charts_c3/composer.json deleted file mode 100644 index b7068fb2d42e1412fe9b6480c2e61b2714ce33c8..0000000000000000000000000000000000000000 --- a/modules/charts_c3/composer.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "charts_cthree", - "version": "0.0.1", - "require": { - "dthree": "*", - "cthree": "*", - "cthree/css": "*" - }, - "repositories": [ - { - "type": "package", - "package": { - "name": "dthree", - "version": "3", - "type": "dthree", - "dist": { - "url": "https://d3js.org/d3.v3.min.js", - "type": "file" - } - } - }, - { - "type": "package", - "package": { - "name": "cthree", - "version": "0.4.11", - "type": "cthree", - "dist": { - "url": "https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.js", - "type": "file" - } - } - }, - { - "type": "package", - "package": { - "name": "cthree/css", - "version": "0.4.11", - "type": "css", - "dist": { - "url": "https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.css", - "type": "file" - } - } - } - ], - "extra": { - "assets": { - "packages": { - "dthree": "*", - "cthree": "*", - "cthree/css": "*" - } - } - } -} diff --git a/modules/charts_c3/src/Charts/C3ChartsRender.php b/modules/charts_c3/src/Charts/C3ChartsRender.php index 062a4348e82961306ef437a737cff5f2bbf84c40..786291bf53f341653c060a76e4332ad53a9c77e1 100644 --- a/modules/charts_c3/src/Charts/C3ChartsRender.php +++ b/modules/charts_c3/src/Charts/C3ChartsRender.php @@ -20,7 +20,7 @@ class C3ChartsRender implements ChartsRenderInterface { * Construct. */ public function __construct() { - Util::checkMissingLibrary('charts_c3', '/vendor/cthree/c3.min.js'); + Util::checkMissingLibrary('libraries/c3/c3.min.js'); } /** diff --git a/modules/charts_google/.gitignore b/modules/charts_google/.gitignore deleted file mode 100644 index 4f4acd356ffd7eabb0eec871e7edb678ffe6f6b0..0000000000000000000000000000000000000000 --- a/modules/charts_google/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -vendor/ -composer.lock \ No newline at end of file diff --git a/modules/charts_google/README.txt b/modules/charts_google/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..7479349b9917b79a15a6cda486a93ada98223d71 --- /dev/null +++ b/modules/charts_google/README.txt @@ -0,0 +1,37 @@ +Installation using Composer (recommended) +======================================== + +If you use Composer to manage dependencies, edit "/composer.json" as follows. + + 1. Run "composer require --prefer-dist composer/installers" to ensure that you + have the "composer/installers" package installed. This package facilitates + the installation of packages into directories other than "/vendor" (e.g. + "/libraries") using Composer. + + 2. Add the following to the "installer-paths" section of "composer.json": + +"libraries/{$name}": ["type:drupal-library"], + + 3. Add the following to the "repositories" section of "composer.json": + + { + "type": "package", + "package": { + "name": "google/charts", + "version": "45", + "type": "drupal-library", + "extra": { + "installer-name": "google_charts" + }, + "dist": { + "url": "https://www.gstatic.com/charts/loader.js", + "type": "file" + }, + "require": { + "composer/installers": "~1.0" + } + } + } + +4. Run "composer require --prefer-dist google/charts:45" - you should find that new directories have been created +under "/libraries" diff --git a/modules/charts_google/charts_google.libraries.yml b/modules/charts_google/charts_google.libraries.yml index 86412618120aafe3a1927702c6414f03ed3b3202..0a340c799d376d9913acbcf38483d54e6b2cb073 100644 --- a/modules/charts_google/charts_google.libraries.yml +++ b/modules/charts_google/charts_google.libraries.yml @@ -14,6 +14,6 @@ google: url: 'http://www.apache.org/licenses/LICENSE-2.0' gpl-compatible: false js: - vendor/google/loader.js: { } + /libraries/google_charts/loader.js: { } dependencies: - charts_google/charts_google diff --git a/modules/charts_google/composer.json b/modules/charts_google/composer.json deleted file mode 100644 index 1f1934c4f2242ea3ad77999ca72de6925fbf6a73..0000000000000000000000000000000000000000 --- a/modules/charts_google/composer.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "charts_google", - "version": "0.0.1", - "require": { - "google": "*" - }, - "repositories": [ - { - "type": "package", - "package": { - "name": "google", - "version": "45", - "type": "google", - "dist": { - "url": "https://www.gstatic.com/charts/loader.js", - "type": "file" - } - } - } - ], - "extra": { - "assets": { - "actions": [ - { - "type": "copy", - "target": "js", - "pattern": "\\.js$" - } - ], - "packages": { - "google": "*" - } - } - } -} diff --git a/modules/charts_google/src/Charts/GoogleChartsRender.php b/modules/charts_google/src/Charts/GoogleChartsRender.php index 7e1022296486900a9fbd9ee6c2705248f84abfbd..9bdb63489a98794a0313e8ee7a8b001732492cda 100644 --- a/modules/charts_google/src/Charts/GoogleChartsRender.php +++ b/modules/charts_google/src/Charts/GoogleChartsRender.php @@ -18,7 +18,7 @@ class GoogleChartsRender implements ChartsRenderInterface { * Construct. */ public function __construct() { - Util::checkMissingLibrary('charts_google', '/vendor/google/loader.js'); + Util::checkMissingLibrary('libraries/google_charts/loader.js'); } /** diff --git a/modules/charts_highcharts/.gitignore b/modules/charts_highcharts/.gitignore deleted file mode 100644 index 4f4acd356ffd7eabb0eec871e7edb678ffe6f6b0..0000000000000000000000000000000000000000 --- a/modules/charts_highcharts/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -vendor/ -composer.lock \ No newline at end of file diff --git a/modules/charts_highcharts/README.txt b/modules/charts_highcharts/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..fb3facb636c8ac6409b9702e2a06575e83dd100c --- /dev/null +++ b/modules/charts_highcharts/README.txt @@ -0,0 +1,91 @@ +Installation using Composer (recommended) +======================================== + +If you use Composer to manage dependencies, edit "/composer.json" as follows. + + 1. Run "composer require --prefer-dist composer/installers" to ensure that you + have the "composer/installers" package installed. This package facilitates + the installation of packages into directories other than "/vendor" (e.g. + "/libraries") using Composer. + + 2. Add the following to the "installer-paths" section of "composer.json": + +"libraries/{$name}": ["type:drupal-library"], + + 3. Add the following to the "repositories" section of "composer.json": + + { + "type": "package", + "package": { + "name": "highcharts/highcharts", + "version": "6.0.4", + "type": "drupal-library", + "extra": { + "installer-name": "highcharts" + }, + "dist": { + "url": "https://code.highcharts.com/6.0.4/highcharts.js", + "type": "file" + }, + "require": { + "composer/installers": "~1.0" + } + } + }, + { + "type": "package", + "package": { + "name": "highcharts/exporting", + "version": "6.0.4", + "type": "drupal-library", + "extra": { + "installer-name": "highcharts_exporting" + }, + "dist": { + "url": "https://code.highcharts.com/6.0.4/modules/exporting.js", + "type": "file" + }, + "require": { + "composer/installers": "~1.0" + } + } + }, + { + "type": "package", + "package": { + "name": "highcharts/export-data", + "version": "6.0.4", + "type": "drupal-library", + "extra": { + "installer-name": "highcharts_export-data" + }, + "dist": { + "url": "https://code.highcharts.com/6.0.4/modules/export-data.js", + "type": "file" + }, + "require": { + "composer/installers": "~1.0" + } + } + }, + { + "type": "package", + "package": { + "name": "highcharts/accessibility", + "version": "6.0.4", + "type": "drupal-library", + "extra": { + "installer-name": "highcharts_accessibility" + }, + "dist": { + "url": "https://code.highcharts.com/6.0.4/modules/accessibility.js", + "type": "file" + }, + "require": { + "composer/installers": "~1.0" + } + } + } + +4. Run "composer require --prefer-dist highcharts/highcharts:6.0.4 highcharts/exporting:6.0.4 highcharts/export-data:6.0.4 highcharts/accessibility:6.0.4" - you should find that new directories have been created +under "/libraries" diff --git a/modules/charts_highcharts/charts_highcharts.libraries.yml b/modules/charts_highcharts/charts_highcharts.libraries.yml index 841a7b987c4ee0f8ff21b60d015b5e0d25ae578e..64e4f470033b5b5cc15e7b468300cb21305e80ff 100644 --- a/modules/charts_highcharts/charts_highcharts.libraries.yml +++ b/modules/charts_highcharts/charts_highcharts.libraries.yml @@ -15,10 +15,9 @@ highcharts: url: https://creativecommons.org/licenses/by-nc/3.0/ gpl-compatible: false js: - vendor/highcharts/highcharts.js: {} - vendor/exporting/exporting.js: {} - vendor/export-data/export-data.js: {} - vendor/accessibility/accessibility.js: {} - + /libraries/highcharts/highcharts.js: {} + /libraries/highcharts_exporting/exporting.js: {} + /libraries/highcharts_export-data/export-data.js: {} + /libraries/highcharts_accessibility/accessibility.js: {} dependencies: - charts_highcharts/charts_highcharts diff --git a/modules/charts_highcharts/composer.json b/modules/charts_highcharts/composer.json deleted file mode 100644 index 45fb1d189a13315bae83ef866e9e308c16085f36..0000000000000000000000000000000000000000 --- a/modules/charts_highcharts/composer.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "charts_highcharts", - "version": "0.0.1", - "require": { - "highcharts": "*", - "exporting": "*", - "export-data": "*", - "accessibility": "*" - }, - "repositories": [ - { - "type": "package", - "package": { - "name": "highcharts", - "version": "5.0.7", - "type": "highcharts", - "dist": { - "url": "https://code.highcharts.com/highcharts.js", - "type": "file" - } - } - }, - { - "type": "package", - "package": { - "name": "exporting", - "version": "5.0.7", - "type": "highcharts", - "dist": { - "url": "https://code.highcharts.com/modules/exporting.js", - "type": "file" - } - } - }, - { - "type": "package", - "package": { - "name": "export-data", - "version": "5.0.7", - "type": "highcharts", - "dist": { - "url": "https://code.highcharts.com/modules/export-data.js", - "type": "file" - } - } - }, - { - "type": "package", - "package": { - "name": "accessibility", - "version": "5.0.7", - "type": "highcharts", - "dist": { - "url": "https://code.highcharts.com/modules/accessibility.js", - "type": "file" - } - } - } - ], - "extra": { - "assets": { - "actions": [ - { - "type": "copy", - "target": "js", - "pattern": "\\.js$" - } - ], - "packages": { - "highcharts": "*" - } - } - } -} diff --git a/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php b/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php index d6f848a07b0d34965f1664dd4a6a43cf6d0f08c5..22e76ee539ecdf3d883a4756986d6056960ca4a8 100644 --- a/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php +++ b/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php @@ -29,7 +29,10 @@ class HighchartsChartsRender implements ChartsRenderInterface { * Construct. */ public function __construct() { - Util::checkMissingLibrary('charts_highcharts', '/vendor/highcharts/highcharts.js'); + Util::checkMissingLibrary('libraries/highcharts/highcharts.js'); + Util::checkMissingLibrary('libraries/highcharts_accessibility/accessibility.js'); + Util::checkMissingLibrary('libraries/highcharts_export-data/export-data.js'); + Util::checkMissingLibrary('libraries/highcharts_exporting/exporting.js'); } /** diff --git a/src/Charts/ModuleSelector.php b/src/Charts/ModuleSelector.php index a677e7c50dc23fa0e927f094a9345a1d0d52abaa..32fd56eabc2221a683c3e9c3fd00a1af193c6ed7 100644 --- a/src/Charts/ModuleSelector.php +++ b/src/Charts/ModuleSelector.php @@ -8,7 +8,6 @@ namespace Drupal\charts\Charts; class ModuleSelector { private $library; - private $assetLocation = '/vendor/'; private $assetName; private $categories; private $seriesData; diff --git a/src/Util/Util.php b/src/Util/Util.php index 7ea0c5b1cf167ad623506bba2e86bd3e8bd3621e..450d890a67f9620c20d08921f9501b8620001fd3 100644 --- a/src/Util/Util.php +++ b/src/Util/Util.php @@ -106,16 +106,14 @@ class Util { /** * Checks for missing libraries necessary for data visualization. * - * @param string $moduleName - * Module name. * @param string $libraryPath * Library Path. */ - public static function checkMissingLibrary($moduleName = '', $libraryPath = '') { - $module_path = drupal_get_path('module', $moduleName); - if (!file_exists($module_path . $libraryPath)) { - $text = 'Charting libraries for ' . $moduleName . ' might not be installed. Run \'composer install\' for ' . $moduleName . ' sub-module.'; - drupal_set_message(t($text), 'error'); + public static function checkMissingLibrary($libraryPath = '') { + if (!file_exists(DRUPAL_ROOT . DIRECTORY_SEPARATOR . $libraryPath)) { + drupal_set_message(t('Charting libraries might not be installed at the location @libraryPath.', [ + '@libraryPath' => $libraryPath, + ]), 'error'); } }