How to use the vega.read 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 john-guerra / navio / shipyard / src / components / playground / loader / Loader.jsx View on Github external
reader.onload = (lEvent) => {
      const format = file.name.split('.').pop().toLowerCase();
      var values;
      try {
        console.log('TRY')
        // if (format === 'txt' || (format !== "csv" && format !== "tsv")) {
        //   throw Error();
        // }
        values = vega.read(lEvent.target.result, {type: format});
        // let csvFormat = d3.dsvFormat(","); should be csvFormat??
        // values = csvFormat.parse(lEvent.target.result);
        setData(values);
        setComponentClasses(Object.keys(values[0]));
        toggleLoading();
        toggleDataLoaded();
      } catch (err) {
        console.log('CATCH', err)
        const separator = prompt('Write a delimiter for your dataset (e.g: ;)');
        let ssv = d3.dsvFormat(separator);
        values = ssv.parse(lEvent.target.result);
        delete values.columns;
        setData(values);
        setComponentClasses(Object.keys(values[0]));
        toggleLoading();
        toggleDataLoaded();
github john-guerra / navio / shipyard / src / content / load / Load.jsx View on Github external
reader.onload = (lEvent: any) => {
      console.log('onload')
      const format = file.name.split('.').pop();
      let values;
      try {
        console.log('try')
        if(format === "txt") throw true
        values = vega.read(lEvent.target.result, {type: format});
        console.log('try2')
        this.props.setData(values);
        this.setState({loading:false})
      } catch (err) {
        console.log('err')
        let ssv = d3.dsvFormat(";");
        console.log('err2');
        values = ssv.parse(lEvent.target.result);
        console.log(values);
        this.props.setData(values);
        this.setState({loading:false});
      }
    };
github vega / voyager / src / components / data-selector / index.tsx View on Github external
private onDataTextSubmit() {
    const values = vega.read(this.state.dataText, {type: 'csv'});
    this.props.handleAction(datasetLoad(this.state.dataName, {values}));
  }
github vega / voyager / src / components / data-selector / index.tsx View on Github external
reader.onload = (lEvent: any) => {
      const name = file.name.replace(/\.\w+$/, '');
      const format = file.name.split('.').pop();

      let values;
      try {
        values = vega.read(lEvent.target.result, {type: format});
      } catch (err) {
        window.alert(err.message);
      }

      handleAction(datasetLoad(name, {values, format}));
    };
github vega / voyager / src / components / data-selector / index.tsx View on Github external
private loadDataString(data: string) {
    const name = this.state.dataName;
    const fileType = this.state.fileType;
    const values = vega.read(data, {type: fileType});
    this.props.handleAction(datasetLoad(name, {values}));
  }