summaryrefslogtreecommitdiff
path: root/plugins/TimeMachine/Assets/js/components/chart-project-time-machine.js
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2020-05-05 14:25:42 +0200
committeremkael <emkael@tlen.pl>2020-05-05 14:25:42 +0200
commit62827e6cf470449c117624058fb36ad94804bcc0 (patch)
tree10cd1e4d36c34b694acfadaa69fc7f6ae2b1eabd /plugins/TimeMachine/Assets/js/components/chart-project-time-machine.js
parent7b66ddf2e4fbdb837e78d8b7dbaa9fc38391bc32 (diff)
Time tracking related pluginsHEADmaster
Diffstat (limited to 'plugins/TimeMachine/Assets/js/components/chart-project-time-machine.js')
-rw-r--r--plugins/TimeMachine/Assets/js/components/chart-project-time-machine.js84
1 files changed, 84 insertions, 0 deletions
diff --git a/plugins/TimeMachine/Assets/js/components/chart-project-time-machine.js b/plugins/TimeMachine/Assets/js/components/chart-project-time-machine.js
new file mode 100644
index 00000000..0ae20256
--- /dev/null
+++ b/plugins/TimeMachine/Assets/js/components/chart-project-time-machine.js
@@ -0,0 +1,84 @@
+KB.component('chart-project-analytics-time-comparison', function (containerElement, options) {
+ this.render = function () {
+ let spent = options.labelSpent;
+ let estimated = options.labelEstimated;
+ let data = [];
+ let result = [];
+ let groupsSpent = [];
+ let groupsEstimated = [];
+ let categories = [options.labelOpen, options.labelClosed];
+
+ for (let metric in options.metrics) {
+ data[metric+'-'+spent] = [metric+'-'+spent];
+ data[metric+'-'+estimated] = [metric+'-'+estimated];
+ groupsSpent.push(metric+'-'+spent);
+ groupsEstimated.push(metric+'-'+estimated);
+ data[metric+'-'+spent].push(options.metrics[metric]['open'].time_spent);
+ data[metric+'-'+estimated].push(options.metrics[metric]['open'].time_estimated);
+ data[metric+'-'+spent].push(options.metrics[metric]['closed'].time_spent);
+ data[metric+'-'+estimated].push(options.metrics[metric]['closed'].time_estimated);
+ result.push(data[metric+'-'+estimated]);
+ result.push(data[metric+'-'+spent]);
+ }
+ result.sort();
+
+ KB.dom(containerElement).add(KB.dom('div').attr('id', 'chart').build());
+
+ c3.generate({
+ data: {
+ columns: result,
+ type: 'bar',
+ groups: [
+ groupsEstimated,
+ groupsSpent
+ ]
+ },
+ bar: {
+ width: {
+ ratio: 0.5
+ }
+ },
+ axis: {
+ x: {
+ type: 'category',
+ categories: categories
+ }
+ },
+ legend: {
+ show: true
+ }
+ });
+ };
+});
+
+KB.component('chart-project-analytics-spent-time-by-dates', function (containerElement, options) {
+ this.render = function () {
+ let spentTime = [options.labelSpent];
+ spentTime.push(options.metrics['open']);
+ spentTime.push(options.metrics['closed']);
+ let categories = [options.labelOpen, options.labelClosed];
+
+ KB.dom(containerElement).add(KB.dom('div').attr('id', 'chart').build());
+
+ c3.generate({
+ data: {
+ columns: [spentTime],
+ type: 'bar'
+ },
+ bar: {
+ width: {
+ ratio: 0.3
+ }
+ },
+ axis: {
+ x: {
+ type: 'category',
+ categories: categories
+ }
+ },
+ legend: {
+ show: true
+ }
+ });
+ };
+}); \ No newline at end of file