How to use the vega.changeset function in vega

To help you get started, we’ve selected a few vega examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TwoRavens / TwoRavens / assets / app / views / PlotVegaLite.js View on Github external
diff(vnode) {
        let {data, identifier} = vnode.attrs;
        let newData = data.filter(datum => !this.dataKeys.has(datum[identifier]));

        this.dataKeys = new Set(data.map(datum => datum[identifier]));
        this.instance
            // .width(offsetWidth)
            // .height(offsetHeight + (heightOffset || 0))
            .change('embedded', vega.changeset()
                .insert(newData)
                .remove(datum => !this.dataKeys.has(datum[identifier])))
            .run();
    }
github vega / voyager / src / components / vega-lite / index.tsx View on Github external
private bindData() {
    const {data, spec} = this.props;
    if (data && isNamedData(spec.data)) {
      this.view.change(spec.data.name,
        vega.changeset()
            .remove(() => true) // remove previous data
            .insert(data.values)
      );
    }
  }
github streamlit / streamlit / frontend / src / components / elements / VegaLiteChart / VegaLiteChart.tsx View on Github external
if (
      dataIsAnAppendOfPrev(
        prevData,
        prevNumRows,
        prevNumCols,
        data,
        numRows,
        numCols
      )
    ) {
      if (prevNumRows < numRows) {
        this.vegaView.insert(name, getDataArray(data, prevNumRows))
      }
    } else {
      // Clean the dataset and insert from scratch.
      const cs = vega
        .changeset()
        .remove(vega.truthy)
        .insert(getDataArray(data))
      this.vegaView.change(name, cs)
      logMessage(
        `Had to clear the ${name} dataset before inserting data through Vega view.`
      )
    }
  }
github datadotworld / chart-builder / src / components / VegaLiteImage.js View on Github external
async constructView() {
    let { spec, data } = this.props
    const loader = vega.loader()
    const logLevel = vega.Warn
    const renderer = 'svg'

    spec = vl.compile(spec).spec

    const runtime = vega.parse(spec)
    const view = new vega.View(runtime, {
      loader,
      logLevel,
      renderer
    }).initialize()

    view.change('source', vega.changeset().insert(data))

    const svgString: string = await view.toSVG()

    const blob = new Blob([svgString], { type: 'image/svg+xml' })
    const url = window.URL.createObjectURL(blob)

    this.image = url
    view.finalize()

    this.props.onRender && this.props.onRender(blob)
  }
github apple / turicreate / src / visualization / Turi Create Visualization / src / user_interface / src / elements / Plot / Chart / index.js View on Github external
checkLoadedFlag(data, $this) {
        if($this.vegaLoading) {
            window.setTimeout($this.checkLoadedFlag, 100, data, $this);
        } else {
            if($this.vegaLoading){
                debugger;
            }

            if (!data || !data.values) {
                debugger;
            }

            var newData = data.values.slice();

            var changeSet = vega.changeset();

            if(data.progress != null){
                var progress = parseFloat(data.progress);
                if(parseInt(progress*100, 10) >= 100){
                    document.getElementById('progress_bar').style.width = parseInt(progress*100)+"%";
                    setTimeout(function(){
                               document.getElementById('progress_bar').style.opacity = "0.0";
                               }, 1000);
                }else{
                    document.getElementById('progress_bar').style.width = parseInt(progress*100)+"%";
                }
            }

            var prevData = $this.vegaView.data("source_2");

            for(var y = 0; y < newData.length; y++ ){
github Kitware / candela / packages / examples / line-dynamic / index.js View on Github external
data (data) {
    this.options.data = data;
    this.view.change('source_0', changeset().remove(() => true).insert(this.options.data)).run();
  }
}