简体   繁体   中英

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

I use Vega charting library. Every time I switch between tabs, the app render charts and one of charts has a spec with URL of topoJSON. The spec itself is in memory, but this URL is called every time on re-rendering charts.

This example uses URL to load topoJSON of the world map: https://vega.github.io/vega/examples/zoomable-world-map/

Is it possible include topoJSON to the spec instead of using URL? Or at least cache it somehow on local (can't use CDN).

在此处输入图像描述

Here is how to supply topojson inline.

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. yourMesh should be the feature or mesh name.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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