Comments (13)
Also need to mention https://observablehq.com/@fil/experimental-plot-tooltip-01 which partly addresses this issue.
Again it shows some problems with (the way I intercept) the creation of a faceted g to add interactive behaviors. A clean method to do this would be welcome.
from plot.
I can't give a specific date but interaction is definitely on the roadmap.
from plot.
A Voronoi mark could allow this, but more generally I'm wondering if we should have an event-based system for hover.
viewof plot
will be dedicated to the selection (or full dataset in absence of a selection). To deal with hover, we should probably create a mechanism such as Plot.plot(………).on("pointermove", …)
, at the plot (or at the mark) level?
And provide a helper function that knows how to create a tooltip (probably with a title in bold and a multiline text, both optionals).
from plot.
Thanks @Fil for adding super useful interactivity. I am using Plot via npm. Will the tooltip functionality be available from within the package anytime soon?
from plot.
I've been doing some (comparatively basic) voronoi/tooltip functionality in React Charts and would love to offer any help here that I can, if any. I can say from experience in both building and using several different interaction models for my charts that element-based interaction models are usually easier to build and use compared to arbitrary closest-to-point/trie-like ones. In fact, the same great features that make encoding data to cells, bands, shapes, etc such a breeze in plot would make building this "invisible" interaction layer so much easier than what I've been going through lately 😂 .
Put me to work!
from plot.
I was thinking that this would be implemented as an invisible mark (say a rect with fill: none and pointer-events: all) which listens for pointer events and then assigns the ownerSVGElement.value and emits an input event (for viewof compatibility). I was further imagining that the value based on the pointer position would be dependent on which (invisible) mark type you chose. For example, you could imagine a mark type suitable for scatterplots that computes x and y positions for the data, and sets the value to the closest point to the mouse; you could also imagine a mark type suitable for line charts that only considers the x position; you could also imagine {brush, brushX, brushY} marks that allow selection instead of searching.
from plot.
My remark was more about separating the two signals: if the viewof channel is dedicated to filtering (typically brushing), I don't think it should be used to send information about what the user is hovering, and vice versa?
In the case of a chart which has both brush and hover interactions, you'd want the brush to return "a collection" and update "aggregate charts" downstream. Hovering on clicking on 1 datum would update an "individual view", with lots of details about that datum (that view could be a tooltip mark in the same plot). Typically I think we wouldn't want to mix these two streams, because they have very different purposes and rendering methods. Hence the proposal of dedicating viewof to selection (of a subset of the data), and a different dispatch mechanism for hovering/pointing at one datum.
I can't find a good example right now, the closest thing would be https://observablehq.com/@john-guerra/umap-playground if its brush returned a selection via viewof. (It's a nice dataset btw).
from plot.
Ah. I was thinking you’d only have one or the other (hovering or brushing), but never both.
from plot.
I have this data editor plugin example where I'm sending a customEvent with modified data — but getting the actual target of that event is a bit of a mess, and could be helped if we exposed a method of some sort that would trigger when the plot is appended (or ready to append) to the DOM.
Currently this needs an async call and a somewhat chancy heuristic:
// set chart to the svg and send the initial value
requestAnimationFrame(() => {
chart = g.ownerSVGElement;
if (chart?.parentElement?.nodeName === "FIGURE") chart = chart.parentElement;
chart.value = data;
chart.dispatchEvent(new CustomEvent("input", {bubbles: true}));
});
I'd like to replace it with a method that would have a signature such as ready(index, g, parent, svg parent, data dispatcher)
we need
g
and (or?)index
to know in which facet we are and possibly create event listeners;- the parent is the svg or html parent depending on the presence of a figcaption; useful to wrap into something else
- the svg parent is always the svg; can help to know if we're in svg or html mode, or add styles or target event listeners
- the data dispatcher is a data flow function to call with data to set the value for viewof
PS: This would be triggered once for each facet, which is not necessarily OK. We might want two such methods: one for each facet, and one for the whole mark.
from plot.
Hi! Is there any way to do interaction with Plot? I tried viewing the above links but most of them are dead. Even if it's a hacky solution, I'd like to know if there is some way to do interaction.
from plot.
I have fixed the links; if you play with them, I would be happy to have feedback.
from plot.
Reference metricsgraphics
from plot.
Some great reference examples for different chart types by @tannerlinsley: https://codesandbox.io/s/github/tannerlinsley/react-charts/tree/beta/examples/simple?from-embed
from plot.
Related Issues (20)
- Offset for tips
- Chart with facets: ticks overflow HOT 5
- Waffle mark
- interpolatorRandomWalk maxDistance
- Cluster contours / segmentation
- Spatial interpolator reducers
- Barycentric interpolator leaves some raster cells uninterpolated HOT 2
- Return slope from linear regression mark? HOT 1
- Trouble using Plot library in a CommonJS environment
- The initial value of a plot with a title and a pointer transform is undefined
- Support for different projections?
- The tip mark should respect the associated scale’s (local) time zone, if present HOT 1
- Pointer interaction interferes with external event handlers
- The tip mark’s format option should not be ignored when a title channel is present
- Rounded corners on rect, but only for some corners HOT 2
- Rect mark doesn't work with `scale: { type: "log" }` HOT 1
- Add a "Plot in Angular" example to the getting started page
- Exemple using Vue.js version 2
- Determine the default height when the projection domain is set
- Dot / circle with centroid radius value isn't responsive to accessor changes HOT 4
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 plot.