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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
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
Hide 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.
v 8.0.1
- Improve CI migration procedure and documentation
- Make commit graphs responsive to window width changes (Stan Hu)
v 8.0.0
- 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 @@
%div
%p
.slead
Commits per day of month
%canvas
#month-chart
{
width:
800
,
height:
400
}
%canvas
#month-chart
.row
.col-md-6
%div
%p
.slead
Commits per day hour (UTC)
%canvas
#hour-chart
{
width:
800
,
height:
400
}
%canvas
#hour-chart
.col-md-6
%div
%p
.slead
Commits per weekday
%canvas
#weekday-chart
{
width:
800
,
height:
400
}
%canvas
#weekday-chart
:coffeescript
data = {
labels :
#{
@commits_per_time
.
keys
.
to_json
}
,
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
}
}]
}
responsiveChart = (selector, data) ->
options = { "scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2, maintainAspectRatio: false }
ctx = $("#hour-chart").get(0).getContext("2d");
new Chart(ctx).Bar(data,{"scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2})
# get selector by context
ctx = selector.get(0).getContext("2d")
# pointing parent container to make chart.js inherit its width
container = $(selector).parent()
data = {
labels :
#{
@commits_per_week_days
.
keys
.
to_json
}
,
datasets : [{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
barStrokeWidth: 1,
barValueSpacing: 1,
barDatasetSpacing: 1,
data :
#{
@commits_per_week_days
.
values
.
to_json
}
}]
}
generateChart = ->
selector.attr('width', $(container).width())
new Chart(ctx).Bar(data, options)
# enabling auto-resizing
$(window).resize( generateChart )
ctx = $("#weekday-chart").get(0).getContext("2d");
new Chart(ctx).Bar(data,{"scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2})
generateChart()
data = {
labels :
#{
@commits_per_month
.
keys
.
to_json
}
,
datasets : [{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
barStrokeWidth: 1,
barValueSpacing: 1,
barDatasetSpacing: 1,
data :
#{
@commits_per_month
.
values
.
to_json
}
}]
chartData = (keys, values) ->
data = {
labels : keys,
datasets : [{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
barStrokeWidth: 1,
barValueSpacing: 1,
barDatasetSpacing: 1,
data : values
}]
}
ctx = $("#month-chart").get(0).getContext("2d");
new Chart(ctx).Bar(data, {"scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2})
hourData = chartData(
#{
@commits_per_time
.
keys
.
to_json
}
,
#{
@commits_per_time
.
values
.
to_json
}
)
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