-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinfovis.js
41 lines (35 loc) · 1.1 KB
/
infovis.js
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
import * as d3 from "d3"
import embed from 'vega-embed';
import { legendColor } from 'd3-svg-legend'
import colorbrewer from 'colorbrewer'
var infovis = {};
const renderVegaLite = function(wid_waypoint, id, visdata, events){
try {
return embed(`#${id}`, visdata, {
tooltip: false,
actions: false,
theme: 'dark'
})
.then(result => {
result.view.addEventListener('click', function(event, item) {
events.clickHandler(item.datum)
});
}).catch(console.warn);
}
catch (error) {
throw error;
}
}
infovis.renderMatrix = function(wid_waypoint, id, visdata, events) {
return renderVegaLite(wid_waypoint, id, visdata, events);
}
infovis.renderBarChart = function(wid_waypoint, id, visdata, events) {
return renderVegaLite(wid_waypoint, id, visdata, events);
}
infovis.renderScatterplot = function(wid_waypoint, id, visdata, events) {
return renderVegaLite(wid_waypoint, id, visdata, events);
}
infovis.renderCanvasScatterplot = function(wid_waypoint, id, visdata, events) {
return renderVegaLite(wid_waypoint, id, visdata, events);
}
export default infovis;