Supply & Demand : Different data sets for each line + more verbose tooltip
See original GitHub issueDo you want to request a feature or report a bug?
feature request
What is the current behavior?
Currently there is only one data array that contains several X points, each X point has two Y values (for I am drawing two lines).
data = [
...
{sell: 8},
{buy: 2, sell: 7},
{buy: 4, sell: 6.5},
{buy: 4.5, sell: 6.25},
...
]
What is the expected behavior?
I have this data:
Notice I can transform sellingData.priceOne
to sell
and buyingData.priceOne
to buy
and construct this XPoint data array, but then I need to display the user, quantity and priceTotal fields in a tooltip on hover. That would require an extensive mapping function as the datasets are not of a same length.
sellingData = [
{user: 'user1', quantity: 200, priceTotal: 1600, priceOne: 8},
{user: 'user2', quantity: 200, priceTotal: 1400, priceOne: 7},
{user: 'user3', quantity: 100, priceTotal: 650, priceOne: 6.5},
{user: 'user4', quantity: 100, priceTotal: 625, priceOne: 6.25}
]
buyingData = [
{user: 'user5', quantity: 1000, priceTotal: 2000, priceOne: 2},
{user: 'user6', quantity: 100, priceTotal: 400, priceOne: 4},
{user: 'user7', quantity: 100, priceTotal: 450, priceOne: 4.5}
]
and I want to see two converging lines that don’t meet - This is a supply and demand chart.
Then I want to display a tooltip with the user, quantity and priceTotal fields separately for each data line, however for that I would need
- I don’t have different tooltip for each line
- The payload gives me only the current XPoint data, that is the data mangled together.
In this picture: Hover over section with both buy and sell line; and only with sell line.
Upon closer inspection, it is apparent that the payload is same for both lines in first case. (point 2.)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:5
Top GitHub Comments
findCloserLine
… When points are drawn, I hijack their coordinates and store them into an array, so I can access them later, then when hovering over the chart, I use the mouse coordinates and find closest point (and it’s line). Given this information, I then select proper tooltip content.Here is the app (please only play with data in this one linked table)
Example data
download json here
Code
I want to do something very similar where I want to have the tooltip react to what line/dot is closest to the mouse position. This was closed, was there a reason for that? Some sort of way to do this without @ackvf solution?