英文:
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上自行托管的任何数据集。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论