forked from nomic-ai/deepscatter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wehi-coords.html
179 lines (173 loc) · 5.17 KB
/
wehi-coords.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<style>
.ttooltip {
z-index: 99;
}
.legend-div {
display: flex;
align-items: center;
margin: 2px;
padding: 5px;
}
#color-legend {
left: 0;
flex-direction: column;
align-items: right;
justify-content: right;
grid-template-columns: repeat(3, 1fr);
display: grid;
}
.color-marker {
width: 20px;
height: 20px;
margin-right: 5px;
border: 1px solid #ccc;
}
.overlay {
position: absolute;
bottom: 0;
background-color: rgba(0, 0, 0, 0.1);
z-index: 99;
}
</style>
<body>
<h1>WEHI & Pubmed Landscape</h1>
<div id="datestring"></div>
<!-- <input id="date" title="date selector" type="range" min="-1800" max="1500" /> -->
<div id="deepscatter">
<div>
<div id="left-overlay" class="overlay"></div>
<div id="color-legend" class="overlay"></div>
</div>
</div>
</body>
<head>
<style>
dt {
float: left;
clear: left;
width: 90px;
font-weight: bold;
color: rgb(128, 19, 0);
}
dt::after {
content: ':';
}
dd {
margin: 0 0 0 80px;
padding: 0 0 0.5em 0;
width: 180px;
}
</style>
</head>
<script type="module">
import Scatterplot from './src/deepscatter';
import { select } from 'd3-selection';
window.select = select; // For the click function below.
const prefs = {
source_url: '/tiles_wehionly_wehicoords',
max_points: 750000, // a full cap.
alpha: 100000, // Target saturation for the full page.
zoom_balance: 0.35, // Rate at which points increase size. https://observablehq.com/@bmschmidt/zoom-strategies-for-huge-scatterplots-with-three-js
//point_size: 10, // Default point size before application of size scaling
point_size: 4,
background_color: '#FFFFFF',
zoom_align: 'right',
click_function:
"select('#ident').html(JSON.stringify(datum, undefined, 2))",
background_options: {
size: 0.5,
mouseover: true,
opacity: 0.01,
},
zoom: {
bbox: {
x: [-120, 120],
y: [-120, 120]
}
},
encoding: {
foreground: {
field: 'labels',
lambda: d => d !== 'unlabeled' //
},
color: {
field: 'labels',
// range: 'category10',
range: ["lightgrey", "#549E79", "#8FB0FF", "#008941", "black", "#7A4900", "#BA0900", "#B79762", "#aeaa00", "#FF2F80", "#6F0062", "#004D43", "#5B4534", "#FF4A46", "#3B5DFF", "#1B4400", "#FF9408", "#b65141", "#0089A3", "#E83000", "#006FA6", "#A4E804", "#C20078", "#FF90C9", "#009271", "#4FC601", "#00C2A0", "#FF34FF", "#00FECF", "#6508ba", "#CC0744", "#1CE6FF", "#D790FF", "#BC23FF", "#FFB500", "#5A0007", "#0000A6"],
"domain": ["unlabeled", "education", "immunology", "chemistry", "cancer", "infectious", "psychiatry", "microbiology", "neuroscience", "nursing", "virology", "pediatric", "pharmacology", "bioinformatics", "veterinary", "genetics", "pathology", "biochemistry", "environment", "physiology", "surgery", "ophthalmology", "computation", "healthcare", "neurology", "nutrition", "engineering", "ecology", "radiology", "ethics", "anesthesiology", "cardiology", "dermatology", "physics", "gynecology", "psychology", "material"]
},
x: {
field: 'x',
transform: 'literal',
},
y: {
field: 'y',
transform: 'literal',
},
//size: {
// field: 'WEHI-affiliated',
// range: [1, 0.1],
// domain: ['True', 'False'],
//},
},
};
const scatterplot = new Scatterplot('#deepscatter');
const first_draw = scatterplot.plotAPI(prefs);
window.plot = scatterplot; // For debugging
let cycle = 0;
const width = 600;
function redo_scale() {
const scale = scatterplot._renderer.aes.store.color.current.scale;
const domain = scale.domain();
const range = scale.range();
select('#color-legend')
.selectAll('div')
.data(domain)
.join('div')
.attr('class', 'legend-div')
.html((d) => `
<span class="color-marker" style="background-color: ${scale(d)}"></span>
${d}
`);
}
first_draw.then(() => {
const holder = select('#left-overlay');
// const buttons = holder
// .selectAll('button')
// .data([
// 'WEHI with All',
// 'All'
// ]);
redo_scale();
// buttons
// .enter()
// .append('div')
// .style('display', 'flex')
// .style('flex', 'row')
// .append('button')
// .text((d) => d)
// .on('click', function (d) {
// const button = select(this);
// const field = button.text();
// if (field === "WEHI with All") {
// scatterplot
// .plotAPI({
// alpha: 100000,
// max_points: 10000000,
// point_size: 5,
// encoding: {
// background_options: {
// size: 0.1,
// },
// filter: {
// field: 'WEHI-affiliated',
// lambda: d => d === 'True'
// }
// },
// })
// } else if (field === "All") {
// scatterplot.plotAPI(prefs)
// }
// });
});
</script>