Points only in the central line

送分小仙女□ 提交于 2020-06-17 03:53:45

问题


I am using this example named "Line Chart with Point Markers" as reference, but not see other example or any clues about conditional or "selected by symbol" points.

The illustration shows a typical case (see also SPC) where I need only the blue central line with dots.


回答1:


You can do this by layering filtered versions of the dataset. Modifying the example you linked to, it might look something like this (vega editor):

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "description": "Stock prices of 5 Tech Companies over Time.",
  "data": {"url": "data/stocks.csv"},
  "encoding": {
    "x": {"timeUnit": "year", "field": "date", "type": "temporal"},
    "y": {"aggregate": "mean", "field": "price", "type": "quantitative"},
    "color": {"field": "symbol", "type": "nominal"}
  },
  "layer": [
    {
      "mark": {"type": "line", "point": true},
      "transform": [{"filter": "datum.symbol == 'GOOG'"}]
    },
    {
      "mark": {"type": "line"},
      "transform": [{"filter": "datum.symbol != 'GOOG'"}]
    }
  ]
}



来源:https://stackoverflow.com/questions/61657753/points-only-in-the-central-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!