From 8976f4d15c151afaf2249c526c6a42463e98f491 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 21 Nov 2016 22:50:57 -0500 Subject: Use components to render charts --- assets/js/components/chart-avg-time-column.js | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 assets/js/components/chart-avg-time-column.js (limited to 'assets/js/components/chart-avg-time-column.js') diff --git a/assets/js/components/chart-avg-time-column.js b/assets/js/components/chart-avg-time-column.js new file mode 100644 index 00000000..0fc85f71 --- /dev/null +++ b/assets/js/components/chart-avg-time-column.js @@ -0,0 +1,41 @@ +KB.component('chart-avg-time-column', function (containerElement, options) { + + this.render = function () { + var metrics = options.metrics; + var plots = [options.label]; + var categories = []; + + for (var column_id in metrics) { + plots.push(metrics[column_id].average); + categories.push(metrics[column_id].title); + } + + KB.el(containerElement).add(KB.el('div').attr('id', 'chart').build()); + + c3.generate({ + data: { + columns: [plots], + type: 'bar' + }, + bar: { + width: { + ratio: 0.5 + } + }, + axis: { + x: { + type: 'category', + categories: categories + }, + y: { + tick: { + format: KB.utils.formatDuration + } + } + }, + legend: { + show: false + } + }); + }; +}); \ No newline at end of file -- cgit v1.2.3