Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hub
ViralHostRangeDB
Commits
51d25297
Commit
51d25297
authored
Oct 01, 2019
by
Bryan BRANCOTTE
Browse files
Adding color on the legend
parent
71856b08
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/viralhostrange/viralhostrangedb/views.py
View file @
51d25297
...
...
@@ -674,6 +674,13 @@ def panda_color_mapping(v):
return
''
def
panda_legend_color_mapping
(
v
):
try
:
return
panda_color_mapping
(
models
.
GlobalViralHostResponseValue
.
objects
.
get
(
name
=
v
).
value
)
except
ValueError
:
return
""
def
download_responses
(
request
):
form
=
forms
.
BrowseForm
(
user
=
request
.
user
,
...
...
@@ -767,6 +774,7 @@ def download_responses(request):
df_data
=
df_data
.
style
.
applymap
(
func
=
panda_color_mapping
)
df_data
.
to_excel
(
writer
)
df_legend
=
df_legend
.
style
.
applymap
(
func
=
panda_legend_color_mapping
)
df_legend
.
to_excel
(
writer
,
startcol
=
0
,
startrow
=
len
(
row_header
)
+
3
)
if
len
(
options
)
>
0
:
df_options
.
to_excel
(
writer
,
startcol
=
0
,
startrow
=
len
(
row_header
)
+
3
+
len
(
legend_name
)
+
3
,
index
=
None
)
...
...
@@ -971,6 +979,7 @@ def host_or_virus_download(request, is_host, instance):
df_data
=
df_data
.
style
.
applymap
(
func
=
panda_color_mapping
)
df_data
.
to_excel
(
writer
,
startcol
=
0
,
startrow
=
2
)
df_legend
=
df_legend
.
style
.
applymap
(
func
=
panda_legend_color_mapping
)
df_legend
.
to_excel
(
writer
,
startcol
=
0
,
startrow
=
len
(
row_header
)
+
3
+
2
)
if
len
(
options
)
>
0
:
df_options
.
to_excel
(
writer
,
startcol
=
0
,
startrow
=
len
(
row_header
)
+
3
+
len
(
legend_name
)
+
3
+
2
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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