Comments (7)
if you're talking about timeseries / line data, you'll probably want cursor.dataIdx
, which allows you to supply your own callback that determines which datapoints are hovered for each series based on cursor position and the nearest index in the dataset:
Lines 555 to 556 in ff021df
demo: https://leeoniya.github.io/uPlot/demos/nearest-non-null.html
if you're talking about cursor.focus
which determines which series to highlight (when cursor.focus.prox
> 0), there's a similar setting cursor.focus.dist
:
Lines 525 to 526 in ff021df
from uplot.
Thank you for the reply. I'm wondering if my particular use case is actually a little strange or a bit of an edge case:
In the screenshot, what I'm aiming for is for the red series to be easier to focus/select. When other points are close by, it's finicky to get these particular series to focus and requires zooming in a lot.
After looking into the properties you mentioned it seems like I what I need is to use cursor.dataIdx
to hover the nearest non-null point on the red series, but only within a certain distance, and at that point trigger a series focus. I'm just having a little trouble conceptualizing how to achieve this with hooks/cursor settings/etc.
from uplot.
i think you'll need to make a runnable jsfiddle that reproduces the issue, with actual data. e.g.: https://jsfiddle.net/q73vxrpe/
the cursor in your screenshot is close enough that it should be focusing without anything extra. my guess is that your data for the red series is not in ascending-x order (as it should be for all series).
from uplot.
I didn't consider the potential data issue and will certainly start there! If that seems alright I will post a fiddle that recreates this behavior. Thank you for your help!
from uplot.
I'm still not sure if I'm just making a simple mistake, but in this fiddle https://jsfiddle.net/Yumcaxion/hnw9mdcq/58/, in the chart using time: true
for the x-scale, the points on the red two-point line are impossible to hover until you've zoomed in quite a bit and even then they are difficult to hover. I've confirmed that the timestamps are all unique and in ascending order.
In the time: false
x-scale chart, the distance for the point hover/series focus seems like it works as expected. These lines are a little weird because they will always only be two points surrounded by null values, but it seems that as long as the datasets are the same length as the primary y set, this shouldn't be an issue, correct?
Apologies for the hastily assembled fiddle.
from uplot.
well, the shape of the data ends up being different. the actual timestamp data has two nearly-coincident points surrounding the red timestamp.
the hover works by converting your mouse cursor position, which only has pixel-level resolution to an index. and if you have a ton of indices in a single pixel, the binary search will always land on the same index for the same pixel. the reason it works in the indexed case is cause the spacing is wider/more uniform.
i think the way to go here is the cursor.dataIdx
route.
in uPlot v2, there will be no alignment requirement, so this case should "just work", but v2 is a ways off still :)
from uplot.
That makes perfect sense! I'm not sure why I didn't make that connection from the different series timestamps being so close together. This gives me some ideas on how to solve this. I appreciate the help!
from uplot.
Related Issues (20)
- custom markers HOT 1
- the tooltip stick to points
- Tooltip issue #question
- fix mouse interaction performance for 2,000 series HOT 1
- base 2 ranging and ticks without log scale
- Secondary sync demos not working HOT 6
- Ranger selection does not trigger mousemove event. HOT 5
- Click event on chart is 'destroying' existing selection
- Is it possible to create stacked bar charts that are grouped by year ? HOT 2
- what would be an approach to make groups of series? HOT 1
- Can I hide an axis but not the ortho lines? HOT 5
- Solution for adding padding within the canvas itself? HOT 2
- Setting Legend Markers using Paths HOT 1
- Seeking guidance on creating a dynamic chart with the following features HOT 2
- how do set bar with in uplot HOT 1
- Best practice to avoid clipped axis ticks' labels HOT 2
- Can we render Multicolor Bar charts(each bar has different color) using uPlot? HOT 7
- lineInterpolation not working HOT 1
- Set data array read position in options to enable circular buffered data HOT 1
- How set equal axis aspect ratio HOT 2
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 uplot.