Skip to content

Commit

Permalink
starting on custom layout other than "time" fixes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
cpietsch committed May 8, 2023
1 parent 8013664 commit 5b24b8d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
7 changes: 5 additions & 2 deletions js/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function Canvas() {

timeline.init(timeDomain);
x.domain(canvasDomain);
canvas.makeScales();
//canvas.makeScales();

// add preview pics
data.forEach(function (d, i) {
Expand Down Expand Up @@ -302,7 +302,8 @@ function Canvas() {
}
});

canvas.project();
//canvas.makeScales();
//canvas.project();
animate();

// selectedImage = data.find(d => d.id == 88413)
Expand Down Expand Up @@ -480,6 +481,8 @@ function Canvas() {

canvas.setMode = function (mode) {
state.mode = mode;
timeline.setDisabled(mode != "time");
canvas.makeScales();
canvas.project();
};

Expand Down
20 changes: 14 additions & 6 deletions js/viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ function init() {

if (config.loader.layouts) {
initLayouts(config);
} else {
canvas.setMode("time");
}

LoaderSprites()
Expand Down Expand Up @@ -134,12 +136,20 @@ function init() {

config.loader.layouts.forEach((d, i) => {
d.title = d.title.toLowerCase();
if (d.title === "time") return;
d3.csv(baseUrl.path + d.url, function (tsne) {
canvas.addTsneData(d.title, tsne);
});
if (d.title === "time") {
canvas.setMode(d.title);
} else {
d3.csv(baseUrl.path + d.url, function (tsne) {
canvas.addTsneData(d.title, tsne);
if (i == 0) canvas.setMode(d.title);
});
}
});

if (config.loader.layouts.length == 1) {
d3.select(".navi").classed("hide", true);
}

var s = d3.select(".navi").selectAll(".button").data(config.loader.layouts);
s.enter()
.append("div")
Expand All @@ -148,9 +158,7 @@ function init() {
.text((d) => d.title);

s.on("click", function (d) {
console.log(d.title);
canvas.setMode(d.title);
timeline.setDisabled(d.title != "time");
d3.selectAll(".navi .button").classed(
"active",
(d) => d.title == canvas.getMode()
Expand Down

0 comments on commit 5b24b8d

Please sign in to comment.