-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Quansight/vega-lite
Add preliminary support for vega lite
- Loading branch information
Showing
10 changed files
with
660 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
FROM jupyter/scipy-notebook | ||
FROM jupyter/scipy-notebook:1085ca054a5f | ||
|
||
RUN conda install -y -c conda-forge \ | ||
jupyterlab=0.32.0 \ | ||
pymapd | ||
pymapd==0.3.2 \ | ||
altair==2.0.1 | ||
|
||
RUN pip install vdom altair==2.0.0rc2 | ||
RUN pip install \ | ||
vdom \ | ||
git+https://github.com/Quansight/ibis.git@0d1d81400a7a06943f3c99037c348c26942b0ffe | ||
|
||
USER root | ||
RUN echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook | ||
USER $NB_USER |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { compile } from "vega-lite"; | ||
|
||
/** | ||
* Compiles a Mapd vega lite spec to a Mapd vega spec. | ||
* | ||
* The vega lite spec should have an `sql` field in it's data instead of a `values` field. | ||
* | ||
* The vega spec has a bunch of differences between mapd and the original spec. | ||
* @param spec | ||
*/ | ||
export function compileToVega(vlSpec: any): any { | ||
const sql = vlSpec.data.sql; | ||
delete vlSpec.data.sql; | ||
vlSpec.data.name = 'mapd_data' | ||
|
||
const vSpec = compile(vlSpec, {config: {invalidValues: null}}).spec; | ||
|
||
// manually remove transformation from vega spec | ||
// until https://github.com/vega/vega-lite/issues/3665 is merged | ||
vSpec.data[0].name = vSpec.data.pop().name; | ||
vSpec.data[0].sql = sql; | ||
|
||
for (const mark of vSpec.marks) { | ||
// mapd uses mark.properties instead of mark.encode.update | ||
const properties = mark.encode.update; | ||
mark.properties = properties; | ||
delete mark.encode; | ||
|
||
// mapd has an opacity value instead of an object | ||
if (properties.opacity) { | ||
properties.opacity = properties.opacity.value; | ||
} | ||
|
||
// mapd has a fillColor instead of a fill object | ||
if (properties.fill) { | ||
properties.fillColor = properties.fill.value; | ||
delete properties.fill; | ||
} | ||
|
||
//mapd has a shape string instead of object | ||
if (properties.shape) { | ||
properties.shape = properties.shape.value; | ||
} | ||
|
||
// the width and height are required in mapd for symbols, | ||
// unlike in vega where they are optional, or you can just set the | ||
// size | ||
if (mark.type === 'symbol') { | ||
properties.width = properties.height = properties.size; | ||
delete properties.size; | ||
} | ||
} | ||
|
||
return vSpec; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters