Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
ef2679d0
Commit
ef2679d0
authored
Sep 22, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make commit graphs responsive to window width changes
Closes #2653
parent
9e139255
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
41 deletions
+36
-41
CHANGELOG
CHANGELOG
+1
-0
app/views/projects/graphs/commits.html.haml
app/views/projects/graphs/commits.html.haml
+35
-41
No files found.
CHANGELOG
View file @
ef2679d0
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.0.1
v 8.0.1
- Improve CI migration procedure and documentation
- Improve CI migration procedure and documentation
- Make commit graphs responsive to window width changes (Stan Hu)
v 8.0.0
v 8.0.0
- Fix Markdown links not showing up in dashboard activity feed (Stan Hu)
- Fix Markdown links not showing up in dashboard activity feed (Stan Hu)
...
...
app/views/projects/graphs/commits.html.haml
View file @
ef2679d0
...
@@ -32,61 +32,55 @@
...
@@ -32,61 +32,55 @@
%div
%div
%p
.slead
%p
.slead
Commits per day of month
Commits per day of month
%canvas
#month-chart
{
width:
800
,
height:
400
}
%canvas
#month-chart
.row
.row
.col-md-6
.col-md-6
%div
%div
%p
.slead
%p
.slead
Commits per day hour (UTC)
Commits per day hour (UTC)
%canvas
#hour-chart
{
width:
800
,
height:
400
}
%canvas
#hour-chart
.col-md-6
.col-md-6
%div
%div
%p
.slead
%p
.slead
Commits per weekday
Commits per weekday
%canvas
#weekday-chart
{
width:
800
,
height:
400
}
%canvas
#weekday-chart
:coffeescript
:coffeescript
data = {
responsiveChart = (selector, data) ->
labels :
#{
@commits_per_time
.
keys
.
to_json
}
,
options = { "scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2, maintainAspectRatio: false }
datasets : [{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
barStrokeWidth: 1,
barValueSpacing: 1,
barDatasetSpacing: 1,
data :
#{
@commits_per_time
.
values
.
to_json
}
}]
}
ctx = $("#hour-chart").get(0).getContext("2d");
# get selector by context
new Chart(ctx).Bar(data,{"scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2})
ctx = selector.get(0).getContext("2d")
# pointing parent container to make chart.js inherit its width
container = $(selector).parent()
data = {
generateChart = ->
labels :
#{
@commits_per_week_days
.
keys
.
to_json
}
,
selector.attr('width', $(container).width())
datasets : [{
new Chart(ctx).Bar(data, options)
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
# enabling auto-resizing
barStrokeWidth: 1,
$(window).resize( generateChart )
barValueSpacing: 1,
barDatasetSpacing: 1,
data :
#{
@commits_per_week_days
.
values
.
to_json
}
}]
}
ctx = $("#weekday-chart").get(0).getContext("2d");
generateChart()
new Chart(ctx).Bar(data,{"scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2})
chartData = (keys, values) ->
data = {
data = {
labels :
#{
@commits_per_month
.
keys
.
to_json
}
,
labels : keys
,
datasets : [{
datasets : [{
fillColor : "rgba(220,220,220,0.5)",
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
strokeColor : "rgba(220,220,220,1)",
barStrokeWidth: 1,
barStrokeWidth: 1,
barValueSpacing: 1,
barValueSpacing: 1,
barDatasetSpacing: 1,
barDatasetSpacing: 1,
data :
#{
@commits_per_month
.
values
.
to_json
}
data : values
}]
}]
}
}
ctx = $("#month-chart").get(0).getContext("2d");
hourData = chartData(
#{
@commits_per_time
.
keys
.
to_json
}
,
#{
@commits_per_time
.
values
.
to_json
}
)
new Chart(ctx).Bar(data, {"scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2})
responsiveChart($('#hour-chart'), hourData)
dayData = chartData(
#{
@commits_per_week_days
.
keys
.
to_json
}
,
#{
@commits_per_week_days
.
values
.
to_json
}
)
responsiveChart($('#weekday-chart'), dayData)
monthData = chartData(
#{
@commits_per_month
.
keys
.
to_json
}
,
#{
@commits_per_month
.
values
.
to_json
}
)
responsiveChart($('#month-chart'), monthData)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment