From cc7ff8a6a3717f9baccd3fbef63f5cdb0793f748 Mon Sep 17 00:00:00 2001 From: Christopher Pietsch Date: Tue, 23 May 2023 09:41:54 +0200 Subject: [PATCH] added scale factor for each layout #30 --- js/canvas.js | 10 ++++++---- js/viz.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/js/canvas.js b/js/canvas.js index f910dcefd..d47daa572 100644 --- a/js/canvas.js +++ b/js/canvas.js @@ -103,10 +103,10 @@ function Canvas() { var timelineData; var stage, stage1, stage2, stage3, stage4, stage5; var timelineHover = false; - var tsne = []; var tsneIndex = {}; + var tsneScale = {} - function canvas() {} + function canvas() { } canvas.rangeBand = function () { return rangeBand; @@ -311,8 +311,9 @@ function Canvas() { state.init = true; }; - canvas.addTsneData = function (name, d) { + canvas.addTsneData = function (name, d, scale) { tsneIndex[name] = {}; + tsneScale[name] = scale; var clean = d.map(function (d) { return { id: d.id, @@ -696,8 +697,9 @@ function Canvas() { canvas.project = function () { sleep = false; + var scaleFactor = state.mode == "time" ? 0.9 : tsneScale[state.mode] || 0.5; data.forEach(function (d) { - d.scaleFactor = state.mode == "time" ? 0.9 : 0.5; + d.scaleFactor = scaleFactor; d.sprite.scale.x = d.scaleFactor; d.sprite.scale.y = d.scaleFactor; if (d.sprite2) { diff --git a/js/viz.js b/js/viz.js index 7f2ff4260..ce64d46cc 100644 --- a/js/viz.js +++ b/js/viz.js @@ -140,7 +140,7 @@ function init() { canvas.setMode(d.title); } else { d3.csv(baseUrl.path + d.url, function (tsne) { - canvas.addTsneData(d.title, tsne); + canvas.addTsneData(d.title, tsne, d.scale); if (i == 0) canvas.setMode(d.title); }); }