data-visualization - 如何在 Vega-Lite 中格式化货币?
问题描述
我正在尝试在 Vega-Lite 编辑器中将值格式化为货币。我正在尝试复制文档,但遇到了一个奇怪的错误。Y轴是数值。传入格式化字符串会给出“预期值”。
这是json:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Protocol Chart",
"width": 500,
"height": 225,
"data": {
"values": [
{
"asset": "eth",
"time": "2021-06-15T00:00:00Z",
"ReferenceRateUSD": "2577.04473863238"
},
{
"asset": "eth",
"time": "2021-06-16T00:00:00Z",
"ReferenceRateUSD": "2552.74103641146"
},
{
"asset": "eth",
"time": "2021-06-17T00:00:00Z",
"ReferenceRateUSD": "2360.99938690824"
}
]
},
"config": {
"view": {
"stroke": "transparent"
}
},
"mark": "line",
"encoding": {
"x": {
"axis": {
"domainColor": "#DDD",
"grid": false,
"labelColor": "#AEAEAE",
"ticks": false,
"labelPadding": 10
},
"field": "time",
"type": "temporal",
"title": ""
},
"y": {
"axis": {
"labelOffset": 2,
"domainColor": "white",
"labelColor": "#AEAEAE",
"ticks": false,
"labelPadding": 10,
"format": '$.2f'
},
"field": "ReferenceRateUSD",
"type": "quantitative",
"title": "",
"scale": {
"zero": false
}
},
"color": {
"field": "doesntmatter",
"type": "nominal",
"legend": null,
"scale": {
"range": ["#91DB97"]
}
}
}
}
我在这里想念什么?如何让它接受我的格式字符串?
解决方案
推荐阅读
- amazon-s3 - JW Player 中 S3 托管的 HLS 视频的 CORS 配置
- python - 如何在手风琴Python中抓取隐藏的文本
- javascript - 在同一页面上调用一个 javascript 弹出窗口,该页面应该在输入文本中具有动态值
- node.js - Node.js中的SFTP上传空文件
- unity3d - unity build error 找不到:AndroidTargetDevice
- azure - “分区低于目标副本或实例计数”,Service Fabric 本地群集上有状态服务
- php - DocuSign PHP SDK - 为什么我调用 createEnvelope() 时会发送两封电子邮件?
- flutter - Flutter ScrollController 在 NestedScrollView 中的位置
- python - 如何提高文本解析功能的性能?
- python - 我如何登录到这个特定的网站/如何使用 cookie 文件登录