Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support axis labelHref #4148

Open
SyntaxRules opened this issue Sep 4, 2018 · 5 comments
Open

Support axis labelHref #4148

SyntaxRules opened this issue Sep 4, 2018 · 5 comments
Labels

Comments

@SyntaxRules
Copy link

Purpose:
Enable href navigation when user clicks on axis label

Explanation:
vega/vega-lite already has some form of interactivity. Interaction is mostly based on point selection. This feature proposes adding in interactivity to the axis labels. While my immediate desire is to enable href on axis', conditional highlighting or label selection might be nice as well.

Possible Spec:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "description": "A simple bar chart with ranged data (aka Gantt Chart).",
  "data": {
    "values": [
      {"task": "A","task_href": "google.com/A","start": 1, "end": 3},
      {"task": "A","task_href": "google.com/A","start": 4, "end": 7},
      {"task": "B","task_href": "google.com/B","start": 3, "end": 8},
      {"task": "C","task_href": "google.com/C","start": 8, "end": 10},
      {"task": "C","task_href": "google.com/C","start": 1, "end": 2}
    ]
  },
  "mark": "bar",
  "encoding": {
    "y": {"field": "task", "type": "ordinal", "axis": {"href": "task_href"}},
    "x": {"field": "start", "type": "quantitative"},
    "x2": {"field": "end", "type": "quantitative"}
  }
}
@domoritz
Copy link
Member

domoritz commented Sep 5, 2018

Related to #1657

@willcrichton
Copy link

Is there a way to get this behavior with just Vega right now? I tried something like:

<VegaLite ... onNewView={v => v.addEventListener('@legendLabel:click', ...)} />

However, according to vega/vega#352 you can only listen to primitive events like click. I tried that too, but because legend elements aren't datum, they aren't passed to the click callback.

Is there maybe some indirect way where I can define a signal and listen to the signal? I tried this too:

<VegaLite 
   ...
   patch={spec => {
     spec.signals.push({
       name: "foobar",
       value: null,
       on: [{events: "@legendSymbol:click @legendLabel:click",
               update: '{value: datum.value}',
               force: true}]
     })
     return spec;
   }}
   signalListeners={{
     "foobar": (e) => {
       console.log('test', e);
     }
   }}
  />

But no luck either.

@kanitw
Copy link
Member

kanitw commented Jan 3, 2021

@domoritz It's probably fair to add labelHref?

@kanitw kanitw changed the title On click axis label go to href Support axis labelHref Jan 3, 2021
@domoritz
Copy link
Member

domoritz commented Jan 3, 2021

I wonder whether it would be better to support labelHref in Vega directly rather than only Vega-Lite.

@kanitw kanitw added the P4 Nice to Have label Jan 3, 2021
@flip111
Copy link

flip111 commented Feb 6, 2021

would be a nice feature :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants