Skip to content

Commit 2bb5b9d

Browse files
committed
Add regions to dashboard
1 parent 538fd1a commit 2bb5b9d

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

resources/report/dashboard/script.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ document.querySelectorAll(".tab-link").forEach(button => {
1212
// Initialize selection widgets
1313
const choicesInstances = {};
1414

15+
choicesInstances["region-select"] = new Choices("#region-select", {
16+
searchEnabled: false,
17+
removeItemButton: true,
18+
shouldSort: false,
19+
itemSelectText: "",
20+
placeholder: false
21+
});
22+
document.getElementById("region-select").addEventListener("change", updateChart);
23+
24+
1525
choicesInstances["source-select"] = new Choices("#source-select", {
1626
searchEnabled: false,
1727
removeItemButton: true,
@@ -102,13 +112,17 @@ function getSelectedValues(id) {
102112
}
103113

104114
function updateChart() {
115+
const selectedRegions = getSelectedValues("region-select");
105116
const selectedSources = getSelectedValues("source-select");
106117
const selectedparams = getSelectedValues("param-select");
107118
const selectedMetrics = getSelectedValues("metric-select");
108119

109120
const newSpec = JSON.parse(JSON.stringify(spec));
110121
const filters = [];
111122

123+
if (selectedRegions.length > 0) {
124+
filters.push({ field: "region", oneOf: selectedRegions });
125+
}
112126
if (selectedSources.length > 0) {
113127
filters.push({ field: "source", oneOf: selectedSources });
114128
}

resources/report/dashboard/template.html.jinja2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@
107107
</p>
108108
</div>
109109
<div class="controls">
110+
<div class="control-group">
111+
<label>Regions(s)</label>
112+
<select id="region-select">
113+
{% for region in regions %}
114+
<option value="{{region}}"{% if region == 'all' %} selected{% endif %}>{{region}}</option>
115+
{% endfor %}
116+
</select>
117+
</div>
110118
<div class="control-group">
111119
<label>Source(s)</label>
112120
<select id="source-select" multiple>

workflow/scripts/report_experiment_dashboard.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def main(args):
5353
sources = df["source"].unique()
5454
params = df["param"].unique()
5555
metrics = df["metric"].unique()
56+
regions = df["region"].unique()
5657

5758
# get json string to embed in the HTML
5859
df_json = df.to_json(orient="records", lines=False)
@@ -76,6 +77,7 @@ def main(args):
7677
sources=sources,
7778
params=params,
7879
metrics=metrics,
80+
regions=regions,
7981
header_text=args.header_text,
8082
)
8183
LOG.info("Size of generated HTML: %d bytes", len(html.encode("utf-8")))

0 commit comments

Comments
 (0)