0

如何设置存储在数据字段中的线条颜色?在织女我做了:

marks :[
 {
   encode: {
     enter: {
       ...
       stroke: {field: "color"}
      }
    }
  }
]

Vega-Lite 有类似的方法吗?

4

1 回答 1

0

您可以使用带有标记的color编码。linevega-lite 网站上有几个例子;一个相关的是多系列折线图

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "description": "Stock prices of 5 Tech Companies over Time.",
  "data": {"url": "data/stocks.csv"},
  "mark": "line",
  "encoding": {
    "x": {"field": "date", "type": "temporal"},
    "y": {"field": "price", "type": "quantitative"},
    "color": {"field": "symbol", "type": "nominal"}
  }
}

在此处输入图像描述

于 2018-08-23T02:17:34.733 回答