I want to make a timeline where the user can choose between scrolling to zoom or select a region to zoom.
There are some examples of the first like:
https://bl.ocks.org/mbostock/4015254
Or zooming in on a area with brush:
https://bl.ocks.org/mbostock/f48fcdb929a620ed97877e4678ab15e6
But I cannot find an example that does both. How can I do both? Or are there any examples that I missed?
Brushable and zoomable timeline with d3
1.3k views Asked by MM 2x13 At
1
There are 1 answers
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in D3.JS
- issue with Loading TopoJSON File in D3.js: Map Not Displaying Properly
- Nothing is shown when running a d3 sample code
- Trouble setting fixed nodes in force graph: Fixing nodes break links (D3)
- Visx Streamgraph Custom Typing
- D3 - Tree of life plot not showing data
- D3.js - Grouped Bar Chart - Error Updating Input Data
- D3.js transition only works for the deleted Elements
- Anybody knows why the tooltip doesn't show up where and how I want to?
- Translate coordinates of label in d3 org chart
- Facing issue while implementing Drag behaviour for D3 nodes
- D3.js forcegraph in Shiny
- Tring to render label on nodes and edges in a d3 force graph, but they are not visible although available under dom tree
- D3.js Error transition arc "<path> attribute d: Expected arc flag ('0' or '1'),"
- GeoJSON MultiPolygon Inversion Works for All Federal Districts of Russia Except Siberia in D3.js Map
- Add interactive tooltips in networkD3 package in R
Related Questions in ZOOMING
- Why is the zoom feature of my game in pygame not working?
- OpenLayers: Zoom level cropping VectorTile layer - how to fix?
- mapView.fitToBounds() method from highcharts not working
- Zoom Web SDK - "Invalid apiKey/sdkKey and/or signature"
- React zooming and dragging image
- Using SciPy ndimage.zoom on an array with nan values
- Removing blurred mathematical expressions into a PDF file and make it vectorized when zooming
- UIScrollView is unexpectedly initially zoomed in in UIViewControllerRepresentable
- Zooming into defs in force-directed graphs
- Layout breaks on zoom in with "cmd +" but not with zoom in with mousepad
- Image not being dragged correctly when zoomed in
- Prevent shiny reactivity to re-render a plot when zooming the screen
- d3 zoomable circle packaging broken zoom
- App with Imageview scale in Android Studio emulator Small Device breaks without error
- Resolving Coordinate Misalignment in Zoomable PictureBox
Related Questions in BRUSH
- How to save the brush event when hovering over elements with their own events
- brush overlaps events on other elements
- brush in shiny is resetting despite resetOnNew=FALSE. What can I do about it?
- Can I programmatically brush a plot in shiny? Can I have the same brush multiple times?
- How to alter SVG elements in React js and use Recharts at the same time?
- How to set a background colour in xaml.cs file?
- how to preserve brush job when image size is changed?(with Konva JS)
- Why are there small black dots on the lines I draw?
- How to add highlighting of brused points on scatter3 in MATLAB
- How to save matlab figure with brushed elements
- D3js how to select paths and highlight them with a brush function
- Converting Brush to SolidColorBrush WinUi 3
- R shiny brush can not be removed by any means. Can anyone help me?
- WPF XAML Apply Opacity to Brush Only
- Changing DrawingImage brush binded to DynamicResource
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
This is not the most straightforward thing to implement. As you will notice, the brush based zooming does not rely on
d3.zoombut instead performs the zooming via listeners that fire on events to do whatever is needed to scale the axes and move the plot elements accordingly.In comparison, all the scrolling based zoom examples typically rely on
d3.zoomwhich utilizes ad3.zoom()behavior that keeps track of all the transforms performed on the plot while panning/zooming and is solely responsible for updating the various chart elements. The difficulty lies in the fact that the 2 approaches are quite different and if you manually change the chart view via brushing, you need to figure out a way to update the internal zoom transform thatd3.zoomreferences so that it is aware of the changes made via the brush based zoom events.This is not at all easy to do because
d3.zoomwas not designed to be fed information from elsewhere and the internal record of transforms that were performed are not meant to be updateable/mutable. You can update the transform viaselection.call(zoom.transform, d3.zoomIdentity);but that unfortunately also fires a whole bunch of events related to the actual zoom behavior, which is not something you want since you already handled all the zoom behavior with your brush based zoom. An ugly, but effective workaround that I was able to use to reset the zoom transform was to mutate the actual.__zoomfield of the DOM node that is bound to thed3.zoombehavior as follows:So for example: If you want a 2D brush for rectangle zooming, but also
d3.zoombased zooming for panning and mouse-scrolling, then anytime you use the 2D brush to zoom, you will want to reset the d3.zoom transform back to the identity transform as above. This prevents and ugly and jarring jitter in panning/scrolling response when chaining 2D brush based zooming actions with panning/mouse-scrolling actions due to the transform on record withd3.zoomnot being in-sync with the view on display (due to the 2D brush based zoom changing the view without d3.zoom's knowledge).Here is something else that is important to note:
d3.zoomhas a limitation in that it currently only supports a common zoom scale for both X and Y axes (Source). This unfortunately means that there is no way to map a 2-D brush based zoom to ad3.zoombased approach since 2D brush based zooming produces different zoom scaling in X and Y. If you want to do things with minimal issues, using a consistent approach, I'd recommend looking into using d3.xyzoom. This is a fork ofd3.zoomthat implements support for different scales for X and Y axes. This would enable you to calculate the corresponding X and Y zoom scaling and translation values for any 2D brush selection, which you could then feed intod3.zoom, thus enabling you to perform all the zooming using a common approach (which also results in the least amount of code duplication).That being said, if you are solely interested in a 1-D brush based zoom, you should be able to map that to a d3.zoom approach so that you don't have to deal with 2 different paths for handling the view and scaling of all the axes and other graphical elements in your chart. Here is a good example of this:
https://bl.ocks.org/mbostock/34f08d5e11952a80609169b7917d4172
I apologize for the length of this post and if it is a bit rambling. I am working on putting together a block on my work in a couple of days and I'll try to circle back here and post a link when I get around to doing so. I only started learning D3 a week ago, so I'm learning along the way.