Skip to content

Commit f669b10

Browse files
author
Christoph Wolfes
committed
fixed y-axis scale
1 parent 6818658 commit f669b10

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

src/charts/commitsByMonth.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,39 @@
2525
'use strict';
2626

2727
angular.module('adf.widget.scm')
28-
.controller('CommitsByMonthController', function(config, repository, commitsByMonth) {
28+
.controller('CommitsByMonthController', function (config, repository, commitsByMonth) {
2929
var vm = this;
3030
if (commitsByMonth) {
3131
vm.chart = createChart();
3232
}
3333

34-
function parseDate(input) {
35-
var parts = input.split('-');
36-
return Date.UTC(parseInt(parts[0]), parseInt(parts[1]) - 1, 1);
37-
}
38-
3934
function createChart() {
4035
var chartData = [];
36+
var options = {
37+
scales: {
38+
yAxes: [
39+
{
40+
id: 'y-axis-1',
41+
display: true,
42+
position: 'left',
43+
ticks: { fixedStepSize: 1 },
44+
scaleLabel: {
45+
display: true,
46+
labelString: 'Commits'
47+
}
48+
}
49+
]
50+
}
51+
};
4152
var chart = {
4253
labels: [],
4354
data: [chartData],
4455
series: ["Commits"],
45-
class: "chart-line"
56+
class: "chart-line",
57+
options: options
4658
};
4759

48-
angular.forEach(commitsByMonth.month, function(month) {
60+
angular.forEach(commitsByMonth.month, function (month) {
4961
chart.labels.push(month.value);
5062
chartData.push(month.count);
5163
});

src/charts/commitsLastCommits.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,29 @@ angular.module('adf.widget.scm')
3333
}
3434

3535
function createChart() {
36+
var options = {
37+
scales: {
38+
yAxes: [
39+
{
40+
id: 'y-axis-1',
41+
display: true,
42+
position: 'left',
43+
ticks: { fixedStepSize: 1 },
44+
scaleLabel: {
45+
display: true,
46+
labelString: 'Commits'
47+
}
48+
}
49+
]
50+
}
51+
};
3652
var chartData = [];
3753
var chart = {
3854
labels: [],
3955
data: [chartData],
4056
series: ["Commits"],
41-
class: "chart-line"
57+
class: "chart-line",
58+
options: options
4259
};
4360

4461
var data = {};
@@ -57,7 +74,6 @@ angular.module('adf.widget.scm')
5774
});
5875

5976
angular.forEach(data, function(entry) {
60-
console.log(entry);
6177
chart.labels.push(entry.date);
6278
chartData.push(entry.count);
6379
});

src/charts/line-chart.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div ng-if="vm.chart">
66
<canvas id="line" class="chart chart-line"
77
chart-data="vm.chart.data" chart-labels="vm.chart.labels"
8-
chart-options="vm.chart.options" chart-series="vm.chart.series">
8+
chart-series="vm.chart.series" chart-options="vm.chart.options">
99
</canvas>
1010
</div>
1111
</div>

0 commit comments

Comments
 (0)