Comments (3)
Using the current camera system, resetting to a particular zoom/pan level might require initializing the camera with a single instantaneous zoom/pan interaction that represents the previous incremental zooming/panning.
https://github.com/ismms-himc/clustergrammer-gl/blob/master/src/cameras/camera_interaction.js
from clustergrammer-gl.
Also, slow down zooming a little by default (maybe allow this to be adjusted by users).
from clustergrammer-gl.
Camera update notes (paraphrased from gitter channel @rreusser comments):
Using d3-zoom
the main code is here: https://observablehq.com/@rreusser/regl-tools#persistentZoom
function persistentZoom (xScale, yScale, originalXScale, originalYScale, callback) {
return d3.zoom().on('zoom', function () {
let range
let t = d3.event.transform;
range = xScale.range().map(t.invertX, t);
xScale.domain(originalXScale.domain())
xScale.domain(range.map(xScale.invert, xScale));
range = yScale.range().map(t.invertY, t);
yScale.domain(originalYScale.domain())
yScale.domain(range.map(yScale.invert, yScale));
});
}
note, the scales are d3 scales (see scale definitions under sample usage)
let xScale = d3.scaleLinear()
.domain([-3, 3])
.range([viewport.margin.l, viewport.width - viewport.margin.r])
.clamp(true);
let yScale = constrainLinearScaleAspectRatio(
d3.scaleLinear()
.domain([-1.5, 1.5])
.range([viewport.height - viewport.margin.b, viewport.margin.t])
.clamp(true),
xScale, 1);
usage looks like this
svg.call(
persistentZoom(currentXScale, currentYScale, xScale, yScale)
.scaleExtent([0.01, 10000])
.on('zoom.plot', () => (dirty = true))
);
Using the d3 scales with webgl is a different manner, the function below translates the scales into a 2d view matrix that can be used in webgl
https://observablehq.com/@rreusser/regl-tools#createReglViewportConfiguration
function createReglViewportConfiguration (regl) {
const viewport3 = mat3create();
let command = regl({
scissor: {
enable: true,
box: {
x: (ctx, props) => ctx.pixelRatio * props.margin.l,
y: (ctx, props) => ctx.pixelRatio * props.margin.b,
width: (ctx, props) => ctx.framebufferWidth - ctx.pixelRatio * (props.margin.r + props.margin.l),
height: (ctx, props) => ctx.framebufferHeight - ctx.pixelRatio * (props.margin.t + props.margin.b)
}
},
viewport: {
x: (ctx, props) => ctx.pixelRatio * props.margin.l,
y: (ctx, props) => ctx.pixelRatio * props.margin.b,
width: (ctx, props) => ctx.framebufferWidth - ctx.pixelRatio * (props.margin.r + props.margin.l),
height: (ctx, props) => ctx.framebufferHeight - ctx.pixelRatio * (props.margin.t + props.margin.b)
},
uniforms: {
viewportResolution: (ctx, props) => [ctx.viewportWidth, ctx.viewportHeight],
framebufferResolution: ctx => [ctx.framebufferWidth, ctx.framebufferHeight],
inverseViewportResolution: (ctx, props) => [1 / ctx.viewportWidth, 1 / ctx.viewportHeight],
inverseFramebufferResolution: ctx => [1 / ctx.framebufferWidth, 1 / ctx.framebufferHeight],
}
});
return function (viewport, callback) {
command(viewport, callback);
}
}
from clustergrammer-gl.
Related Issues (20)
- Voronoi Spatial Single Cell Data HOT 1
- improve dendrogram behavior and viz HOT 1
- value-based-category histograms for clusters
- callback function on common interactions
- custom matrix tile color scheme HOT 2
- zooming breaks with symmetrical matrix of 200x200 size HOT 1
- tooltip overflow HOT 2
- slow down zooming scroll speed
- control panel not rendering correctly in some browsers HOT 1
- toggle on/off Harmonizome gene lookup HOT 2
- Stable sorting on reordering HOT 1
- Make Observable HQ Improvements
- gene box plot across categories
- Tooltip to get visible rows/cols by clicking heatmap
- data download and metadata/categories button HOT 1
- normalization section in control panel
- Hdbscan JS
- npm packaging HOT 2
- install on local machine HOT 1
- Rendering error under React HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clustergrammer-gl.