Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
limbra
limbra
Commits
930a30dd
Commit
930a30dd
authored
Jan 19, 2016
by
LE GAC Renaud
Browse files
Fix bugs in the graph method do_linechart, do_empty.
parent
005a7cf8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
modules/graph_tools.py
modules/graph_tools.py
+16
-6
No files found.
modules/graph_tools.py
View file @
930a30dd
...
@@ -55,7 +55,7 @@ def do_empty(db, selector, target=None):
...
@@ -55,7 +55,7 @@ def do_empty(db, selector, target=None):
months
=
to_datetime
([
"%i-%02i"
%
(
year
,
i
)
for
i
in
xrange
(
1
,
13
)])
months
=
to_datetime
([
"%i-%02i"
%
(
year
,
i
)
for
i
in
xrange
(
1
,
13
)])
df
=
DataFrame
([
0
]
*
12
*
nyear
,
index
=
months
)
df
=
DataFrame
([
0
]
*
12
*
nyear
,
index
=
months
)
ax
=
df
.
plot
(
legend
=
False
,
x_compat
=
True
,
ylim
=
(
0
,
100
),
ax
=
target
)
ax
=
df
.
plot
(
legend
=
False
,
x_compat
=
True
,
ax
=
target
)
do_tick
(
ax
)
do_tick
(
ax
)
return
ax
return
ax
...
@@ -124,7 +124,7 @@ def do_linechart(publications, selector, target=None):
...
@@ -124,7 +124,7 @@ def do_linechart(publications, selector, target=None):
setrows
=
db
(
query
)
setrows
=
db
(
query
)
if
setrows
.
count
()
==
0
:
if
setrows
.
count
()
==
0
:
return
do_empty
(
db
,
selector
)
return
do_empty
(
db
,
selector
,
target
=
target
)
count
=
publications
.
id
.
count
()
count
=
publications
.
id
.
count
()
rows
=
setrows
.
select
(
publications
.
submitted
,
rows
=
setrows
.
select
(
publications
.
submitted
,
...
@@ -133,7 +133,7 @@ def do_linechart(publications, selector, target=None):
...
@@ -133,7 +133,7 @@ def do_linechart(publications, selector, target=None):
orderby
=
group_by
)
orderby
=
group_by
)
# build the list of data points
# build the list of data points
data
,
y
=
[],
0.
data
,
y
,
prev_year
=
[],
0.
,
None
for
row
in
rows
:
for
row
in
rows
:
submitted
=
row
.
publications
.
submitted
submitted
=
row
.
publications
.
submitted
...
@@ -145,15 +145,25 @@ def do_linechart(publications, selector, target=None):
...
@@ -145,15 +145,25 @@ def do_linechart(publications, selector, target=None):
else
:
else
:
y
=
row
[
count
]
y
=
row
[
count
]
# a continous line when month axis is selected
# a contin
u
ous line when month axis is selected
if
is_month
:
if
is_month
:
data
.
append
([
submitted
[:
7
],
y
])
data
.
append
([
submitted
[:
7
],
y
])
# a step line for the year axis
# a step line for the year axis
# fill properly holes between year
else
:
else
:
year
=
int
(
submitted
[:
4
])
year
=
int
(
submitted
[:
4
])
data
.
append
([
"%i-06"
%
(
year
-
1
),
y
])
data
.
append
([
"%i-06"
%
year
,
y
])
if
prev_year
is
not
None
and
prev_year
+
1
!=
year
:
for
x
in
xrange
(
prev_year
+
1
,
year
):
n
=
(
y
if
is_cumu
else
0.
)
data
.
append
([
"%i-01-01"
%
x
,
n
])
data
.
append
([
"%i-12-31"
%
x
,
n
])
data
.
append
([
"%i-01-01"
%
year
,
y
])
data
.
append
([
"%i-12-31"
%
year
,
y
])
prev_year
=
year
# instantiate the dataframe
# instantiate the dataframe
# the index is the time
# the index is the time
...
...
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