Skip to content
Snippets Groups Projects
Commit e1d1f832 authored by Daniel Cothran's avatar Daniel Cothran
Browse files

Issue #2879533 by lbaran: Improve Charts code documentation

parent 6824cdd4
No related branches found
No related tags found
No related merge requests found
Showing
with 159 additions and 139 deletions
...@@ -50,15 +50,15 @@ use Drupal\charts\Theme\ChartsInterface; ...@@ -50,15 +50,15 @@ use Drupal\charts\Theme\ChartsInterface;
* chart_data, chart_xaxis, and chart_yaxis). For a full list, see the * chart_data, chart_xaxis, and chart_yaxis). For a full list, see the
* charts_element_info() function. * charts_element_info() function.
* *
*
* @see charts_element_info() * @see charts_element_info()
* */
*
/**
* Alter an individual chart before it is printed. * Alter an individual chart before it is printed.
* *
* @param $chart * @param array $chart
* The chart renderable. Passed in by reference. * The chart renderable. Passed in by reference.
* @param $chart_id * @param string $chart_id
* The chart identifier, pulled from the $chart['#chart_id'] property (if * The chart identifier, pulled from the $chart['#chart_id'] property (if
* any). Not all charts have a chart identifier. * any). Not all charts have a chart identifier.
*/ */
...@@ -76,9 +76,12 @@ function hook_chart_alter(&$chart, $chart_id) { ...@@ -76,9 +76,12 @@ function hook_chart_alter(&$chart, $chart_id) {
* name instead of being passed in as an argument. * name instead of being passed in as an argument.
* *
* @see hook_chart_alter() * @see hook_chart_alter()
* @param $chart *
* @param array $chart
* Chart.
*/ */
function hook_chart_CHART_ID_alter(&$chart) { function hook_chart_CHART_ID_alter(&$chart) {
} }
/** /**
...@@ -93,13 +96,14 @@ function hook_chart_CHART_ID_alter(&$chart) { ...@@ -93,13 +96,14 @@ function hook_chart_CHART_ID_alter(&$chart) {
* Even though this hook may be fragile, it may provide developers with access * Even though this hook may be fragile, it may provide developers with access
* to library-specific functionality. * to library-specific functionality.
* *
* @param $definition * @param array $definition
* The chart definition to be modified. The raw values are passed directly to * The chart definition to be modified. The raw values are passed directly to
* the charting library. * the charting library.
* @param $chart * @param array $chart
* The chart renderable. This may be used for reference (or read to add * The chart renderable. This may be used for reference (or read to add
* support for new properties), but any changes to this variable will not * support for new properties), but any changes to this variable will not
* have an effect on output. * have an effect on output.
*
* @internal param $chart_id The chart ID, derived from the $chart['#chart_id'] property. Note that not* The chart ID, derived from the $chart['#chart_id'] property. Note that not * @internal param $chart_id The chart ID, derived from the $chart['#chart_id'] property. Note that not* The chart ID, derived from the $chart['#chart_id'] property. Note that not
* all charts may have a $chart_id. * all charts may have a $chart_id.
*/ */
...@@ -111,8 +115,10 @@ function hook_chart_definition_alter(&$definition, $chart) { ...@@ -111,8 +115,10 @@ function hook_chart_definition_alter(&$definition, $chart) {
* *
* Same as hook_chart_definition_alter(), only including the $chart_id in the * Same as hook_chart_definition_alter(), only including the $chart_id in the
* function name instead of being passed in as an argument. * function name instead of being passed in as an argument.
* @see hook_chart_definition_alter() * @see hook_chart_definition_alter().
* @param $chart *
* @param array $chart
* Chart.
*/ */
function hook_chart_definition_CHART_ID_alter(&$chart) { function hook_chart_definition_CHART_ID_alter(&$chart) {
} }
...@@ -143,7 +149,9 @@ function hook_charts_info() { ...@@ -143,7 +149,9 @@ function hook_charts_info() {
* *
* If your module needs to modify the capabilities of a charting library, such * If your module needs to modify the capabilities of a charting library, such
* as to add support for a new chart type, it may do so with this hook. * as to add support for a new chart type, it may do so with this hook.
* @param $info *
* @param array $info
* Info.
*/ */
function hook_charts_info_alter(&$info) { function hook_charts_info_alter(&$info) {
// Say the Google charts library supports geo charts. // Say the Google charts library supports geo charts.
...@@ -167,7 +175,8 @@ function hook_charts_type_info() { ...@@ -167,7 +175,8 @@ function hook_charts_type_info() {
// Many charting libraries always refer to the main axis as the "y-axis", // Many charting libraries always refer to the main axis as the "y-axis",
// even if the chart's main axis is horizontal. An example of this is a // even if the chart's main axis is horizontal. An example of this is a
// bar chart, where the values are along the horizontal axis. // bar chart, where the values are along the horizontal axis.
'axis_inverted' => TRUE, // Meaning x/y axis are flipped. // Meaning x/y axis are flipped.
'axis_inverted' => TRUE,
// For bar/area/other charts that support stacking of series, set this value // For bar/area/other charts that support stacking of series, set this value
// to TRUE. // to TRUE.
'stacking' => TRUE, 'stacking' => TRUE,
...@@ -180,7 +189,9 @@ function hook_charts_type_info() { ...@@ -180,7 +189,9 @@ function hook_charts_type_info() {
* *
* If your module needs to modify the capabilities or labels of a paricular * If your module needs to modify the capabilities or labels of a paricular
* chart type, it may alter the definitions provided by other modules. * chart type, it may alter the definitions provided by other modules.
* @param $chart_types *
* @param array $chart_types
* Chart Types.
*/ */
function hook_charts_type_info_alter(&$chart_types) { function hook_charts_type_info_alter(&$chart_types) {
$chart_types['bar']['stacking'] = FALSE; $chart_types['bar']['stacking'] = FALSE;
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
/** /**
* @file * @file
* Charts module file that provides hook_theme. * Charts - Module.
*/ */
use Drupal\charts\Util\Util; use Drupal\charts\Util\Util;
use Drupal\charts\Charts\ModuleSelector; use Drupal\charts\Charts\ModuleSelector;
/** /**
* {@inheritdoc} * Implements hook_theme().
*/ */
function charts_theme($existing, $type, $theme, $path) { function charts_theme($existing, $type, $theme, $path) {
...@@ -17,14 +17,14 @@ function charts_theme($existing, $type, $theme, $path) { ...@@ -17,14 +17,14 @@ function charts_theme($existing, $type, $theme, $path) {
'views_view_charts' => [ 'views_view_charts' => [
'variables' => [ 'variables' => [
'view' => NULL, 'view' => NULL,
'row' => NULL, 'row' => NULL,
], ],
], ],
]; ];
} }
/** /**
* {@inheritdoc} * Implements template_preprocess_views_view_charts().
*/ */
function template_preprocess_views_view_charts(&$variables) { function template_preprocess_views_view_charts(&$variables) {
...@@ -91,6 +91,9 @@ function template_preprocess_views_view_charts(&$variables) { ...@@ -91,6 +91,9 @@ function template_preprocess_views_view_charts(&$variables) {
$attachmentDisplayOptions[$i]['inherit_yaxis'] = $view->displayHandlers->get($attachmentId)->options['inherit_yaxis']; $attachmentDisplayOptions[$i]['inherit_yaxis'] = $view->displayHandlers->get($attachmentId)->options['inherit_yaxis'];
} }
$seriesData = array_merge($seriesData, $seriesDataAttachment); $seriesData = array_merge($seriesData, $seriesDataAttachment);
$moduleSelector = new ModuleSelector($library, $categories, $seriesData, $options, $attachmentDisplayOptions, $variables, $chartId); $moduleSelector = new ModuleSelector($library, $categories, $seriesData, $options, $attachmentDisplayOptions, $chartId);
if ($moduleSelector->moduleExists()) {
$moduleSelector->buildVariables($variables);
}
} }
# In charts.permissions.yml file. 'access all charts':
access all charts:
title: 'Administer Charts' title: 'Administer Charts'
description: 'This permission needs to be fleshed out.' description: 'This permission needs to be fleshed out.'
restrict access: TRUE 'restrict access': true
charts.settings: charts.settings:
path: '/admin/config/content/charts' path: /admin/config/content/charts
defaults: defaults:
_form: 'Drupal\charts\Form\ChartsConfigForm' _form: Drupal\charts\Form\ChartsConfigForm
_title: 'Default chart configuration' _title: 'Default chart configuration'
requirements: requirements:
_permission: 'administer site configuration' _permission: 'administer site configuration'
services: services:
charts.charts_service: charts.charts_service:
class: Drupal\charts\Services\ChartService class: Drupal\charts\Services\ChartService
charts.charts_attachment: charts.charts_attachment:
class: Drupal\charts\Services\ChartAttachmentService class: Drupal\charts\Services\ChartAttachmentService
charts.views_variable: charts.views_variable:
class: Drupal\charts\Services\ViewsDataService class: Drupal\charts\Services\ViewsDataService
charts.settings: charts.settings:
class: Drupal\charts\Services\ChartsSettingsService class: Drupal\charts\Services\ChartsSettingsService
arguments: ['@config.factory'] arguments: ['@config.factory']
...@@ -244,7 +244,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren ...@@ -244,7 +244,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren
// Set data attributes to identify special properties of different types. // Set data attributes to identify special properties of different types.
foreach ($chart_types as $chart_type => $chart_type_info) { foreach ($chart_types as $chart_type => $chart_type_info) {
if ($chart_type_info['axis_inverted']) { if (isset($chart_type_info['axis_inverted']) && $chart_type_info['axis_inverted']) {
$form['type'][$chart_type]['#attributes']['data-axis-inverted'] = TRUE; $form['type'][$chart_type]['#attributes']['data-axis-inverted'] = TRUE;
} }
if ($chart_type_info['axis'] === ChartsInterface::CHARTS_SINGLE_AXIS) { if ($chart_type_info['axis'] === ChartsInterface::CHARTS_SINGLE_AXIS) {
...@@ -256,7 +256,6 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren ...@@ -256,7 +256,6 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren
$first_field = key($field_options); $first_field = key($field_options);
// $form['#theme'] = 'charts_settings_fields'; // $form['#theme'] = 'charts_settings_fields';
$form['fields'] = [ $form['fields'] = [
'#title' => t('Charts fields'), '#title' => t('Charts fields'),
'#type' => 'fieldset', '#type' => 'fieldset',
...@@ -602,34 +601,34 @@ function charts_default_settings_form_submit($form, $form_state) { ...@@ -602,34 +601,34 @@ function charts_default_settings_form_submit($form, $form_state) {
* Provides default options used by charts_settings_form(). * Provides default options used by charts_settings_form().
*/ */
function charts_default_settings() { function charts_default_settings() {
$defaults = []; $defaults = [
$defaults['type'] = 'pie'; 'type' => 'pie',
$defaults['library'] = NULL; 'library' => NULL,
$defaults['label_field'] = NULL; 'label_field' => NULL,
$defaults['data_fields'] = NULL; 'data_fields' => NULL,
$defaults['field_colors'] = NULL; 'field_colors' => NULL,
$defaults['title'] = ''; 'title' => '',
$defaults['title_position'] = 'out'; 'title_position' => 'out',
$defaults['data_labels'] = FALSE; 'data_labels' => FALSE,
$defaults['legend'] = TRUE; 'legend' => TRUE,
$defaults['legend_position'] = 'right'; 'legend_position' => 'right',
$defaults['colors'] = charts_default_colors(); 'colors' => charts_default_colors(),
$defaults['background'] = ''; 'background' => '',
$defaults['tooltips'] = TRUE; 'tooltips' => TRUE,
$defaults['tooltips_use_html'] = FALSE; 'tooltips_use_html' => FALSE,
$defaults['width'] = NULL; 'width' => NULL,
$defaults['height'] = NULL; 'height' => NULL,
$defaults['xaxis_title'] = ''; 'xaxis_title' => '',
$defaults['xaxis_labels_rotation'] = 0; 'xaxis_labels_rotation' => 0,
$defaults['yaxis_title'] = ''; 'yaxis_title' => '',
$defaults['yaxis_min'] = ''; 'yaxis_min' => '',
$defaults['yaxis_max'] = ''; 'yaxis_max' => '',
$defaults['yaxis_prefix'] = ''; 'yaxis_prefix' => '',
$defaults['yaxis_suffix'] = ''; 'yaxis_suffix' => '',
$defaults['yaxis_decimal_count'] = ''; 'yaxis_decimal_count' => '',
$defaults['yaxis_labels_rotation'] = 0; 'yaxis_labels_rotation' => 0,
];
Drupal::moduleHandler()->alter('charts_default_settings', $defaults); Drupal::moduleHandler()->alter('charts_default_settings', $defaults);
return $defaults; return $defaults;
} }
...@@ -5,4 +5,4 @@ To see the example, navigate to: ...@@ -5,4 +5,4 @@ To see the example, navigate to:
Settings for this chart derive from the Charts module's Settings for this chart derive from the Charts module's
default settings, which are configured here: default settings, which are configured here:
/admin/config/content/charts /admin/config/content/charts
\ No newline at end of file
name: Charts API Example name: 'Charts API Example'
type: module type: module
description: Demonstrates how to use the Charts module without Views. description: 'Demonstrates how to use the Charts module without Views.'
core: 8.x core: 8.x
package: Examples package: Examples
dependencies: dependencies:
- charts:charts - 'charts:charts'
charts_api_examples:
version: 1.x
js:
js/charts_api_example.js: {}
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Contains charts_api_example.module. * Charts Api Example - Module.
*/ */
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
...@@ -12,41 +12,40 @@ use Drupal\charts\Charts\ModuleSelector; ...@@ -12,41 +12,40 @@ use Drupal\charts\Charts\ModuleSelector;
* Implements hook_help(). * Implements hook_help().
*/ */
function charts_api_example_help($route_name, RouteMatchInterface $route_match) { function charts_api_example_help($route_name, RouteMatchInterface $route_match) {
$output = '';
switch ($route_name) { switch ($route_name) {
// Main module help for the charts_api_example module. // Main module help for the charts_api_example module.
case 'help.page.charts_api_example': case 'help.page.charts_api_example':
$output = '';
$output .= '<h3>' . t('About') . '</h3>'; $output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('A simple example on how to interact with the Charts API') . '</p>'; $output .= '<p>' . t('A simple example on how to interact with the Charts API') . '</p>';
return $output; break;
default:
} }
return $output;
} }
/** /**
* Implements hook_theme(). * Implements hook_theme().
*/ */
function charts_api_example_theme() { function charts_api_example_theme() {
$vars = [
'library' => '',
'categories' => '',
'seriesData' => '',
'options' => '',
];
return [ return [
'charts_api_example' => [ 'charts_api_example' => [
'template' => 'charts_api_example', 'template' => 'charts_api_example',
'variables' => $vars, 'variables' => [
'library' => '',
'categories' => [],
'seriesData' => [],
'options' => [],
],
], ],
]; ];
} }
/** /**
* Implements template_preprocess_page * Implements template_preprocess_charts_api_example().
*
* @param $variables
*/ */
function template_preprocess_charts_api_example(&$variables) { function template_preprocess_charts_api_example(&$variables) {
$moduleSelector = new ModuleSelector($variables['library'], $variables['categories'], $variables['seriesData'], $variables['options'], [], $variables, 'xyz'); $moduleSelector = new ModuleSelector($variables['library'], $variables['categories'], $variables['seriesData'], $variables['options'], [], 'xyz');
} if ($moduleSelector->moduleExists()) {
\ No newline at end of file $moduleSelector->buildVariables($variables);
}
}
charts_api_example.display: charts_api_example.display:
path: '/charts/example/display' path: /charts/example/display
defaults: defaults:
_controller: '\Drupal\charts_api_example\Controller\ChartsApiExample::display' _controller: '\Drupal\charts_api_example\Controller\ChartsApiExample::display'
_title: 'How to use the Charts API' _title: 'How to use the Charts API'
......
...@@ -47,20 +47,35 @@ class ChartsApiExample extends ControllerBase implements ContainerInjectionInter ...@@ -47,20 +47,35 @@ class ChartsApiExample extends ControllerBase implements ContainerInjectionInter
]; ];
// Sample data format. // Sample data format.
$categories = ["Category 1", "Category 2", "Category 3", "Category 4"]; $categories = ['Category 1', 'Category 2', 'Category 3', 'Category 4'];
$seriesData = [ $seriesData = [
["name" => "Series 1", "color" => "#0d233a", "type" => null, "data" => [250, 350, 400, 200]], [
["name" => "Series 2", "color" => "#8bbc21", "type" => "column", "data" => [150, 450, 500, 300]], 'name' => 'Series 1',
["name" => "Series 3", "color" => "#910000", "type" => "area", "data" => [0, 0, 60, 90]] 'color' => '#0d233a',
'type' => NULL,
'data' => [250, 350, 400, 200],
], [
'name' => 'Series 2',
'color' => '#8bbc21',
'type' => 'column',
'data' => [150, 450, 500, 300],
], [
'name' => 'Series 3',
'color' => '#910000',
'type' => 'area',
'data' => [0, 0, 60, 90],
],
]; ];
return [ $build = [
'#theme' => 'charts_api_example', '#theme' => 'charts_api_example',
'#library' => (string) $library, '#library' => (string) $library,
'#categories' => $categories, '#categories' => $categories,
'#seriesData' => $seriesData, '#seriesData' => $seriesData,
'#options' => $options, '#options' => $options,
]; ];
return $build;
} }
/** /**
...@@ -71,4 +86,5 @@ class ChartsApiExample extends ControllerBase implements ContainerInjectionInter ...@@ -71,4 +86,5 @@ class ChartsApiExample extends ControllerBase implements ContainerInjectionInter
$container->get('charts.settings') $container->get('charts.settings')
); );
} }
}
\ No newline at end of file }
{% set library = 'charts_' ~ chart_type ~ '/' ~ chart_type %} {% set library = 'charts_' ~ chart_type ~ '/' ~ chart_type %}
{{ attach_library("#{ library }") }} {{ attach_library("#{ library }") }}
<p>Edit charts_api_example.html.twig to delete this message. To change the <p>Edit charts_api_example.html.twig to delete this message. To change the
library used by this file, change the <a href="/admin/config/content/charts"> library used by this file, change the <a href="{{ url('charts.settings',{}) }}">default settings</a>.
default settings </p>
</a>.</p>
<div {{ attributes }} {{ content_attributes }} style="width:100%; height:400px;"></div> <div {{ attributes }} {{ content_attributes }} style="width:100%; height:400px;"></div>
name: C3 Charts name: 'C3 Charts'
type: module type: module
description: 'Charts module integration with C3 Charts.' description: 'Charts module integration with C3 Charts.'
package: Charts package: Charts
core: 8.x core: 8.x
dependencies: dependencies:
- charts:charts - 'charts:charts'
charts_c3: charts_c3:
version: 1.x version: 1.x
js: js:
js/charts_c3.js: {} js/charts_c3.js: { }
dependencies: dependencies:
- core/jquery - core/jquery
- core/jquery.once - core/jquery.once
- core/drupal - core/drupal
d3: d3:
remote: https://d3js.org/d3.v3.min.js remote: 'https://d3js.org/d3.v3.min.js'
version: 3 version: 3
license: license:
name: BSD name: BSD
url: https://en.wikipedia.org/wiki/BSD_licenses url: 'https://en.wikipedia.org/wiki/BSD_licenses'
gpl-compatible: false gpl-compatible: false
js: js:
vendor/dthree/d3.v3.min.js: {} vendor/dthree/d3.v3.min.js: { }
c3: c3:
remote: https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.js remote: 'https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.js'
version: 0.4.11 version: 0.4.11
license: license:
name: MIT name: MIT
url: https://opensource.org/licenses/MIT url: 'https://opensource.org/licenses/MIT'
gpl-compatible: true gpl-compatible: true
css: css:
theme: theme:
vendor/cthree/css/c3.min.css: {} vendor/cthree/css/c3.min.css: { }
js: js:
vendor/cthree/c3.min.js: {} vendor/cthree/c3.min.js: { }
dependencies: dependencies:
- charts_c3/charts_c3 - charts_c3/charts_c3
- charts_c3/d3 - charts_c3/d3
\ No newline at end of file
...@@ -11,31 +11,33 @@ use Drupal\charts_c3\Settings\CThree\ChartData; ...@@ -11,31 +11,33 @@ use Drupal\charts_c3\Settings\CThree\ChartData;
use Drupal\charts_c3\Settings\CThree\ChartColor; use Drupal\charts_c3\Settings\CThree\ChartColor;
use Drupal\charts_c3\Settings\CThree\ChartAxis; use Drupal\charts_c3\Settings\CThree\ChartAxis;
/**
* C3 Charts Render.
*/
class C3ChartsRender implements ChartsRenderInterface { class C3ChartsRender implements ChartsRenderInterface {
/**
* Construct.
*/
public function __construct() { public function __construct() {
Util::checkMissingLibrary('charts_c3', '/vendor/cthree/c3.min.js'); Util::checkMissingLibrary('charts_c3', '/vendor/cthree/c3.min.js');
} }
/** /**
* @param $options * {@inheritdoc}
* @param array $categories
* @param array $seriesData
* @param $chartId
* @param array $attachmentDisplayOptions
*
* @return CThree
*/ */
public function charts_render_charts($options, $categories = [], $seriesData = [], $attachmentDisplayOptions = [], &$variables, $chartId) { public function chartsRenderCharts(array $options = [], array $categories = [], array $seriesData = [], array $attachmentDisplayOptions = [],array &$variables = [], $chartId = '') {
$noAttachmentDisplays = count($attachmentDisplayOptions) === 0; $noAttachmentDisplays = count($attachmentDisplayOptions) === 0;
$types = []; $types = [];
// @todo - make this work for more that one attachment. // @todo - make this work for more that one attachment.
for ($i = 1; $i <= count($attachmentDisplayOptions); $i++) { for ($i = 1; $i <= count($attachmentDisplayOptions); $i++) {
if ($attachmentDisplayOptions[$i - 1]['style']['options']['type'] == 'column') if ($attachmentDisplayOptions[$i - 1]['style']['options']['type'] == 'column') {
$types[$seriesData[$i]['name']] = 'bar'; $types[$seriesData[$i]['name']] = 'bar';
else }
else {
$types[$seriesData[$i]['name']] = $attachmentDisplayOptions[$i - 1]['style']['options']['type']; $types[$seriesData[$i]['name']] = $attachmentDisplayOptions[$i - 1]['style']['options']['type'];
}
} }
$c3Data = []; $c3Data = [];
for ($i = 0; $i < count($seriesData); $i++) { for ($i = 0; $i < count($seriesData); $i++) {
...@@ -61,14 +63,14 @@ class C3ChartsRender implements ChartsRenderInterface { ...@@ -61,14 +63,14 @@ class C3ChartsRender implements ChartsRenderInterface {
// Sets the primary y axis. // Sets the primary y axis.
$yAxis = []; $yAxis = [];
$yAxis[$seriesData[0]['name']] = 'y'; $yAxis[$seriesData[0]['name']] = 'y';
$showAxis['show'] = true; $showAxis['show'] = TRUE;
$showAxis['label'] = $options['yaxis_title']; $showAxis['label'] = $options['yaxis_title'];
$chartAxis->y = $showAxis; $chartAxis->y = $showAxis;
// Sets secondary axis from the first attachment only. // Sets secondary axis from the first attachment only.
if (!$noAttachmentDisplays && $attachmentDisplayOptions[0]['inherit_yaxis'] == 0) { if (!$noAttachmentDisplays && $attachmentDisplayOptions[0]['inherit_yaxis'] == 0) {
$yAxis[$seriesData[1]['name']] = 'y2'; $yAxis[$seriesData[1]['name']] = 'y2';
$showSecAxis['show'] = true; $showSecAxis['show'] = TRUE;
$showSecAxis['label'] = $attachmentDisplayOptions[0]['style']['options']['yaxis_title']; $showSecAxis['label'] = $attachmentDisplayOptions[0]['style']['options']['yaxis_title'];
$chartAxis->y2 = $showSecAxis; $chartAxis->y2 = $showSecAxis;
} }
...@@ -117,4 +119,5 @@ class C3ChartsRender implements ChartsRenderInterface { ...@@ -117,4 +119,5 @@ class C3ChartsRender implements ChartsRenderInterface {
$variables['attributes']['id'][0] = $chartId; $variables['attributes']['id'][0] = $chartId;
$variables['attributes']['class'][] = 'charts-c3'; $variables['attributes']['class'][] = 'charts-c3';
} }
} }
name: Google Charts name: 'Google Charts'
type: module type: module
description: 'Charts module integration with Google Charts.' description: 'Charts module integration with Google Charts.'
package: Charts package: Charts
core: 8.x core: 8.x
dependencies: dependencies:
- charts:charts - 'charts:charts'
charts_google: charts_google:
version: 1.x version: 1.x
js: js:
js/charts_google.js: {} js/charts_google.js: { }
dependencies: dependencies:
- core/jquery - core/jquery
- core/jquery.once - core/jquery.once
- core/drupal - core/drupal
google: google:
remote: https://www.gstatic.com/charts/loader.js remote: 'https://www.gstatic.com/charts/loader.js'
version: VERSION version: VERSION
license: license:
name: Apache 2.0 name: 'Apache 2.0'
url: http://www.apache.org/licenses/LICENSE-2.0 url: 'http://www.apache.org/licenses/LICENSE-2.0'
gpl-compatible: false gpl-compatible: false
js: js:
vendor/google/loader.js: {} vendor/google/loader.js: { }
dependencies: dependencies:
- charts_google/charts_google - charts_google/charts_google
...@@ -12,10 +12,10 @@ use Drupal\charts\Theme\ChartsInterface; ...@@ -12,10 +12,10 @@ use Drupal\charts\Theme\ChartsInterface;
*/ */
function charts_google_charts_info() { function charts_google_charts_info() {
$info['google'] = [ $info['google'] = [
'label' => t('Google Charts'), 'label' => t('Google Charts'),
'render' => '_charts_google_render', 'render' => '_charts_google_render',
'types' => ['area', 'bar', 'column', 'donut', 'line', 'pie', 'scatter'], 'types' => ['area', 'bar', 'column', 'donut', 'line', 'pie', 'scatter'],
'file' => 'charts_google.inc', 'file' => 'charts_google.inc',
]; ];
return $info; return $info;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment