vega-lite icon indicating copy to clipboard operation
vega-lite copied to clipboard

Add composite mark callout

Open starry97 opened this issue 8 years ago • 10 comments

starry97 avatar Feb 21 '18 19:02 starry97

@starry97 -- one possibility for all of these offset thing is having calloutAngle and then makes all of the calloutOffset, calloutSize (maybe rename to calloutLength), labelOffset just number rather than {x,y} -- then you can do the math to calculate things.

kanitw avatar Feb 24 '18 03:02 kanitw

Rebase onto 2.x-annotation? (The first commit is redundant)

kanitw avatar Mar 03 '18 23:03 kanitw

Sorry for going back and forth. I google callout and only see cloud style callout. This makes me wonder if calloutline is a better mark name. In any case, changing name is not that hard, I'd still keep the name callout and address other issues / make examples.

kanitw avatar Mar 06 '18 20:03 kanitw

I'm playing with it a little bit. Here is another example you could polish and consider adding:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "description": "Google's stock price over time.",
  "data": {"url": "data/stocks.csv"},
  "transform": [{"filter": "datum.symbol==='GOOG'"}],
  "layer": [{
    "mark": "line",
    "encoding": {
      "x": {"field": "date", "type": "temporal", "axis": {"format": "%Y"}},
      "y": {"field": "price", "type": "quantitative"}
    }

  }, {
    "transform": [{
      "filter": {
        "field": "date",
        "range": [
          {"year": 2006, "month": 1, "day": 1},
          {"year": 2006, "month": 1, "day": 1}
        ]
      }
    }],
    "mark": {
      "type": "callout",
      "calloutAngle": 90,
      "label": {
        "align": "center"
      },
      "labelOffset": 2
    },
    "encoding": {
      "x": {"field": "date", "type": "temporal", "axis": {"format": "%Y"}},
      "y": {"field": "price", "type": "quantitative"},
      "text": {"value": "high horsepower"},
      "color": {"value": "red"}
    }
  }, {
    "transform": [{
      "filter": {
        "field": "date",
        "range": [
          {"year": 2006, "month": 1, "day": 1},
          {"year": 2006, "month": 1, "day": 1}
        ]
      }
    }],
    "mark": {
      "type": "circle",
      "color": "red"
    },
    "encoding": {
      "x": {"field": "date", "type": "temporal", "axis": {"format": "%Y"}},
      "y": {"field": "price", "type": "quantitative"},
      "text": {"value": "high horsepower"}
    }
  }]
}
pasted_image_3_7_18__9_42_am

kanitw avatar Mar 07 '18 17:03 kanitw

  • [ ] Besides align, baseline is important too. You might wanna look at @NeelMohapatra's PR recently to see if you can reuse similar rules.

image

kanitw avatar Mar 07 '18 19:03 kanitw

@kanitw, what would a callout look like if it was supposed to represent several data points instead of just one ? Should there be a similar restriction as with selection, that is point and interval?

g3o2 avatar Apr 02 '18 11:04 g3o2

@g3o2 you can draw multiple callouts just like any other marks. This is just a macro for drawing line segment(s) and text(s) using just one (composite) mark.

kanitw avatar Apr 07 '18 22:04 kanitw

@starry97 -- any update on this? (Do you still have time to clean it up for a release?)

kanitw avatar Apr 07 '18 22:04 kanitw

What's left in this PR? I think this would be awesome to have but I won't have the cycles to finish it.

domoritz avatar Oct 05 '18 22:10 domoritz

Is there any chance of this being resurrected? It looks like a fantastic feature to have.

PBI-David avatar Aug 06 '22 10:08 PBI-David