Coder Social home page Coder Social logo

randomfractals / vscode-vega-viewer Goto Github PK

View Code? Open in Web Editor NEW
122.0 3.0 11.0 26.81 MB

VSCode extension for Interactive Preview of Vega and Vega-Lite maps πŸ—ΊοΈ and graphs πŸ“ˆ.

Home Page: https://marketplace.visualstudio.com/items?itemName=RandomFractalsInc.vscode-vega-viewer

License: Apache License 2.0

TypeScript 69.61% HTML 20.32% JavaScript 8.28% CSS 1.79%
vscode vega vega-lite viewer preview extension charts graphs maps

vscode-vega-viewer's Issues

restrict vega.preview command display in menus to vega json documents only

Currently, vega Preview option is displayed in explorer and editor menus for all .json files.

Desired:

Restrict this to .vega, .vg.json, .vl.json, .vg, and .vl files only to avoid polluting vscode menus for other json files with invalid vega Preview command menu option.

Solution:

Use the following when clause for those menu items:

resourceFilename =~ /.*\\.(vega|vg.json|vl.json|vg|vl)/

or

resourceExtname =~ /.(vega|vg.json|vl.json|vg|vl)/

add support for the latest Vega v5.x releases

currently this extension provides vg.json and vl.json Previews using embedded Vega v4 and Vega-Lite v3 libraries.

Vega dev team, @jheer and @domoritz have been busy with new Vega v5 updates recently.

I'd like to support latest Vega library updates to Preview vega json files created with new features and changes in v5.x. See Vega repo for more info:

https://github.com/vega/vega/releases

Ultimately and ideally as part of this viewer update, load correct vega, vega-lite or vega-embed version for Preview based on the Vega $schema reference provided in vg.json || vl.json spec for backward compatibility and previews of older vega specs.

add local/relative data load support

Vega Viewer alpha v. requires absolute urls via https for data refs in spec.

In order to preview Vega examples, you need to change all example data references

  "data": [
    {
      "name": "source",
      "url": "data/cars.json",
      ...
    }
  ]

to published Vega data sets

  "data": [
    {
      "name": "source",
      "url": "https://vega.github.io/vega-datasets/data/cars.json",
      ...
    }
  ]

Same applies to custom Vega/Lite specs you create.

Solution:

Scan Vega spec for relative data url refs, read them from fs and pass that data along with spec json to the webview and vega embed to load and render with custom vega loader that grabs local data injections from vega viewer webview post message for preview refresh

"data" outside top-level specification

If I load local data on the top-level of a spec it works fine, but if "data" appears somewhere else it doesn't work.
For example this works

{
  "$schema": "https://vega.github.io/schema/vega-lite/v3.json",
  "data": {
    "url": "myfile.csv"
    },
    "Rest of specification"
}

While this doesn't

{
  "$schema": "https://vega.github.io/schema/vega-lite/v3.json",
  "layer": [
    {
      "data": {
      "url": "myfile.csv"
      },
      "Rest of specification"
}

add live vega spec preview?

this is already set up in extension.ts workspace.onDidChangeTextDocument event handler, but I disabled it for alpha.

If updating preview on json spec save is not sufficient I can enable this feature in the next viewer release by adding some 1 min or so timer (configurable to your liking) for that whole json parser and render process not to fire on every char change (why I disabled it for now)

add vega.help command using browser preview setup to show supporting docs πŸ€”

this extension already provides jsonSchema validation and intelli-sense code hints for vega json files.

Adding online help docs loading in another preview panel could be next good step to make it even more appealing for devs using vega viz libs or altair for charting and data viz prototyping.

i.e. something as simple as just loading vega examples site in another vscode preview panel to alleviate the need to load vega docs in chrome or other browser window:

https://vega.github.io/vega/examples/contour-plot/

cc @domoritz @kanitw & @jheer: your thoughts on this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.