draco-core

Visualization Knowledge as Constraints.

Usage no npm install needed!

<script type="module">
  import dracoCore from 'https://cdn.skypack.dev/draco-core';
</script>

README

Draco Core

JavaScript module with the Draco knowledge base and helper functions to convert from Draco ASP to Vega-Lite and vice-versa as well as a function to convert from CompassQL to Draco ASP.

vl2asp (spec: TopLevelUnitSpec): string[] <>

Translates a Vega-Lite specification into a list of ASP Draco facts.

cql2asp (spec: any): string[] <>

Translates a CompassQL specification into a list of ASP Draco constraints.

asp2vl (facts: string[]): TopLevelUnitSpec <>

Interprets a list of ASP Draco facts as a Vega-Lite specification.

data2schema (data: any[]): Schema <>

Reads a list of rows and generates a schema for the dataset. data should be given as a list of dictionaries.

schema2asp (schema: Schema): string[] <>

Translates a schema into an ASP declaration of the data it describes.

constraints2json (constraintsAsp: string, weightsAsp?: string): Constraint[] <>

Translates the given ASP constraints and matching weights (i.e. for soft constraints) into JSON format.

Examples

You can run vl2asp, aps2vl, and cql2asp on the command line.

cat ../examples/ab.json  | vl2asp | clingo