Miso.Dataset. DataView

new DataView ( options )

A DataView is an immutable version of dataset. It is the result of selecting a subset of the data using the Miso.Dataset#where call. If the dataset is syncing, this view will be updated when changes take place in the original dataset. A Miso.Dataset also extends from DataView. All the methods available on a dataview will also be available on the dataset.

Parameters

  • options Object optional

    initialization parameters

    Properties
    • parent Miso.Dataset required

      parent dataset

    • filter function required

      filter specification TODO: document better

      Properties
      • columns String | Array.<String> required

        column name or multiple names

      • rows Number | function required

        rowId or function

Source

Methods

column ( name )

Returns: Miso.Dataset.Column
You can edit the code in this block and rerun it.

Parameters

  • name String required

    name of the column to be selected

Returns

View of the given column name

Type: Miso.Dataset.Column
Source

columnNames ( )

Returns: Array.<String>
You can edit the code in this block and rerun it.

Returns

the names of all columns, not including id column

Type: Array.<String>
Source

columns ( columnsArray )

Returns: Miso.Dataset.DataView
You can edit the code in this block and rerun it.

Parameters

  • columnsArray Array.<String> required

    an array of column names

Returns

dataset view of the given columns

Type: Miso.Dataset.DataView
Source

countBy ( byColumn, options )

Returns: Miso.Dataset.Derived

Returns a new derived dataset that contains the original byColumn and a count column that returns the number of occurances each unique value in the byColumn contained.

You can edit the code in this block and rerun it.

Parameters

  • byColumn String required

    The column to count instances again.

  • options Object optional

Returns

Type: Miso.Dataset.Derived
Source

each ( iterator, context )

Iterates over all rows in the dataset. Each row is not a direct reference to the data and thus should not be altered in any way.

You can edit the code in this block and rerun it.

Parameters

Source

eachColumn ( iterator, context )

Iterates over each column. Direct column references, not arrays so modifying data may cause internal inconsistencies.

You can edit the code in this block and rerun it.

Parameters

Source

groupBy ( byColumn, columns, options )

Returns: Miso.Dataset.Derived

Group rows by values in a given column

You can edit the code in this block and rerun it.

Parameters

  • byColumn String required

    The column by which rows will be grouped

  • columns Array.<String> required

    The columns to be included

  • options Object optional
    Properties
    • method function required

      Function that specifies the way in which the columns are aggregated. The default is sum. The function signature is function(arr). It should return a single result.

    • preprocess function required

      specify a normalization function for the byColumn values if you need to group by some kind of derivation of those values that are not just equality based.

Returns

Type: Miso.Dataset.Derived
Source

hasColumn ( name )

Returns: Boolean

Checks for the existance of a column and returns true/false

You can edit the code in this block and rerun it.

Parameters

  • name String required

    Name of column to check for

Returns

true if a column exists, false otherwise.

Type: Boolean
Source

max ( columns )

Returns: Miso.Dataset.Product|Number

If the dataset has sync enabled this will return a Miso.Dataset.Product that can be used to bind events to and access the current value. Otherwise it will return the current value - the highest numeric value in that column.

You can edit the code in this block and rerun it.

Parameters

  • columns String | Array.<String> required

    column name(s) on which the value is calculated

Returns

Type: Miso.Dataset.Product | Number
Source

mean ( columns )

Returns: Miso.Dataset.Product|Number

If the dataset has sync enabled this will return a Miso.Dataset.Product that can be used to bind events to and access the current value. Otherwise it will return the current value - the mean or average of the numeric form of the values in the column.

You can edit the code in this block and rerun it.

Parameters

  • columns Array.<String> required

    array of column names on which the value is calculated

Returns

Type: Miso.Dataset.Product | Number
Source

min ( columns )

Returns: Miso.Dataset.Product|Number

If the dataset has sync enabled this will return a Miso.Dataset.Product that can be used to bind events to and access the current value. Otherwise it will return the current value - the lowest numeric value in that column.

