src/JsPlot3D.js
/**
     * Instead of passing one single array of data, you can select three different arrays. X[n], Y[n], Z[n] is treated as the n-th datapoint.
     * labels[n] is the label of this datapoint, that is used for coloration. All those 4 arrays should have the same length. Only as many points can
     * be plotted as the shortest array's length.
     * @param {number} X Array of X-Values [1, 2, 0.6, 3]
     * @param {number} Y Array of Y-Values []
     * @param {number} Z Array of Z-Values []
     * @param {number} labels Array of labels, e.g. ["Tree", "Bird", "Fox", "Fox", "Dog", "Tree"] or [1, 2, 3, 1, 2, 2, 1].
     * - When this parameter is defined, the default value of options.colorCol is set to the column of labels (3).
     * But it can also be overwritten to one of 0, 1 or 2 by using the options parameter
     * - Default: []
     * @param {object} options same as the options parameter in plotDataFrame
     */
Instead of passing one single array of data, you can select three different arrays.
Instead of passing one single array of data you can select three different arrays .
plotArrays(X, Y, Z, labels=[], options={})
    {
        let length = Math.min(X.length, Y.length, Z.length)
        let df = new Array(length)
        let attributes = 3
        if(labels.length !== 0)
        {
            length = Math.min(length, labels.length)
            if(options.colorCol === undefined) options.colorCol = 3
            attributes = 4
        }
        for(let i = 0; i < length; i++)
        {
            df[i] = new Array(attributes)
            df[i][0] = X[i]
            df[i][1] = Y[i]
            df[i][2] = Z[i]
        }
        if(labels.length !== 0)
        {
            for(let i = 0; i < length; i++)
            {
                df[i][3] = labels[i]
            }
        }
        this.plotDataFrame(df, 0, 1, 2, options)
    }
plotArrays ( X , Y , Z , labels = [ ] , options = { } ) { let length = Math . min ( X . length , Y . length , Z . length ) let df = new Array ( length ) let attributes = 3 if ( labels . length !== 0 ) { length = Math . min ( length , labels . length ) if ( options . colorCol === undefined ) options . colorCol = 3 attributes = 4 } for ( let i = 0 ; i < length ; i ++ ) { df [ i ] = new Array ( attributes ) df [ i ] [ 0 ] = X [ i ] df [ i ] [ 1 ] = Y [ i ] df [ i ] [ 2 ] = Z [ i ] } if ( labels . length !== 0 ) { for ( let i = 0 ; i < length ; i ++ ) { df [ i ] [ 3 ] = labels [ i ] } } this . plotDataFrame ( df , 0 , 1 , 2 , options ) }
Instead of passing one single array of data, you can select three different arrays.
Instead of passing one single array of data you can select three different arrays .
// how many datapoints // this is going to be filled with datapoints // TODO new Float32Array when the array contains integers (see GitHub issue #16, might contain strings at some point in the future) // how many attributes(x, y, z and maybe labels) each datapoint has // if labels is defined, assume that as colorCol and add it to the dataframe // TODO I wonder if this is faster when using webassembly? // transpose [X, Y, Z] // add the labels