Esri / Esri/cedar

Time chart mouseover/off events always show same data

Open
#88 0 comments 0 reactions 0 assignees View on GitHub
v0x
Dominant language
Handlebars
Stars
265
Forks
236
PR merge metrics
No merged PRs in 30d

Description

I’ve wired up mouseover on the line chart (events are logged to the console), but it seems that no matter where I hover in the chart I see the same data:

http://tomwayson.github.io/cedar/examples/time-responsive-events.html

@dbouwman points out that this is b/c w/ line charts there is only one mark (the line) and that wille the data that cedar gets back from vega is includes all the points that make up the line, cedar is only passing the first one back to the client event handler. He also suggested that we might be able to figure out the value from the array of points based on the mouse x position, but that we're probably better off waiting for vega v2's improved "interactions."

I did start looking at the v2 examples. The index_chart example here: http://idl.cs.washington.edu/projects/reactive-vega/examples/editor/ shows how to declaratively capture the changes to mousemove. Near as I can tell it’s getting the date along the x-scale at the mouse.x position and then using that as the input to a transform on the data (see below for .json).

Anyway, I wonder if that approach (getting data from the scales instead of the underlying data) makes more sense for line charts and whether or not there's a v1 way to do it.

``` js
"signals": [
{
"name": "xPos",
"init": 265,
"streams": [{"type": "mousemove", "expr": "p.x", "scale": "x", "invert": "true"}]
},
{
"name": "indexDate",
"init": 1104566400000,
"streams": [{"type": "xPos", "expr": "date(xPos)"}]
}
],
"data": [
{
"name": "stocks",
"url": "data/stocks.csv",
"format": {"type": "csv", "parse": {"price":"number", "date":"date"}}
},
{
"name": "index",
"source": "stocks",
"transform": [{
"type": "filter",
"test": "d.date + 1296000000 >= indexDate && d.date - 1296000000 <= indexDate"
}]
},
{
"name": "indexified_stocks",
"source": "stocks",
"transform": [{
"type": "zip",
"with": "index",
"as": "index_term",
"key": "symbol",
"withKey": "symbol",
"default": {"price": 0}
}, {
"type": "formula",
"field": "indexed_price",
"expr": "d.index_term.price > 0 ? (d.price - d.index_term.price)/d.index_term.price : 0"
}]
}
...
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.