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
Kazuhiko Shiozaki
gitlab-ce
Commits
f3c33b33
Commit
f3c33b33
authored
Jan 19, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't vendor minified g.bar.js
parent
37d3728d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
675 additions
and
9 deletions
+675
-9
app/assets/javascripts/application.js.coffee
app/assets/javascripts/application.js.coffee
+1
-1
vendor/assets/javascripts/g.bar-min.js
vendor/assets/javascripts/g.bar-min.js
+0
-8
vendor/assets/javascripts/g.bar.js
vendor/assets/javascripts/g.bar.js
+674
-0
No files found.
app/assets/javascripts/application.js.coffee
View file @
f3c33b33
...
...
@@ -22,7 +22,7 @@
#= require select2
#= require raphael
#= require g.raphael
#= require g.bar
-min
#= require g.bar
#= require Chart
#= require branch-graph
#= require ace/ace
...
...
vendor/assets/javascripts/g.bar-min.js
deleted
100644 → 0
View file @
37d3728d
/*!
* g.Raphael 0.5 - Charting library, based on Raphaël
*
* Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com)
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
* From: https://github.com/jhurt/g.raphael/blob/master/g.bar.js
*/
(
function
(){
function
c
(
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
){
var
k
,
l
=
{
round
:
"
round
"
,
sharp
:
"
sharp
"
,
soft
:
"
soft
"
,
square
:
"
square
"
};
if
(
g
&&!
f
||!
g
&&!
e
)
return
i
?
""
:
j
.
path
();
switch
(
h
=
l
[
h
]
||
"
square
"
,
f
=
Math
.
round
(
f
),
e
=
Math
.
round
(
e
),
c
=
Math
.
round
(
c
),
d
=
Math
.
round
(
d
),
h
){
case
"
round
"
:
if
(
g
)
m
=~~
(
e
/
2
),
m
>
f
?(
m
=
f
,
k
=
[
"
M
"
,
c
-~~
(
e
/
2
),
d
,
"
l
"
,
0
,
0
,
"
a
"
,
~~
(
e
/
2
),
m
,
0
,
0
,
1
,
e
,
0
,
"
l
"
,
0
,
0
,
"
z
"
]):
k
=
[
"
M
"
,
c
-
m
,
d
,
"
l
"
,
0
,
m
-
f
,
"
a
"
,
m
,
m
,
0
,
1
,
1
,
e
,
0
,
"
l
"
,
0
,
f
-
m
,
"
z
"
];
else
{
var
m
=~~
(
f
/
2
);
m
>
e
?(
m
=
e
,
k
=
[
"
M
"
,
c
+
.
5
,
d
+
.
5
-~~
(
f
/
2
),
"
l
"
,
0
,
0
,
"
a
"
,
m
,
~~
(
f
/
2
),
0
,
0
,
1
,
0
,
f
,
"
l
"
,
0
,
0
,
"
z
"
]):
k
=
[
"
M
"
,
c
+
.
5
,
d
+
.
5
-
m
,
"
l
"
,
e
-
m
,
0
,
"
a
"
,
m
,
m
,
0
,
1
,
1
,
0
,
f
,
"
l
"
,
m
-
e
,
0
,
"
z
"
]}
break
;
case
"
sharp
"
:
if
(
g
)
n
=~~
(
e
/
2
),
k
=
[
"
M
"
,
c
+
n
,
d
,
"
l
"
,
-
e
,
0
,
0
,
-
b
(
f
-
n
,
0
),
n
,
-
a
(
n
,
f
),
n
,
a
(
n
,
f
),
n
,
"
z
"
];
else
{
var
n
=~~
(
f
/
2
);
k
=
[
"
M
"
,
c
,
d
+
n
,
"
l
"
,
0
,
-
f
,
b
(
e
-
n
,
0
),
0
,
a
(
n
,
e
),
n
,
-
a
(
n
,
e
),
n
+
(
f
>
2
*
n
),
"
z
"
]}
break
;
case
"
square
"
:
k
=
g
?[
"
M
"
,
c
+~~
(
e
/
2
),
d
,
"
l
"
,
1
-
e
,
0
,
0
,
-
f
,
e
-
1
,
0
,
"
z
"
]:[
"
M
"
,
c
,
d
+~~
(
f
/
2
),
"
l
"
,
0
,
-
f
,
e
,
0
,
0
,
f
,
"
z
"
];
break
;
case
"
soft
"
:
g
?(
m
=
a
(
Math
.
round
(
e
/
5
),
f
),
k
=
[
"
M
"
,
c
-~~
(
e
/
2
),
d
,
"
l
"
,
0
,
m
-
f
,
"
a
"
,
m
,
m
,
0
,
0
,
1
,
m
,
-
m
,
"
l
"
,
e
-
2
*
m
,
0
,
"
a
"
,
m
,
m
,
0
,
0
,
1
,
m
,
m
,
"
l
"
,
0
,
f
-
m
,
"
z
"
]):(
m
=
a
(
e
,
Math
.
round
(
f
/
5
)),
k
=
[
"
M
"
,
c
+
.
5
,
d
+
.
5
-~~
(
f
/
2
),
"
l
"
,
e
-
m
,
0
,
"
a
"
,
m
,
m
,
0
,
0
,
1
,
m
,
m
,
"
l
"
,
0
,
f
-
2
*
m
,
"
a
"
,
m
,
m
,
0
,
0
,
1
,
-
m
,
m
,
"
l
"
,
m
-
e
,
0
,
"
z
"
])}
return
i
?
k
.
join
(
"
,
"
):
j
.
path
(
k
)}
function
d
(
a
,
b
,
d
,
e
,
f
,
g
,
h
){
h
=
h
||
{};
var
i
=
this
,
j
=
h
.
type
||
"
square
"
,
k
=
parseFloat
(
h
.
gutter
||
"
20%
"
),
l
=
a
.
set
(),
m
=
a
.
set
(),
n
=
a
.
set
(),
o
=
a
.
set
(),
p
=
Math
.
max
.
apply
(
Math
,
g
),
q
=
[],
r
=
0
,
s
=
h
.
colors
||
i
.
colors
,
t
=
g
.
length
;
if
(
Raphael
.
is
(
g
[
0
],
"
array
"
)){
p
=
[],
r
=
t
,
t
=
0
;
for
(
var
u
=
g
.
length
;
u
--
;)
m
.
push
(
a
.
set
()),
p
.
push
(
Math
.
max
.
apply
(
Math
,
g
[
u
])),
t
=
Math
.
max
(
t
,
g
[
u
].
length
);
if
(
h
.
stacked
)
for
(
var
u
=
t
;
u
--
;){
for
(
var
v
=
0
,
w
=
g
.
length
;
w
--
;)
v
+=+
g
[
w
][
u
]
||
0
;
q
.
push
(
v
)}
for
(
var
u
=
g
.
length
;
u
--
;)
if
(
t
>
g
[
u
].
length
)
for
(
var
w
=
t
;
w
--
;)
g
[
u
].
push
(
0
);
p
=
Math
.
max
.
apply
(
Math
,
h
.
stacked
?
q
:
p
)}
p
=
h
.
to
||
p
;
var
x
=
100
*
(
e
/
(
t
*
(
100
+
k
)
+
k
)),
y
=
x
*
k
/
100
,
z
=
null
==
h
.
vgutter
?
20
:
h
.
vgutter
,
A
=
[],
B
=
b
+
y
,
C
=
(
f
-
2
*
z
)
/
p
;
h
.
stretch
||
(
y
=
Math
.
round
(
y
),
x
=
Math
.
floor
(
x
)),
!
h
.
stacked
&&
(
x
/=
r
||
1
);
for
(
var
u
=
0
;
t
>
u
;
u
++
){
A
=
[];
for
(
var
w
=
0
;(
r
||
1
)
>
w
;
w
++
){
var
D
=
Math
.
round
((
r
?
g
[
w
][
u
]:
g
[
u
])
*
C
),
E
=
d
+
f
-
z
-
D
,
F
=
c
(
Math
.
round
(
B
+
x
/
2
),
E
+
D
,
x
,
D
,
!
0
,
j
,
null
,
a
).
attr
({
stroke
:
"
none
"
,
fill
:
s
[
r
?
w
:
u
]});
r
?
m
[
w
].
push
(
F
):
m
.
push
(
F
),
F
.
y
=
E
,
F
.
x
=
Math
.
round
(
B
+
x
/
2
),
F
.
w
=
x
,
F
.
h
=
D
,
F
.
value
=
r
?
g
[
w
][
u
]:
g
[
u
],
h
.
stacked
?
A
.
push
(
F
):
B
+=
x
}
if
(
h
.
stacked
){
var
G
;
o
.
push
(
G
=
a
.
rect
(
A
[
0
].
x
-
A
[
0
].
w
/
2
,
d
,
x
,
f
).
attr
(
i
.
shim
)),
G
.
bars
=
a
.
set
();
for
(
var
H
=
0
,
I
=
A
.
length
;
I
--
;)
A
[
I
].
toFront
();
for
(
var
I
=
0
,
J
=
A
.
length
;
J
>
I
;
I
++
){
var
K
,
F
=
A
[
I
],
D
=
(
H
+
F
.
value
)
*
C
,
L
=
c
(
F
.
x
,
d
+
f
-
z
-
.
5
*!!
H
,
x
,
D
,
!
0
,
j
,
1
,
a
);
G
.
bars
.
push
(
F
),
H
&&
F
.
attr
({
path
:
L
}),
F
.
h
=
D
,
F
.
y
=
d
+
f
-
z
-
.
5
*!!
H
-
D
,
n
.
push
(
K
=
a
.
rect
(
F
.
x
-
F
.
w
/
2
,
F
.
y
,
x
,
F
.
value
*
C
).
attr
(
i
.
shim
)),
K
.
bar
=
F
,
K
.
value
=
F
.
value
,
H
+=
F
.
value
}
B
+=
x
}
B
+=
y
}
if
(
o
.
toFront
(),
B
=
b
+
y
,
!
h
.
stacked
)
for
(
var
u
=
0
;
t
>
u
;
u
++
){
for
(
var
w
=
0
;(
r
||
1
)
>
w
;
w
++
){
var
K
;
n
.
push
(
K
=
a
.
rect
(
Math
.
round
(
B
),
d
+
z
,
x
,
f
-
z
).
attr
(
i
.
shim
)),
K
.
bar
=
r
?
m
[
w
][
u
]:
m
[
u
],
K
.
value
=
K
.
bar
.
value
,
B
+=
x
}
B
+=
y
}
return
l
.
label
=
function
(
b
,
c
){
b
=
b
||
[],
this
.
labels
=
a
.
set
();
var
e
,
j
=-
1
/
0
;
if
(
h
.
stacked
){
for
(
var
k
=
0
;
t
>
k
;
k
++
)
for
(
var
l
=
0
,
o
=
0
;(
r
||
1
)
>
o
;
o
++
)
if
(
l
+=
r
?
g
[
o
][
k
]:
g
[
k
],
o
==
r
-
1
){
var
q
=
i
.
labelise
(
b
[
k
],
l
,
p
);
e
=
a
.
text
(
m
[
o
][
k
].
x
,
d
+
f
-
z
/
2
,
q
).
attr
(
i
.
txtattr
).
attr
({
fill
:
h
.
legendcolor
||
"
#000
"
,
"
text-anchor
"
:
"
start
"
}).
insertBefore
(
n
[
k
*
(
r
||
1
)
+
o
]);
var
s
=
e
.
getBBox
();
j
>
s
.
x
-
7
?
e
.
remove
():(
this
.
labels
.
push
(
e
),
j
=
s
.
x
+
s
.
width
)}}
else
for
(
var
k
=
0
;
t
>
k
;
k
++
)
for
(
var
o
=
0
;(
r
||
1
)
>
o
;
o
++
){
var
q
=
i
.
labelise
(
r
?
b
[
o
]
&&
b
[
o
][
k
]:
b
[
k
],
r
?
g
[
o
][
k
]:
g
[
k
],
p
);
e
=
a
.
text
(
m
[
o
][
k
].
x
-
x
/
2
,
c
?
d
+
f
-
z
/
2
:
m
[
o
][
k
].
y
-
10
,
q
).
attr
(
i
.
txtattr
).
attr
({
fill
:
h
.
legendcolor
||
"
#000
"
,
"
text-anchor
"
:
"
start
"
}).
insertBefore
(
n
[
k
*
(
r
||
1
)
+
o
]);
var
s
=
e
.
getBBox
();
e
.
translate
((
x
-
s
.
width
)
/
2
,
1
),
j
>
s
.
x
-
7
?
e
.
remove
():(
this
.
labels
.
push
(
e
),
j
=
s
.
x
+
s
.
width
)}
return
this
},
l
.
hover
=
function
(
a
,
b
){
return
o
.
hide
(),
n
.
show
(),
n
.
mouseover
(
a
).
mouseout
(
b
),
this
},
l
.
hoverColumn
=
function
(
a
,
b
){
return
n
.
hide
(),
o
.
show
(),
b
=
b
||
function
(){},
o
.
mouseover
(
a
).
mouseout
(
b
),
this
},
l
.
click
=
function
(
a
){
return
o
.
hide
(),
n
.
show
(),
n
.
click
(
a
),
this
},
l
.
each
=
function
(
a
){
if
(
!
Raphael
.
is
(
a
,
"
function
"
))
return
this
;
for
(
var
b
=
n
.
length
;
b
--
;)
a
.
call
(
n
[
b
]);
return
this
},
l
.
eachColumn
=
function
(
a
){
if
(
!
Raphael
.
is
(
a
,
"
function
"
))
return
this
;
for
(
var
b
=
o
.
length
;
b
--
;)
a
.
call
(
o
[
b
]);
return
this
},
l
.
clickColumn
=
function
(
a
){
return
n
.
hide
(),
o
.
show
(),
o
.
click
(
a
),
this
},
l
.
push
(
m
,
n
,
o
),
l
.
bars
=
m
,
l
.
covers
=
n
,
l
}
function
e
(
a
,
b
,
d
,
e
,
f
,
g
,
h
){
h
=
h
||
{};
var
i
=
this
,
j
=
h
.
type
||
"
square
"
,
k
=
parseFloat
(
h
.
gutter
||
"
20%
"
),
l
=
a
.
set
(),
m
=
a
.
set
(),
n
=
a
.
set
(),
o
=
a
.
set
(),
p
=
Math
.
max
.
apply
(
Math
,
g
),
q
=
[],
r
=
0
,
s
=
h
.
colors
||
i
.
colors
,
t
=
g
.
length
;
if
(
Raphael
.
is
(
g
[
0
],
"
array
"
)){
p
=
[],
r
=
t
,
t
=
0
;
for
(
var
u
=
g
.
length
;
u
--
;)
m
.
push
(
a
.
set
()),
p
.
push
(
Math
.
max
.
apply
(
Math
,
g
[
u
])),
t
=
Math
.
max
(
t
,
g
[
u
].
length
);
if
(
h
.
stacked
)
for
(
var
u
=
t
;
u
--
;){
for
(
var
v
=
0
,
w
=
g
.
length
;
w
--
;)
v
+=+
g
[
w
][
u
]
||
0
;
q
.
push
(
v
)}
for
(
var
u
=
g
.
length
;
u
--
;)
if
(
t
>
g
[
u
].
length
)
for
(
var
w
=
t
;
w
--
;)
g
[
u
].
push
(
0
);
p
=
Math
.
max
.
apply
(
Math
,
h
.
stacked
?
q
:
p
)}
p
=
h
.
to
||
p
;
var
x
=
Math
.
floor
(
100
*
(
f
/
(
t
*
(
100
+
k
)
+
k
))),
y
=
Math
.
floor
(
x
*
k
/
100
),
z
=
[],
A
=
d
+
y
,
B
=
(
e
-
1
)
/
p
;
!
h
.
stacked
&&
(
x
/=
r
||
1
);
for
(
var
u
=
0
;
t
>
u
;
u
++
){
z
=
[];
for
(
var
w
=
0
;(
r
||
1
)
>
w
;
w
++
){
var
C
=
r
?
g
[
w
][
u
]:
g
[
u
],
D
=
c
(
b
,
A
+
x
/
2
,
Math
.
round
(
C
*
B
),
x
-
1
,
!
1
,
j
,
null
,
a
).
attr
({
stroke
:
"
none
"
,
fill
:
s
[
r
?
w
:
u
]});
r
?
m
[
w
].
push
(
D
):
m
.
push
(
D
),
D
.
x
=
b
+
Math
.
round
(
C
*
B
),
D
.
y
=
A
+
x
/
2
,
D
.
w
=
Math
.
round
(
C
*
B
),
D
.
h
=
x
,
D
.
value
=+
C
,
h
.
stacked
?
z
.
push
(
D
):
A
+=
x
}
if
(
h
.
stacked
){
var
E
=
a
.
rect
(
b
,
z
[
0
].
y
-
z
[
0
].
h
/
2
,
e
,
x
).
attr
(
i
.
shim
);
o
.
push
(
E
),
E
.
bars
=
a
.
set
();
for
(
var
F
=
0
,
G
=
z
.
length
;
G
--
;)
z
[
G
].
toFront
();
for
(
var
G
=
0
,
H
=
z
.
length
;
H
>
G
;
G
++
){
var
I
,
D
=
z
[
G
],
C
=
Math
.
round
((
F
+
D
.
value
)
*
B
),
J
=
c
(
b
,
D
.
y
,
C
,
x
-
1
,
!
1
,
j
,
1
,
a
);
E
.
bars
.
push
(
D
),
F
&&
D
.
attr
({
path
:
J
}),
D
.
w
=
C
,
D
.
x
=
b
+
C
,
n
.
push
(
I
=
a
.
rect
(
b
+
F
*
B
,
D
.
y
-
D
.
h
/
2
,
D
.
value
*
B
,
x
).
attr
(
i
.
shim
)),
I
.
bar
=
D
,
F
+=
D
.
value
}
A
+=
x
}
A
+=
y
}
if
(
o
.
toFront
(),
A
=
d
+
y
,
!
h
.
stacked
)
for
(
var
u
=
0
;
t
>
u
;
u
++
){
for
(
var
w
=
0
;(
r
||
1
)
>
w
;
w
++
){
var
I
=
a
.
rect
(
b
,
A
,
e
,
x
).
attr
(
i
.
shim
);
n
.
push
(
I
),
I
.
bar
=
r
?
m
[
w
][
u
]:
m
[
u
],
I
.
value
=
I
.
bar
.
value
,
A
+=
x
}
A
+=
y
}
return
l
.
label
=
function
(
c
,
d
){
c
=
c
||
[],
this
.
labels
=
a
.
set
();
for
(
var
e
=
0
;
t
>
e
;
e
++
)
for
(
var
f
=
0
;
r
>
f
;
f
++
){
var
o
,
j
=
i
.
labelise
(
r
?
c
[
f
]
&&
c
[
f
][
e
]:
c
[
e
],
r
?
g
[
f
][
e
]:
g
[
e
],
p
),
k
=
d
?
m
[
f
][
e
].
x
-
x
/
2
+
3
:
b
+
5
;
this
.
labels
.
push
(
o
=
a
.
text
(
k
,
m
[
f
][
e
].
y
,
j
).
attr
(
i
.
txtattr
).
attr
({
fill
:
h
.
legendcolor
||
"
#000
"
,
"
text-anchor
"
:
"
start
"
}).
insertBefore
(
n
[
0
])),
b
+
5
>
o
.
getBBox
().
x
?
o
.
attr
({
x
:
b
+
5
,
"
text-anchor
"
:
"
start
"
}):
m
[
f
][
e
].
label
=
o
}
return
this
},
l
.
hover
=
function
(
a
,
b
){
return
o
.
hide
(),
n
.
show
(),
b
=
b
||
function
(){},
n
.
mouseover
(
a
).
mouseout
(
b
),
this
},
l
.
hoverColumn
=
function
(
a
,
b
){
return
n
.
hide
(),
o
.
show
(),
b
=
b
||
function
(){},
o
.
mouseover
(
a
).
mouseout
(
b
),
this
},
l
.
each
=
function
(
a
){
if
(
!
Raphael
.
is
(
a
,
"
function
"
))
return
this
;
for
(
var
b
=
n
.
length
;
b
--
;)
a
.
call
(
n
[
b
]);
return
this
},
l
.
eachColumn
=
function
(
a
){
if
(
!
Raphael
.
is
(
a
,
"
function
"
))
return
this
;
for
(
var
b
=
o
.
length
;
b
--
;)
a
.
call
(
o
[
b
]);
return
this
},
l
.
click
=
function
(
a
){
return
o
.
hide
(),
n
.
show
(),
n
.
click
(
a
),
this
},
l
.
clickColumn
=
function
(
a
){
return
n
.
hide
(),
o
.
show
(),
o
.
click
(
a
),
this
},
l
.
push
(
m
,
n
,
o
),
l
.
bars
=
m
,
l
.
covers
=
n
,
l
}
var
a
=
Math
.
min
,
b
=
Math
.
max
,
f
=
function
(){};
f
.
prototype
=
Raphael
.
g
,
e
.
prototype
=
d
.
prototype
=
new
f
,
Raphael
.
fn
.
hbarchart
=
function
(
a
,
b
,
c
,
d
,
f
,
g
){
return
new
e
(
this
,
a
,
b
,
c
,
d
,
f
,
g
)},
Raphael
.
fn
.
barchart
=
function
(
a
,
b
,
c
,
e
,
f
,
g
){
return
new
d
(
this
,
a
,
b
,
c
,
e
,
f
,
g
)}})();
\ No newline at end of file
vendor/assets/javascripts/g.bar.js
0 → 100644
View file @
f3c33b33
/*!
* g.Raphael 0.51 - Charting library, based on Raphaël
*
* Copyright (c) 2009-2012 Dmitry Baranovskiy (http://g.raphaeljs.com)
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/
(
function
()
{
var
mmin
=
Math
.
min
,
mmax
=
Math
.
max
;
function
finger
(
x
,
y
,
width
,
height
,
dir
,
ending
,
isPath
,
paper
)
{
var
path
,
ends
=
{
round
:
'
round
'
,
sharp
:
'
sharp
'
,
soft
:
'
soft
'
,
square
:
'
square
'
};
// dir 0 for horizontal and 1 for vertical
if
((
dir
&&
!
height
)
||
(
!
dir
&&
!
width
))
{
return
isPath
?
""
:
paper
.
path
();
}
ending
=
ends
[
ending
]
||
"
square
"
;
height
=
Math
.
round
(
height
);
width
=
Math
.
round
(
width
);
x
=
Math
.
round
(
x
);
y
=
Math
.
round
(
y
);
switch
(
ending
)
{
case
"
round
"
:
if
(
!
dir
)
{
var
r
=
~~
(
height
/
2
);
if
(
width
<
r
)
{
r
=
width
;
path
=
[
"
M
"
,
x
+
.
5
,
y
+
.
5
-
~~
(
height
/
2
),
"
l
"
,
0
,
0
,
"
a
"
,
r
,
~~
(
height
/
2
),
0
,
0
,
1
,
0
,
height
,
"
l
"
,
0
,
0
,
"
z
"
];
}
else
{
path
=
[
"
M
"
,
x
+
.
5
,
y
+
.
5
-
r
,
"
l
"
,
width
-
r
,
0
,
"
a
"
,
r
,
r
,
0
,
1
,
1
,
0
,
height
,
"
l
"
,
r
-
width
,
0
,
"
z
"
];
}
}
else
{
r
=
~~
(
width
/
2
);
if
(
height
<
r
)
{
r
=
height
;
path
=
[
"
M
"
,
x
-
~~
(
width
/
2
),
y
,
"
l
"
,
0
,
0
,
"
a
"
,
~~
(
width
/
2
),
r
,
0
,
0
,
1
,
width
,
0
,
"
l
"
,
0
,
0
,
"
z
"
];
}
else
{
path
=
[
"
M
"
,
x
-
r
,
y
,
"
l
"
,
0
,
r
-
height
,
"
a
"
,
r
,
r
,
0
,
1
,
1
,
width
,
0
,
"
l
"
,
0
,
height
-
r
,
"
z
"
];
}
}
break
;
case
"
sharp
"
:
if
(
!
dir
)
{
var
half
=
~~
(
height
/
2
);
path
=
[
"
M
"
,
x
,
y
+
half
,
"
l
"
,
0
,
-
height
,
mmax
(
width
-
half
,
0
),
0
,
mmin
(
half
,
width
),
half
,
-
mmin
(
half
,
width
),
half
+
(
half
*
2
<
height
),
"
z
"
];
}
else
{
half
=
~~
(
width
/
2
);
path
=
[
"
M
"
,
x
+
half
,
y
,
"
l
"
,
-
width
,
0
,
0
,
-
mmax
(
height
-
half
,
0
),
half
,
-
mmin
(
half
,
height
),
half
,
mmin
(
half
,
height
),
half
,
"
z
"
];
}
break
;
case
"
square
"
:
if
(
!
dir
)
{
path
=
[
"
M
"
,
x
,
y
+
~~
(
height
/
2
),
"
l
"
,
0
,
-
height
,
width
,
0
,
0
,
height
,
"
z
"
];
}
else
{
path
=
[
"
M
"
,
x
+
~~
(
width
/
2
),
y
,
"
l
"
,
1
-
width
,
0
,
0
,
-
height
,
width
-
1
,
0
,
"
z
"
];
}
break
;
case
"
soft
"
:
if
(
!
dir
)
{
r
=
mmin
(
width
,
Math
.
round
(
height
/
5
));
path
=
[
"
M
"
,
x
+
.
5
,
y
+
.
5
-
~~
(
height
/
2
),
"
l
"
,
width
-
r
,
0
,
"
a
"
,
r
,
r
,
0
,
0
,
1
,
r
,
r
,
"
l
"
,
0
,
height
-
r
*
2
,
"
a
"
,
r
,
r
,
0
,
0
,
1
,
-
r
,
r
,
"
l
"
,
r
-
width
,
0
,
"
z
"
];
}
else
{
r
=
mmin
(
Math
.
round
(
width
/
5
),
height
);
path
=
[
"
M
"
,
x
-
~~
(
width
/
2
),
y
,
"
l
"
,
0
,
r
-
height
,
"
a
"
,
r
,
r
,
0
,
0
,
1
,
r
,
-
r
,
"
l
"
,
width
-
2
*
r
,
0
,
"
a
"
,
r
,
r
,
0
,
0
,
1
,
r
,
r
,
"
l
"
,
0
,
height
-
r
,
"
z
"
];
}
}
if
(
isPath
)
{
return
path
.
join
(
"
,
"
);
}
else
{
return
paper
.
path
(
path
);
}
}
/*\
* Paper.vbarchart
[ method ]
**
* Creates a vertical bar chart
**
> Parameters
**
- x (number) x coordinate of the chart
- y (number) y coordinate of the chart
- width (number) width of the chart (respected by all elements in the set)
- height (number) height of the chart (respected by all elements in the set)
- values (array) values
- opts (object) options for the chart
o {
o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
o vgutter (number)
o colors (array) colors be used repeatedly to plot the bars. If multicolumn bar is used each sequence of bars with use a different color.
o stacked (boolean) whether or not to tread values as in a stacked bar chart
o to
o stretch (boolean)
o }
**
= (object) path element of the popup
> Usage
| r.vbarchart(0, 0, 620, 260, [76, 70, 67, 71, 69], {})
\*/
function
VBarchart
(
paper
,
x
,
y
,
width
,
height
,
values
,
opts
)
{
opts
=
opts
||
{};
var
chartinst
=
this
,
type
=
opts
.
type
||
"
square
"
,
gutter
=
parseFloat
(
opts
.
gutter
||
"
20%
"
),
chart
=
paper
.
set
(),
bars
=
paper
.
set
(),
covers
=
paper
.
set
(),
covers2
=
paper
.
set
(),
total
=
Math
.
max
.
apply
(
Math
,
values
),
stacktotal
=
[],
multi
=
0
,
colors
=
opts
.
colors
||
chartinst
.
colors
,
len
=
values
.
length
;
if
(
Raphael
.
is
(
values
[
0
],
"
array
"
))
{
total
=
[];
multi
=
len
;
len
=
0
;
for
(
var
i
=
values
.
length
;
i
--
;)
{
bars
.
push
(
paper
.
set
());
total
.
push
(
Math
.
max
.
apply
(
Math
,
values
[
i
]));
len
=
Math
.
max
(
len
,
values
[
i
].
length
);
}
if
(
opts
.
stacked
)
{
for
(
var
i
=
len
;
i
--
;)
{
var
tot
=
0
;
for
(
var
j
=
values
.
length
;
j
--
;)
{
tot
+=+
values
[
j
][
i
]
||
0
;
}
stacktotal
.
push
(
tot
);
}
}
for
(
var
i
=
values
.
length
;
i
--
;)
{
if
(
values
[
i
].
length
<
len
)
{
for
(
var
j
=
len
;
j
--
;)
{
values
[
i
].
push
(
0
);
}
}
}
total
=
Math
.
max
.
apply
(
Math
,
opts
.
stacked
?
stacktotal
:
total
);
}
total
=
(
opts
.
to
)
||
total
;
var
barwidth
=
width
/
(
len
*
(
100
+
gutter
)
+
gutter
)
*
100
,
barhgutter
=
barwidth
*
gutter
/
100
,
barvgutter
=
opts
.
vgutter
==
null
?
20
:
opts
.
vgutter
,
stack
=
[],
X
=
x
+
barhgutter
,
Y
=
(
height
-
2
*
barvgutter
)
/
total
;
if
(
!
opts
.
stretch
)
{
barhgutter
=
Math
.
round
(
barhgutter
);
barwidth
=
Math
.
floor
(
barwidth
);
}
!
opts
.
stacked
&&
(
barwidth
/=
multi
||
1
);
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
stack
=
[];
for
(
var
j
=
0
;
j
<
(
multi
||
1
);
j
++
)
{
var
h
=
Math
.
round
((
multi
?
values
[
j
][
i
]
:
values
[
i
])
*
Y
),
top
=
y
+
height
-
barvgutter
-
h
,
bar
=
finger
(
Math
.
round
(
X
+
barwidth
/
2
),
top
+
h
,
barwidth
,
h
,
true
,
type
,
null
,
paper
).
attr
({
stroke
:
"
none
"
,
fill
:
colors
[
multi
?
j
:
i
]
});
if
(
multi
)
{
bars
[
j
].
push
(
bar
);
}
else
{
bars
.
push
(
bar
);
}
bar
.
y
=
top
;
bar
.
x
=
Math
.
round
(
X
+
barwidth
/
2
);
bar
.
w
=
barwidth
;
bar
.
h
=
h
;
bar
.
value
=
multi
?
values
[
j
][
i
]
:
values
[
i
];
if
(
!
opts
.
stacked
)
{
X
+=
barwidth
;
}
else
{
stack
.
push
(
bar
);
}
}
if
(
opts
.
stacked
)
{
var
cvr
;
covers2
.
push
(
cvr
=
paper
.
rect
(
stack
[
0
].
x
-
stack
[
0
].
w
/
2
,
y
,
barwidth
,
height
).
attr
(
chartinst
.
shim
));
cvr
.
bars
=
paper
.
set
();
var
size
=
0
;
for
(
var
s
=
stack
.
length
;
s
--
;)
{
stack
[
s
].
toFront
();
}
for
(
var
s
=
0
,
ss
=
stack
.
length
;
s
<
ss
;
s
++
)
{
var
bar
=
stack
[
s
],
cover
,
h
=
(
size
+
bar
.
value
)
*
Y
,
path
=
finger
(
bar
.
x
,
y
+
height
-
barvgutter
-
!!
size
*
.
5
,
barwidth
,
h
,
true
,
type
,
1
,
paper
);
cvr
.
bars
.
push
(
bar
);
size
&&
bar
.
attr
({
path
:
path
});
bar
.
h
=
h
;
bar
.
y
=
y
+
height
-
barvgutter
-
!!
size
*
.
5
-
h
;
covers
.
push
(
cover
=
paper
.
rect
(
bar
.
x
-
bar
.
w
/
2
,
bar
.
y
,
barwidth
,
bar
.
value
*
Y
).
attr
(
chartinst
.
shim
));
cover
.
bar
=
bar
;
cover
.
value
=
bar
.
value
;
size
+=
bar
.
value
;
}
X
+=
barwidth
;
}
X
+=
barhgutter
;
}
covers2
.
toFront
();
X
=
x
+
barhgutter
;
if
(
!
opts
.
stacked
)
{
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
for
(
var
j
=
0
;
j
<
(
multi
||
1
);
j
++
)
{
var
cover
;
covers
.
push
(
cover
=
paper
.
rect
(
Math
.
round
(
X
),
y
+
barvgutter
,
barwidth
,
height
-
barvgutter
).
attr
(
chartinst
.
shim
));
cover
.
bar
=
multi
?
bars
[
j
][
i
]
:
bars
[
i
];
cover
.
value
=
cover
.
bar
.
value
;
X
+=
barwidth
;
}
X
+=
barhgutter
;
}
}
chart
.
label
=
function
(
labels
,
isBottom
)
{
labels
=
labels
||
[];
this
.
labels
=
paper
.
set
();
var
L
,
l
=
-
Infinity
;
if
(
opts
.
stacked
)
{
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
var
tot
=
0
;
for
(
var
j
=
0
;
j
<
(
multi
||
1
);
j
++
)
{
tot
+=
multi
?
values
[
j
][
i
]
:
values
[
i
];
if
(
j
==
multi
-
1
)
{
var
label
=
paper
.
labelise
(
labels
[
i
],
tot
,
total
);
L
=
paper
.
text
(
bars
[
i
*
(
multi
||
1
)
+
j
].
x
,
y
+
height
-
barvgutter
/
2
,
label
).
attr
(
txtattr
).
insertBefore
(
covers
[
i
*
(
multi
||
1
)
+
j
]);
var
bb
=
L
.
getBBox
();
if
(
bb
.
x
-
7
<
l
)
{
L
.
remove
();
}
else
{
this
.
labels
.
push
(
L
);
l
=
bb
.
x
+
bb
.
width
;
}
}
}
}
}
else
{
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
for
(
var
j
=
0
;
j
<
(
multi
||
1
);
j
++
)
{
var
label
=
paper
.
labelise
(
multi
?
labels
[
j
]
&&
labels
[
j
][
i
]
:
labels
[
i
],
multi
?
values
[
j
][
i
]
:
values
[
i
],
total
);
L
=
paper
.
text
(
bars
[
i
*
(
multi
||
1
)
+
j
].
x
,
isBottom
?
y
+
height
-
barvgutter
/
2
:
bars
[
i
*
(
multi
||
1
)
+
j
].
y
-
10
,
label
).
attr
(
txtattr
).
insertBefore
(
covers
[
i
*
(
multi
||
1
)
+
j
]);
var
bb
=
L
.
getBBox
();
if
(
bb
.
x
-
7
<
l
)
{
L
.
remove
();
}
else
{
this
.
labels
.
push
(
L
);
l
=
bb
.
x
+
bb
.
width
;
}
}
}
}
return
this
;
};
chart
.
hover
=
function
(
fin
,
fout
)
{
covers2
.
hide
();
covers
.
show
();
covers
.
mouseover
(
fin
).
mouseout
(
fout
);
return
this
;
};
chart
.
hoverColumn
=
function
(
fin
,
fout
)
{
covers
.
hide
();
covers2
.
show
();
fout
=
fout
||
function
()
{};
covers2
.
mouseover
(
fin
).
mouseout
(
fout
);
return
this
;
};
chart
.
click
=
function
(
f
)
{
covers2
.
hide
();
covers
.
show
();
covers
.
click
(
f
);
return
this
;
};
chart
.
each
=
function
(
f
)
{
if
(
!
Raphael
.
is
(
f
,
"
function
"
))
{
return
this
;
}
for
(
var
i
=
covers
.
length
;
i
--
;)
{
f
.
call
(
covers
[
i
]);
}
return
this
;
};
chart
.
eachColumn
=
function
(
f
)
{
if
(
!
Raphael
.
is
(
f
,
"
function
"
))
{
return
this
;
}
for
(
var
i
=
covers2
.
length
;
i
--
;)
{
f
.
call
(
covers2
[
i
]);
}
return
this
;
};
chart
.
clickColumn
=
function
(
f
)
{
covers
.
hide
();
covers2
.
show
();
covers2
.
click
(
f
);
return
this
;
};
chart
.
push
(
bars
,
covers
,
covers2
);
chart
.
bars
=
bars
;
chart
.
covers
=
covers
;
return
chart
;
};
//inheritance
var
F
=
function
()
{};
F
.
prototype
=
Raphael
.
g
;
HBarchart
.
prototype
=
VBarchart
.
prototype
=
new
F
;
//prototype reused by hbarchart
Raphael
.
fn
.
barchart
=
function
(
x
,
y
,
width
,
height
,
values
,
opts
)
{
return
new
VBarchart
(
this
,
x
,
y
,
width
,
height
,
values
,
opts
);
};
/*\
* Paper.barchart
[ method ]
**
* Creates a horizontal bar chart
**
> Parameters
**
- x (number) x coordinate of the chart
- y (number) y coordinate of the chart
- width (number) width of the chart (respected by all elements in the set)
- height (number) height of the chart (respected by all elements in the set)
- values (array) values
- opts (object) options for the chart
o {
o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
o vgutter (number)
o colors (array) colors be used repeatedly to plot the bars. If multicolumn bar is used each sequence of bars with use a different color.
o stacked (boolean) whether or not to tread values as in a stacked bar chart
o to
o stretch (boolean)
o }
**
= (object) path element of the popup
> Usage
| r.barchart(0, 0, 620, 260, [76, 70, 67, 71, 69], {})
\*/
function
HBarchart
(
paper
,
x
,
y
,
width
,
height
,
values
,
opts
)
{
opts
=
opts
||
{};
var
chartinst
=
this
,
type
=
opts
.
type
||
"
square
"
,
gutter
=
parseFloat
(
opts
.
gutter
||
"
20%
"
),
chart
=
paper
.
set
(),
bars
=
paper
.
set
(),
covers
=
paper
.
set
(),
covers2
=
paper
.
set
(),
total
=
Math
.
max
.
apply
(
Math
,
values
),
stacktotal
=
[],
multi
=
0
,
colors
=
opts
.
colors
||
chartinst
.
colors
,
len
=
values
.
length
;
if
(
Raphael
.
is
(
values
[
0
],
"
array
"
))
{
total
=
[];
multi
=
len
;
len
=
0
;
for
(
var
i
=
values
.
length
;
i
--
;)
{
bars
.
push
(
paper
.
set
());
total
.
push
(
Math
.
max
.
apply
(
Math
,
values
[
i
]));
len
=
Math
.
max
(
len
,
values
[
i
].
length
);
}
if
(
opts
.
stacked
)
{
for
(
var
i
=
len
;
i
--
;)
{
var
tot
=
0
;
for
(
var
j
=
values
.
length
;
j
--
;)
{
tot
+=+
values
[
j
][
i
]
||
0
;
}
stacktotal
.
push
(
tot
);
}
}
for
(
var
i
=
values
.
length
;
i
--
;)
{
if
(
values
[
i
].
length
<
len
)
{
for
(
var
j
=
len
;
j
--
;)
{
values
[
i
].
push
(
0
);
}
}
}
total
=
Math
.
max
.
apply
(
Math
,
opts
.
stacked
?
stacktotal
:
total
);
}
total
=
(
opts
.
to
)
||
total
;
var
barheight
=
Math
.
floor
(
height
/
(
len
*
(
100
+
gutter
)
+
gutter
)
*
100
),
bargutter
=
Math
.
floor
(
barheight
*
gutter
/
100
),
stack
=
[],
Y
=
y
+
bargutter
,
X
=
(
width
-
1
)
/
total
;
!
opts
.
stacked
&&
(
barheight
/=
multi
||
1
);
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
stack
=
[];
for
(
var
j
=
0
;
j
<
(
multi
||
1
);
j
++
)
{
var
val
=
multi
?
values
[
j
][
i
]
:
values
[
i
],
bar
=
finger
(
x
,
Y
+
barheight
/
2
,
Math
.
round
(
val
*
X
),
barheight
-
1
,
false
,
type
,
null
,
paper
).
attr
({
stroke
:
"
none
"
,
fill
:
colors
[
multi
?
j
:
i
]});
if
(
multi
)
{
bars
[
j
].
push
(
bar
);
}
else
{
bars
.
push
(
bar
);
}
bar
.
x
=
x
+
Math
.
round
(
val
*
X
);
bar
.
y
=
Y
+
barheight
/
2
;
bar
.
w
=
Math
.
round
(
val
*
X
);
bar
.
h
=
barheight
;
bar
.
value
=
+
val
;
if
(
!
opts
.
stacked
)
{
Y
+=
barheight
;
}
else
{
stack
.
push
(
bar
);
}
}
if
(
opts
.
stacked
)
{
var
cvr
=
paper
.
rect
(
x
,
stack
[
0
].
y
-
stack
[
0
].
h
/
2
,
width
,
barheight
).
attr
(
chartinst
.
shim
);
covers2
.
push
(
cvr
);
cvr
.
bars
=
paper
.
set
();
var
size
=
0
;
for
(
var
s
=
stack
.
length
;
s
--
;)
{
stack
[
s
].
toFront
();
}
for
(
var
s
=
0
,
ss
=
stack
.
length
;
s
<
ss
;
s
++
)
{
var
bar
=
stack
[
s
],
cover
,
val
=
Math
.
round
((
size
+
bar
.
value
)
*
X
),
path
=
finger
(
x
,
bar
.
y
,
val
,
barheight
-
1
,
false
,
type
,
1
,
paper
);
cvr
.
bars
.
push
(
bar
);
size
&&
bar
.
attr
({
path
:
path
});
bar
.
w
=
val
;
bar
.
x
=
x
+
val
;
covers
.
push
(
cover
=
paper
.
rect
(
x
+
size
*
X
,
bar
.
y
-
bar
.
h
/
2
,
bar
.
value
*
X
,
barheight
).
attr
(
chartinst
.
shim
));
cover
.
bar
=
bar
;
size
+=
bar
.
value
;
}
Y
+=
barheight
;
}
Y
+=
bargutter
;
}
covers2
.
toFront
();
Y
=
y
+
bargutter
;
if
(
!
opts
.
stacked
)
{
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
for
(
var
j
=
0
;
j
<
(
multi
||
1
);
j
++
)
{
var
cover
=
paper
.
rect
(
x
,
Y
,
width
,
barheight
).
attr
(
chartinst
.
shim
);
covers
.
push
(
cover
);
cover
.
bar
=
multi
?
bars
[
j
][
i
]
:
bars
[
i
];
cover
.
value
=
cover
.
bar
.
value
;
Y
+=
barheight
;
}
Y
+=
bargutter
;
}
}
chart
.
label
=
function
(
labels
,
isRight
)
{
labels
=
labels
||
[];
this
.
labels
=
paper
.
set
();
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
for
(
var
j
=
0
;
j
<
multi
;
j
++
)
{
var
label
=
paper
.
labelise
(
multi
?
labels
[
j
]
&&
labels
[
j
][
i
]
:
labels
[
i
],
multi
?
values
[
j
][
i
]
:
values
[
i
],
total
),
X
=
isRight
?
bars
[
i
*
(
multi
||
1
)
+
j
].
x
-
barheight
/
2
+
3
:
x
+
5
,
A
=
isRight
?
"
end
"
:
"
start
"
,
L
;
this
.
labels
.
push
(
L
=
paper
.
text
(
X
,
bars
[
i
*
(
multi
||
1
)
+
j
].
y
,
label
).
attr
(
txtattr
).
attr
({
"
text-anchor
"
:
A
}).
insertBefore
(
covers
[
0
]));
if
(
L
.
getBBox
().
x
<
x
+
5
)
{
L
.
attr
({
x
:
x
+
5
,
"
text-anchor
"
:
"
start
"
});
}
else
{
bars
[
i
*
(
multi
||
1
)
+
j
].
label
=
L
;
}
}
}
return
this
;
};
chart
.
hover
=
function
(
fin
,
fout
)
{
covers2
.
hide
();
covers
.
show
();
fout
=
fout
||
function
()
{};
covers
.
mouseover
(
fin
).
mouseout
(
fout
);
return
this
;
};
chart
.
hoverColumn
=
function
(
fin
,
fout
)
{
covers
.
hide
();
covers2
.
show
();
fout
=
fout
||
function
()
{};
covers2
.
mouseover
(
fin
).
mouseout
(
fout
);
return
this
;
};
chart
.
each
=
function
(
f
)
{
if
(
!
Raphael
.
is
(
f
,
"
function
"
))
{
return
this
;
}
for
(
var
i
=
covers
.
length
;
i
--
;)
{
f
.
call
(
covers
[
i
]);
}
return
this
;
};
chart
.
eachColumn
=
function
(
f
)
{
if
(
!
Raphael
.
is
(
f
,
"
function
"
))
{
return
this
;
}
for
(
var
i
=
covers2
.
length
;
i
--
;)
{
f
.
call
(
covers2
[
i
]);
}
return
this
;
};
chart
.
click
=
function
(
f
)
{
covers2
.
hide
();
covers
.
show
();
covers
.
click
(
f
);
return
this
;
};
chart
.
clickColumn
=
function
(
f
)
{
covers
.
hide
();
covers2
.
show
();
covers2
.
click
(
f
);
return
this
;
};
chart
.
push
(
bars
,
covers
,
covers2
);
chart
.
bars
=
bars
;
chart
.
covers
=
covers
;
return
chart
;
};
Raphael
.
fn
.
hbarchart
=
function
(
x
,
y
,
width
,
height
,
values
,
opts
)
{
return
new
HBarchart
(
this
,
x
,
y
,
width
,
height
,
values
,
opts
);
};
})();
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