mirror of
https://github.com/Karaka-Management/oms-SalesAnalysis.git
synced 2026-01-11 03:18:40 +00:00
more tests and some fixes
This commit is contained in:
parent
5b0fff22aa
commit
f8d933b3f5
|
|
@ -3,6 +3,7 @@ import { Autoloader } from '../../../jsOMS/Autoloader.js';
|
||||||
|
|
||||||
Autoloader.defineNamespace('omsApp.Modules');
|
Autoloader.defineNamespace('omsApp.Modules');
|
||||||
|
|
||||||
|
/* global omsApp ChartGeo Chart */
|
||||||
omsApp.Modules.SalesAnalysis = class {
|
omsApp.Modules.SalesAnalysis = class {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
|
@ -16,8 +17,11 @@ omsApp.Modules.SalesAnalysis = class {
|
||||||
|
|
||||||
bind (id)
|
bind (id)
|
||||||
{
|
{
|
||||||
const charts = typeof id === 'undefined' ? document.getElementsByTagName('canvas') : [document.getElementById(id)];
|
const charts = typeof id === 'undefined'
|
||||||
let length = charts.length;
|
? document.getElementsByTagName('canvas')
|
||||||
|
: [document.getElementById(id)];
|
||||||
|
|
||||||
|
const length = charts.length;
|
||||||
|
|
||||||
for (let i = 0; i < length; ++i) {
|
for (let i = 0; i < length; ++i) {
|
||||||
if (charts[i].getAttribute('data-chart') === null
|
if (charts[i].getAttribute('data-chart') === null
|
||||||
|
|
@ -38,7 +42,6 @@ omsApp.Modules.SalesAnalysis = class {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const self = this;
|
|
||||||
const data = JSON.parse(chart.getAttribute('data-chart'));
|
const data = JSON.parse(chart.getAttribute('data-chart'));
|
||||||
|
|
||||||
if (data.type === 'choropleth') {
|
if (data.type === 'choropleth') {
|
||||||
|
|
@ -58,15 +61,16 @@ omsApp.Modules.SalesAnalysis = class {
|
||||||
}
|
}
|
||||||
|
|
||||||
data.data.datasets[0].data = countries.map((c) => (
|
data.data.datasets[0].data = countries.map((c) => (
|
||||||
{feature: c, value: (vals.hasOwnProperty(c.id) ? vals[c.id] : null)}
|
{ feature: c, value: Object.prototype.hasOwnProperty.call(vals, c.id) ? vals[c.id] : null }
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
const myChart = new Chart(chart.getContext('2d'), data);
|
const myChart = new Chart(chart.getContext('2d'), data);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
const myChart = new Chart(chart.getContext('2d'), data);
|
const myChart = new Chart(chart.getContext('2d'), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user