You can edit the code in this block and rerun it.

Parameters

  • columns Array.<String> required

    array of column names on which the value is calculated

Returns

Type: Miso.Dataset.Product | Number
Source

movingAverage ( columns, size, options )

Returns: Miso.Dataset.Derived

Returns a derived dataset in which the specified columns have a moving average computed over them of a specified size.

Parameters

  • columns Dataset.Column required

    The column on which to calculate the average

  • size Number required

    The window size to utilize for the moving average (the number of rows to average per row.)

  • options Object optional
    Properties
    • method function required

      the method to apply to all values in a window. Mean by default.

Returns

Type: Miso.Dataset.Derived
Source

reverseEach ( iterator, context )

Iterates over all rows in the dataset in reverse order. Each row is not a direct reference to the data and thus should not be altered in any way.

You can edit the code in this block and rerun it.

Parameters

Source

rowById ( id )

Returns: Object

Fetches a row object with a specific _id. Note that the returned row object is NOT a direct reference to the data and thus any changes to it will not alter the original data.

You can edit the code in this block and rerun it.

Parameters

  • id Number required

    unique id

Returns

a single row based on its id (NOT Position.)

Type: Object
Source

rowByPosition ( i )

Returns: Object

Fetches a row object at a specified position. Note that the returned row object is NOT a direct reference to the data and thus any changes to it will not alter the original data.

You can edit the code in this block and rerun it.

Parameters

  • i Number required

    position index

Returns

a single row based on its position (NOT ID.)

Type: Object
Source

rows ( filter )

Returns: Miso.Dataset.DataView

Shorthand for ds.where({ rows : rowFilter );} If run with no filter will return all rows.

You can edit the code in this block and rerun it.

Parameters

Returns

a dataset view of filtered rows

Type: Miso.Dataset.DataView
Source

sort ( args )

Returns: Miso.Dataset.DataView

Sorts the dataset according to the comparator. A comparator can either be passed in as part of the options object or have been defined on the dataset already, for example as part of the initialization block.

roughly taken from here: http://jxlib.googlecode.com/svn-history/r977/trunk/src/Source/Data/heapsort.js License: Copyright (c) 2009, Jon Bomgardner. This file is licensed under an MIT style license

You can edit the code in this block and rerun it.

Parameters

  • args Object | function optional

    Comparator Function OR Options object

    Properties
    • comparator function required

      Function used to sort the dataset, uses the same return structure as a standard JavaScript sort

    • silent Boolean required

      Default false, set true to supress the firing of a sort event.

Returns

Type: Miso.Dataset.DataView
Source

sum ( columns )

Returns: Miso.Dataset.Product|Number

If the dataset has sync enabled this will return a Miso.Dataset.Product that can be used to bind events to and access the current value. Otherwise it will return the current value - the sum of the numeric form of the values in the column.

You can edit the code in this block and rerun it.

Parameters

  • columns String | Array.<String> required

    column name(s) on which the value is calculated

Returns

Type: Miso.Dataset.Product | Number
Source

toJSON ( )

Returns: Array

Exports a version of the dataset in json format.

Returns

Array of rows.

Type: Array
Source

where ( filter, options )

Returns: Miso.Dataset.DataView

Used to create Dataviews, subsets of data based on a set of filters. Filtration can be applied to both rows & columns and for syncing datasets changes in the parent dataset from which the dataview was created will be reflected in the dataview.

You can edit the code in this block and rerun it.

Parameters

  • filter function | Object optional

    a function that takes in a row or an options object that can contain the following parameters.

    Properties
    • columns String | Array.<String> optional

      A filter for columns. A single or multiple column names.

    • filter String | function optional

      A filter for rows. A rowId or a filter function that takes in a row and returns true if it passes the criteria.

  • options Object optional

Returns

Type: Miso.Dataset.DataView
Source

Type Definitions

columnIterator

This callback is used to step through each column in a DataView

Type:
  • function
Source

rowIterator

This callback is used to step through each row in a DataView

Type:
  • function
Source