Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
visualizer-embed
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Owen Graham
visualizer-embed
Commits
cbceb533
Verified
Commit
cbceb533
authored
3 years ago
by
Owen Graham
Browse files
Options
Downloads
Patches
Plain Diff
Send years with HTML
parent
c3f694d9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
static/script.js
+5
-28
5 additions, 28 deletions
static/script.js
templates/base.html
+1
-0
1 addition, 0 deletions
templates/base.html
visualizer.py
+8
-9
8 additions, 9 deletions
visualizer.py
with
14 additions
and
37 deletions
static/script.js
+
5
−
28
View file @
cbceb533
/**
* Known plottable years for each station.
*/
const
fetchedYears
=
{};
/**
* Fetch year options and put them in one selector.
*/
function
getYears
(
n
)
{
clearYears
(
n
);
const
station
=
selectVal
(
suffixID
(
'
station
'
,
n
));
fetchYears
(
station
,
years
=>
{
appendYears
(
years
,
n
);
});
const
years
=
recordYears
[
station
];
appendYears
(
years
,
n
);
}
/**
...
...
@@ -21,10 +15,9 @@ function boxplotGetYears() {
clearYears
(
1
);
clearYears
(
2
);
const
station
=
selectVal
(
'
station
'
);
fetchYears
(
station
,
years
=>
{
appendYears
(
years
,
1
);
appendYears
(
years
,
2
);
});
const
years
=
recordYears
[
station
];
appendYears
(
years
,
1
);
appendYears
(
years
,
2
);
}
/**
...
...
@@ -51,22 +44,6 @@ function clearYears(n) {
yearSelect
.
options
.
length
=
1
;
}
/**
* Call `callback(years)` after fetching years for the given station.
*/
function
fetchYears
(
station
,
callback
)
{
if
(
fetchedYears
.
hasOwnProperty
(
station
))
{
callback
(
fetchedYears
[
station
]);
}
else
{
fetch
(
`
${
$SCRIPT_ROOT
}
/record/years
${
paramString
({
station
})}
`
)
.
then
(
response
=>
response
.
json
())
.
then
(
years
=>
{
fetchedYears
[
station
]
=
years
;
callback
(
years
);
});
}
}
function
indexVisualize
()
{
const
params
=
{
station
:
selectVal
(
'
station
'
),
...
...
This diff is collapsed.
Click to expand it.
templates/base.html
+
1
−
0
View file @
cbceb533
...
...
@@ -8,6 +8,7 @@
<link
rel=
"stylesheet"
href=
"https://amrdc.ssec.wisc.edu/wp-test/wp-content/themes/amrdc-theme/dist/fonts/uw160/fonts.css?ver=1.0.0"
>
<script>
const
$SCRIPT_ROOT
=
{{
request
.
script_root
|
tojson
}};
const
recordYears
=
{{
g
.
record_years
|
tojson
}};
</script>
<script
defer
src=
"{{ url_for('static', filename='script.js') }}"
></script>
</head>
...
...
This diff is collapsed.
Click to expand it.
visualizer.py
+
8
−
9
View file @
cbceb533
...
...
@@ -106,14 +106,6 @@ def boxplot():
return
render_template
(
'
boxplot.html
'
)
@app.route
(
'
/record/years
'
)
def
record_years
():
"""
Return a list of years for the selected station.
"""
station
=
get_station
(
get_param
(
'
station
'
))
years
=
[
i
[
'
year
'
]
for
i
in
station
[
'
records
'
]]
return
jsonify
(
years
)
@app.route
(
'
/record/link
'
)
def
record_link
():
"""
Return the source link for the selected dataset.
"""
...
...
@@ -303,7 +295,14 @@ def savefig_response(fig):
def
populate_g
():
"""
Populate `g` with data for rendering page templates.
"""
g
.
stations
=
read_stations
()
stations
=
read_stations
()
g
.
stations
=
stations
def
id_years
(
station
):
years
=
[
record
[
'
year
'
]
for
record
in
station
[
'
records
'
]]
return
station
[
'
id
'
],
years
g
.
record_years
=
dict
(
map
(
id_years
,
stations
))
def
read_stations
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment