Skip to content

Commit 95c87f9

Browse files
committed
Initial version of the new landing page with server side filtering
1 parent cff24bd commit 95c87f9

17 files changed

Lines changed: 1910 additions & 1300 deletions

File tree

client/package.json

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,36 @@
88
"lint": "vue-cli-service lint"
99
},
1010
"dependencies": {
11-
"@girder/components": "git+https://github.com/girder/girder_web_components.git",
11+
"@girder/components": "git+https://github.com/girder/girder_web_components.git#matthew_playground",
12+
"core-js": "^2.6.5",
13+
"d3": "^5.12.0",
1214
"lodash.debounce": "^4.0.8",
13-
"papaparse": "^5.0.0",
14-
"resonantgeo": "git+ssh://git@kwgitlab.kitware.com:open-geoscience/resonantgeo.git",
15-
"stylus": "^0.54.5",
16-
"stylus-loader": "^3.0.2",
15+
"resonantgeo": "git+ssh://git@kwgitlab.kitware.com:open-geoscience/resonantgeo.git#no_vuetify",
1716
"sunburst-chart": "^1.7.0",
18-
"vue": "^2.6.8",
19-
"vue-async-computed": "^3.5.1",
17+
"vue": "^2.6.10",
2018
"vue-google-charts": "^0.3.2",
21-
"vue-nice-scrollbar": "^2.0.1",
2219
"vue-numeral-filter": "^1.1.1",
23-
"vue-router": "^3.0.2",
24-
"vue-utilities": "git+https://github.com/Kitware/vue-utilities.git",
25-
"vuetify": "^1.5.4",
20+
"vue-router": "^3.0.3",
21+
"vue-utilities": "git+https://github.com/Kitware/vue-utilities.git#vuetify-2",
22+
"vuetify": "^2.0.0",
2623
"vuex": "^3.0.1"
2724
},
2825
"devDependencies": {
29-
"@vue/cli-plugin-babel": "^3.6.0",
30-
"@vue/cli-plugin-eslint": "^3.6.0",
31-
"@vue/cli-service": "^3.6.0",
32-
"@vue/eslint-config-prettier": "^4.0.1",
26+
"@vue/cli-plugin-babel": "^3.11.0",
27+
"@vue/cli-plugin-eslint": "^3.11.0",
28+
"@vue/cli-service": "^3.11.0",
29+
"@vue/eslint-config-prettier": "^5.0.0",
3330
"babel-eslint": "^10.0.1",
34-
"copy-webpack-plugin": "^4.6.0",
35-
"eslint": "^5.8.0",
31+
"eslint": "^5.16.0",
3632
"eslint-plugin-prettier": "^3.1.0",
3733
"eslint-plugin-vue": "^5.0.0",
38-
"node-sass": "^4.9.0",
39-
"pug": "^2.0.3",
40-
"pug-loader": "^2.4.0",
34+
"prettier": "^1.18.2",
35+
"pug": "^2.0.4",
4136
"pug-plain-loader": "^1.0.0",
42-
"raw-loader": "^3.0.0",
43-
"sass-loader": "^7.0.1",
44-
"shader-loader": "^1.3.1",
45-
"vue-template-compiler": "^2.6.8"
37+
"sass": "^1.18.0",
38+
"sass-loader": "^7.1.0",
39+
"vue-cli-plugin-vuetify": "^0.6.3",
40+
"vue-template-compiler": "^2.6.10",
41+
"vuetify-loader": "^1.3.0"
4642
}
4743
}

client/public/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico"> -->
88
<title>ResonantEco</title>
99
<!-- TODO: bundle fonts -->
10-
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons' rel="stylesheet">
11-
<link href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" rel="stylesheet">
10+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
1211
</head>
1312
<body>
1413
<noscript>
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
<script>
2+
import * as d3 from "d3";
3+
4+
import { mapColor } from "@/util/colors";
5+
6+
export default {
7+
name: "BiomeTreemap",
8+
components: {},
9+
inject: ["girderRest"],
10+
props: {
11+
filter: {
12+
type: Object,
13+
required: false
14+
},
15+
selections: {
16+
type: Array,
17+
required: false,
18+
default: () => []
19+
}
20+
},
21+
computed: {
22+
treemapData() {
23+
if (!this.biomeCounts) {
24+
return null;
25+
}
26+
var data = {
27+
name: "biome",
28+
children: this.biomeCounts.map(biome => ({
29+
id: biome.key.replace(/ /g, "-"),
30+
name: biome.key,
31+
value: biome.count
32+
}))
33+
};
34+
return d3
35+
.hierarchy(data)
36+
.sum(d => d.value)
37+
.sort((a, b) => b.value - a.value);
38+
}
39+
},
40+
asyncComputed: {
41+
async biomeCounts() {
42+
var params = {};
43+
if (this.filter) {
44+
params["filter"] = this.filter;
45+
}
46+
var { data: meta } = await this.girderRest.get("meta", { params });
47+
return meta.biome;
48+
}
49+
},
50+
watch: {
51+
treemapData(value) {
52+
if (value) {
53+
this.update();
54+
}
55+
},
56+
selections() {
57+
this.update();
58+
}
59+
},
60+
methods: {
61+
update() {
62+
var width = this.$el.clientWidth;
63+
this.width = width;
64+
var height = this.$el.clientHeight;
65+
this.height = height;
66+
67+
var layout = d3
68+
.treemap()
69+
.tile(d3.treemapSquarify)
70+
.size([width, height])
71+
.paddingInner(2);
72+
var nodes = layout(this.treemapData);
73+
74+
var svg = d3.select(this.$el);
75+
svg
76+
.selectAll(".leaf")
77+
.data(nodes.leaves(), d => d.data.name)
78+
.join(
79+
enter => {
80+
var leaf = enter
81+
.append("div")
82+
.attr("class", "leaf")
83+
.classed(
84+
"selected",
85+
d => this.selections.indexOf(d.data.name) !== -1
86+
)
87+
.attr(
88+
"title",
89+
d =>
90+
`${d
91+
.ancestors()
92+
.reverse()
93+
.map(d => d.data.name)
94+
.join(" / ")}\n${d.value}`
95+
)
96+
.style("left", d => `${d.x0}px`)
97+
.style("top", d => `${d.y0}px`)
98+
.style("width", d => `${d.x1 - d.x0}px`)
99+
.style("height", d => `${d.y1 - d.y0}px`)
100+
.style("background-color", d => mapColor("biome", d.data.name))
101+
.on("click", d => {
102+
var index = this.selections.indexOf(d.data.name);
103+
if (index !== -1) {
104+
var selections = this.selections.slice();
105+
selections.splice(index, 1);
106+
this.$emit("update:selections", selections);
107+
} else {
108+
this.$emit("update:selections", [
109+
...this.selections,
110+
d.data.name
111+
]);
112+
}
113+
});
114+
115+
leaf
116+
.append("div")
117+
.attr("class", "leaf-title")
118+
.text(d => {
119+
if (d.y1 - d.y0 < 14) {
120+
return;
121+
}
122+
if (d.x1 - d.x0 < d.data.name.length * 10) {
123+
return;
124+
}
125+
return d.data.name;
126+
});
127+
128+
leaf
129+
.append("div")
130+
.attr("class", "leaf-value")
131+
.text(d => d.data.value);
132+
},
133+
update => {
134+
var leaf = update
135+
.classed(
136+
"selected",
137+
d => this.selections.indexOf(d.data.name) !== -1
138+
)
139+
.transition()
140+
.duration(300)
141+
.style("left", d => `${d.x0}px`)
142+
.style("top", d => `${d.y0}px`)
143+
.style("width", d => `${d.x1 - d.x0}px`)
144+
.style("height", d => `${d.y1 - d.y0}px`)
145+
.style("background-color", d => mapColor("biome", d.data.name));
146+
147+
leaf.select(".leaf-title").text(d => {
148+
if (d.y1 - d.y0 < 14) {
149+
return;
150+
}
151+
if (d.x1 - d.x0 < d.data.name.length * 10) {
152+
return;
153+
}
154+
return d.data.name;
155+
});
156+
leaf.select(".leaf-value").text(d => d.data.value);
157+
},
158+
remove => {
159+
remove
160+
.transition()
161+
.duration(300)
162+
.style("width", "0px")
163+
.style("height", "0px")
164+
.remove();
165+
}
166+
);
167+
}
168+
}
169+
};
170+
</script>
171+
172+
<template>
173+
<div class="biome-treemap"></div>
174+
</template>
175+
176+
<style lang="scss" scoped>
177+
.biome-treemap {
178+
height: 100%;
179+
position: relative;
180+
}
181+
</style>
182+
183+
<style lang="scss">
184+
.biome-treemap {
185+
overflow: hidden;
186+
187+
.leaf {
188+
position: absolute;
189+
overflow: hidden;
190+
transition: transform 0.4s;
191+
192+
&:hover {
193+
transition: transform 0.2s;
194+
transform: scale(0.98);
195+
}
196+
197+
&.selected {
198+
border: solid 2px black;
199+
}
200+
201+
.leaf-title {
202+
margin: 10px 0 0 10px;
203+
color: white;
204+
}
205+
206+
.leaf-value {
207+
margin: 0 0 0 10px;
208+
color: rgba(255, 255, 255, 0.589);
209+
font-size: 20px;
210+
}
211+
}
212+
}
213+
</style>

0 commit comments

Comments
 (0)