如何将我的自己的CSV文件加载到Vega-Lite在线编辑器中?

huangapple go评论169阅读模式
英文:

How to load my own csv into vega-lite online editor?

问题

我想要使用在线的Vega-Lite编辑器来快速原型化一些我想要构建的图表。示例中使用了以下代码来加载数据:

"data": {
  "url": "data/penguins.json"
},

在编辑器内部是否有一种方式可以从.csv文件加载数据?

英文:

I would like to use the online vega-lite editor to do some quick prototyping of some graphs I want to build. The examples use

  "data": {
    "url": "data/penguins.json"
  },

Is there a way to load data from a .csv file from within the editor?

答案1

得分: 0

这是一个从GitHub页面加载.csv数据的具体示例。对于此示例,请考虑在线Vega编辑器上的"气泡图(Gapminder)"示例(链接)。此示例使用以下行来加载数据,与您提供的示例类似:"data": {"url": "data/gapminder-health-income.csv"}。但是,我们可以将此链接更改为直接的GitHub链接,如下所示。

首先,在GitHub上找到您想要使用的数据。这个特定数据集托管在Vega GitHub的vega-datasets存储库下,位于此链接。从这个GitHub页面,您可以选择"raw"按钮以获得仅原始数据的链接(链接),然后可以在在线编辑器中如下使用:"data": {"url": "https://raw.githubusercontent.com/vega/vega-datasets/main/data/gapminder-health-income.csv"}。生成的可视化效果将与默认效果完全相同,但此方法适用于您在GitHub上自行托管的任何数据集。

如何将我的自己的CSV文件加载到Vega-Lite在线编辑器中?

英文:

Here is a concrete example of how to load .csv data from a GitHub page. For this example, consider the "Bubble Plot (Gapminder)" example (link) on the online Vega editor. This example uses the following line to load data, similar to the example you provided: "data": {"url": "data/gapminder-health-income.csv"}. However, we can change this link to a direct GitHub link as follows.

First, find the data that you want to use on GitHub. This particular dataset is hosted on the Vega GitHub under the vega-datasets repository at this link. From this GitHub page, you can select the "raw" button to get a link to only the raw data (link), which can then be used in the online editor as follows: "data": {"url": "https://raw.githubusercontent.com/vega/vega-datasets/main/data/gapminder-health-income.csv"}. The resulting visualization will be exactly the same as the default one, but this approach can work for any datasets that you host for yourself on GitHub.

如何将我的自己的CSV文件加载到Vega-Lite在线编辑器中?

huangapple
  • 本文由 发表于 2023年6月22日 17:36:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76530502.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定