简体   繁体   English

Vega:如何在 Vega 规范中包含 topoJSON 而不是使用 URL

[英]Vega: how to include topoJSON instead of using URL in the Vega spec

I use Vega charting library.我使用 Vega 图表库。 Every time I switch between tabs, the app render charts and one of charts has a spec with URL of topoJSON.每次我在选项卡之间切换时,应用程序都会呈现图表,其中一个图表的规格为 URL 的 topoJSON。 The spec itself is in memory, but this URL is called every time on re-rendering charts.规范本身在 memory 中,但每次在重新渲染图表上都会调用此 URL。

This example uses URL to load topoJSON of the world map: https://vega.github.io/vega/examples/zoomable-world-map/本例使用URL加载世界map的topoJSON: https://vega.github.io/vega/examples/zoomable-world-map/

Is it possible include topoJSON to the spec instead of using URL?是否可以在规范中包含 topoJSON 而不是使用 URL? Or at least cache it somehow on local (can't use CDN).或者至少以某种方式将其缓存在本地(不能使用 CDN)。

在此处输入图像描述

Here is how to supply topojson inline.以下是如何内联提供 topojson。

Create a data as follows创建数据如下

{
            "name": "i",
            "values": {},
            "format": { "type": "topojson", "mesh": "yourMesh", "filter": "exterior" }
}

Everything between the braces for values should be your entire topojson spec.值大括号之间的所有内容都应该是您的整个 topojson 规范。 yourMesh should be the feature or mesh name. yourMesh 应该是特征或网格名称。

I'd post a working example but the spec it too large.我会发布一个工作示例,但规格太大。 You can download a PowerBI file at the following link showing this working.您可以在以下链接中下载 PowerBI 文件,该文件显示了此工作原理。

https://github.com/deneb-viz/deneb/issues/194 https://github.com/deneb-viz/deneb/issues/194

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM