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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e9fcaed3
Commit
e9fcaed3
authored
Apr 29, 2018
by
Paul Vorbach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor duplicate code
parent
2fc6c0d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js
...ges/projects/graphs/show/stat_graph_contributors_graph.js
+10
-6
No files found.
app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js
View file @
e9fcaed3
...
...
@@ -13,8 +13,8 @@ import { dateTickFormat } from '~/lib/utils/tick_formats';
const
d3
=
{
extent
,
max
,
select
,
scaleTime
,
scaleLinear
,
axisLeft
,
axisBottom
,
area
,
brushX
,
timeParse
};
const
extend
=
function
(
child
,
parent
)
{
for
(
const
key
in
parent
)
{
if
(
hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
const
hasProp
=
{}.
hasOwnProperty
;
const
extend
=
function
(
child
,
parent
)
{
for
(
const
key
in
parent
)
{
if
(
hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
export
const
ContributorsGraph
=
(
function
()
{
function
ContributorsGraph
()
{}
...
...
@@ -32,6 +32,12 @@ export const ContributorsGraph = (function() {
ContributorsGraph
.
prototype
.
dates
=
[];
ContributorsGraph
.
prototype
.
determine_width
=
function
(
baseWidth
,
$parentElement
)
{
const
parentPaddingWidth
=
parseFloat
(
$parentElement
.
css
(
'
padding-left
'
))
+
parseFloat
(
$parentElement
.
css
(
'
padding-right
'
));
const
marginWidth
=
this
.
MARGIN
.
left
+
this
.
MARGIN
.
right
;
return
baseWidth
-
parentPaddingWidth
-
marginWidth
;
};
ContributorsGraph
.
set_x_domain
=
function
(
data
)
{
return
ContributorsGraph
.
prototype
.
x_domain
=
data
;
};
...
...
@@ -105,11 +111,10 @@ export const ContributorsMasterGraph = (function(superClass) {
function
ContributorsMasterGraph
(
data1
)
{
const
$parentElement
=
$
(
'
#contributors-master
'
);
const
parentPadding
=
parseFloat
(
$parentElement
.
css
(
'
padding-left
'
))
+
parseFloat
(
$parentElement
.
css
(
'
padding-right
'
));
this
.
data
=
data1
;
this
.
update_content
=
this
.
update_content
.
bind
(
this
);
this
.
width
=
$
(
'
.stat-graph
'
).
width
()
-
parentPadding
-
(
this
.
MARGIN
.
left
+
this
.
MARGIN
.
righ
t
);
this
.
width
=
this
.
determine_width
(
$
(
'
.stat-graph
'
).
width
(),
$parentElemen
t
);
this
.
height
=
200
;
this
.
x
=
null
;
this
.
y
=
null
;
...
...
@@ -217,14 +222,13 @@ export const ContributorsAuthorGraph = (function(superClass) {
function
ContributorsAuthorGraph
(
data1
)
{
const
$parentElements
=
$
(
'
.person
'
);
const
parentPadding
=
parseFloat
(
$parentElements
.
css
(
'
padding-left
'
))
+
parseFloat
(
$parentElements
.
css
(
'
padding-right
'
));
this
.
data
=
data1
;
// Don't split graph size in half for mobile devices.
if
(
$
(
window
).
width
()
<
768
)
{
this
.
width
=
$
(
'
.stat-graph
'
).
width
()
-
parentPadding
-
(
this
.
MARGIN
.
left
+
this
.
MARGIN
.
right
);
this
.
width
=
this
.
determine_width
(
$
(
'
.stat-graph
'
).
width
(),
$parentElements
);
}
else
{
this
.
width
=
(
$
(
'
.stat-graph
'
).
width
()
/
2
)
-
parentPadding
-
(
this
.
MARGIN
.
left
+
this
.
MARGIN
.
right
);
this
.
width
=
this
.
determine_width
(
$
(
'
.stat-graph
'
).
width
()
/
2
,
$parentElements
);
}
this
.
height
=
200
;
this
.
x
=
null
;
...
...
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