Skip to content
Snippets Groups Projects
Commit 35b8ef9e authored by Nia Kathoni's avatar Nia Kathoni Committed by Daniel Cothran
Browse files

Issue #3495124: Rename charts.es6.js to charts.js for 5.1.x

parent 3e1b3566
No related branches found
No related tags found
1 merge request!124Resolve #3495124 "Rename charts.es6.js to"
Pipeline #378718 passed with warnings
/**
* @file
* Charts API.
*/
((Drupal) => {
Drupal.Charts = Drupal.Charts || {};
Drupal.Charts.Configs = Drupal.Charts.Configs || [];
/**
* @typedef {class} Drupal.Charts.Contents
*/
Drupal.Charts.Contents = class {
constructor() {
const chartsElements = document.querySelectorAll('[data-chart]');
chartsElements.forEach(function (el) {
const id = el.getAttribute('id');
Drupal.Charts.Configs[id] = JSON.parse(el.getAttribute('data-chart'));
Drupal.Charts.Configs[id].drupalChartDivElement = el;
Drupal.Charts.Configs[id].drupalChartDivId = id;
});
}
initialize(id) {
const event = new CustomEvent('drupalChartsConfigsInitialization', {
detail: Drupal.Charts.Configs[id]
});
Drupal.Charts.Configs[id].drupalChartDivElement.dispatchEvent(event);
}
static update(id, data) {
if (Drupal.Charts.Configs.hasOwnProperty(id)) {
Drupal.Charts.Configs[id] = data;
}
}
getData(id) {
if (Drupal.Charts.Configs.hasOwnProperty(id)) {
this.initialize(id);
return Drupal.Charts.Configs[id];
}
return {};
}
};
})(Drupal);
/**
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
* @file
* Charts API.
*/
((Drupal) => {
(Drupal => {
Drupal.Charts = Drupal.Charts || {};
Drupal.Charts.Configs = Drupal.Charts.Configs || [];
/**
* @typedef {class} Drupal.Charts.Contents
*/
Drupal.Charts.Contents = class {
constructor() {
const charts_elements = document.querySelectorAll('[data-chart]');
charts_elements.forEach(function (el) {
const chartsElements = document.querySelectorAll('[data-chart]');
chartsElements.forEach(function (el) {
const id = el.getAttribute('id');
Drupal.Charts.Configs[id] = JSON.parse(el.getAttribute('data-chart'));
Drupal.Charts.Configs[id].drupalChartDivElement = el;
......@@ -21,7 +24,8 @@
initialize(id) {
const event = new CustomEvent('drupalChartsConfigsInitialization', {
detail: Drupal.Charts.Configs[id]
detail: Drupal.Charts.Configs[id],
bubbles: true,
});
Drupal.Charts.Configs[id].drupalChartDivElement.dispatchEvent(event);
}
......@@ -37,9 +41,7 @@
this.initialize(id);
return Drupal.Charts.Configs[id];
}
return {};
}
};
})(Drupal);
(function () {
(function (Drupal) {
'use strict';
Drupal.charts_api_example = Drupal.charts_api_example || {};
// PLEASE NOTE: this example is structured to work for Highcharts, but you
// do the same thing for any of the charting libraries.
......@@ -7,10 +9,11 @@
return 'The value for <b>' + this.x +
'</b> is <b>' + this.y + '</b>';
};
Drupal.behaviors.chartsApiExampleCharts = {
attach: function (context, settings) {
let chartcontainer = document.getElementById('exampleidjs');
chartcontainer.addEventListener('drupalChartsConfigsInitialization', function (e) {
let chartContainer = document.getElementById('example-id-js');
chartContainer.addEventListener('drupalChartsConfigsInitialization', function (e) {
let data = e.detail;
const id = data.drupalChartDivId;
// Change the background of the chart to green.
......@@ -21,4 +24,4 @@
});
}
};
}());
}(Drupal));
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