How to use the plywood.Dataset.fromJS function in plywood

To help you get started, we’ve selected a few plywood 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 implydata / plyql / src / cli.ts View on Github external
case 'json':
              outputStr = JSON.stringify(data, null, 2);
              break;

            case 'csv':
              data = Dataset.fromJS(data.toJS()); // Temp hack
              outputStr = data.toCSV();
              break;

            case 'tsv':
              data = Dataset.fromJS(data.toJS()); // Temp hack
              outputStr = data.toTSV();
              break;

            case 'flat':
              data = Dataset.fromJS(data.toJS()); // Temp hack
              outputStr = JSON.stringify(data.flatten(), null, 2);
              break;

            default:
              outputStr = 'Unknown output type';
              break;
          }
          console.log(outputStr);
        },
        (err: Error) => {
github implydata / plyql / src / cli.ts View on Github external
(data: Dataset) => {
          var outputStr: string;
          switch (output) {
            case 'json':
              outputStr = JSON.stringify(data, null, 2);
              break;

            case 'csv':
              data = Dataset.fromJS(data.toJS()); // Temp hack
              outputStr = data.toCSV();
              break;

            case 'tsv':
              data = Dataset.fromJS(data.toJS()); // Temp hack
              outputStr = data.toTSV();
              break;

            case 'flat':
              data = Dataset.fromJS(data.toJS()); // Temp hack
              outputStr = JSON.stringify(data.flatten(), null, 2);
              break;

            default:
              outputStr = 'Unknown output type';
              break;
          }
          console.log(outputStr);
        },
        (err: Error) => {
github allegro / turnilo / src / client / utils / dataset / dataset.mocha.ts View on Github external
it("works when reversing time dimension", () => {
    expect(fillDatasetWithMissingValues(Dataset.fromJS(rawDatasetWithTimeDimension.data[0][SPLIT] as Dataset), "click", "__time", orderByTimeDimensionDecreasing, timezone).toJS())
    .to.deep.equal(Dataset.fromJS(reversedDatasetWithTimeDimension.data[0][SPLIT] as Dataset).toJS());
  });
github allegro / turnilo / src / client / utils / dataset / dataset.mocha.ts View on Github external
it("works with number ranges", () => {
    expect(fillDatasetWithMissingValues(Dataset.fromJS(rawDataWithNumberRanges.data[0][SPLIT] as Dataset), "added", "deltaBucket100", orderByNumberRangeDimensionIncreasing, timezone).toJS())
    .to.deep.equal(Dataset.fromJS(rawDataWithNumberRanges.data[0][SPLIT] as Dataset).toJS());
  });
});
github allegro / turnilo / src / client / utils / download / download.mocha.ts View on Github external
it("encloses set/string in brackets appropriately", () => {
      const ds = Dataset.fromJS([
        { y: ["dear", "john"] },
        { y: ["from", "peter"] }
      ]);
      expect(datasetToFileString(ds, "csv").indexOf("\"dear, john\""), "csv").to.not.equal(-1);
      expect(datasetToFileString(ds, "tsv").indexOf("dear, john"), "tsv").to.not.equal(-1);
    });
  });
github allegro / turnilo / src / common / models / data-cube / data-cube.fixtures.ts View on Github external
*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { basicExecutorFactory, Dataset } from "plywood";
import { DimensionsFixtures } from "../dimension/dimensions.fixtures";
import { MeasuresFixtures } from "../measure/measures.fixtures";
import { DataCube, DataCubeJS } from "./data-cube";

var executor = basicExecutorFactory({
  datasets: {
    wiki: Dataset.fromJS([]),
    twitter: Dataset.fromJS([])
  }
});

export class DataCubeFixtures {
  public static get WIKI_JS(): DataCubeJS {
    return {
      name: "wiki",
      title: "Wiki",
      description: "Wiki full description something about articles and editors",
      clusterName: "druid-wiki",
      source: "wiki",
      introspection: "none",
      attributes: [
        { name: "time", type: "TIME" },
        { name: "articleName", type: "STRING" },
github allegro / turnilo / src / common / models / app-settings / app-settings.fixtures.ts View on Github external
return AppSettingsFixtures.wikiOnly().attachExecutors(() => {
      return basicExecutorFactory({
        datasets: {
          main: Dataset.fromJS(SMALL_WIKI_DATA)
        }
      });
    });
  }
github geo-opensource / pivot / src / client / views / settings-view / data-table / data-table.tsx View on Github external
(resp: any) => {
          if (!this.mounted) return;

          this.loadingDelegate.stop();
          this.setState({
            dataset: Dataset.fromJS(resp.dataset)
          });
        },
        (error: Error) => {
github geo-opensource / pivot / src / common / models / app-settings / app-settings.mock.ts View on Github external
static executorsWiki(): Lookup {
    return {
      wiki: basicExecutorFactory({
        datasets: {
          main: Dataset.fromJS(SMALL_WIKI_DATA)
        }
      })
    };
  }
}
github implydata / plyql / src / datasets.ts View on Github external
export const getDataset = (name: string) => Dataset.fromJS(getData(name));