function addHistograms(featureData) {

    let spfeatures = ["acousticness", "danceability", "energy", "instrumentalness",
        "liveness"/*, 'loudness'*/, "speechiness", "valence", "acousticness"]

    spfeatures.forEach((d, i) => {
        function nodeSelect(x) {
            return x <= 1 ? 0
                : x <= 3 ? 1
                    : x <= 5 ? 2
                        : 3;
        }
        let histHalf = document.querySelector("#hist-half").children // 4 hardcoded
        let divHalf = document.createElement('div')
        divHalf.classList.add("w3-half")
        divHalf.classList.add("plot-half")
        let plotDiv = document.createElement('div')
        plotDiv.classList.add("plot-spline-container")
        plotDiv.style.height = '100px'
        let plotCanvas = document.createElement('canvas')
        plotCanvas.id = `plot-spline-${i}`
        plotDiv.append(plotCanvas)
        divHalf.append(plotDiv)
        histHalf[nodeSelect(i)].append(divHalf)

        let histData = createHistData(featureData, d)
        console.log(histData.countsNorm)
        cjsSpline(`plot-spline-${i}`, histData)
    })
}
// Build containers, add plots and append results
Build containers, add plots and append results
Build containers add plots and append results
function addHistograms(featureData) {
    let spfeatures = ["acousticness", "danceability", "energy", "instrumentalness",
        "liveness", "speechiness", "valence", "acousticness"]
    spfeatures.forEach((d, i) => {
        function nodeSelect(x) {
            return x <= 1 ? 0
                : x <= 3 ? 1
                    : x <= 5 ? 2
                        : 3;
        }
        let histHalf = document.querySelector("#hist-half").children 
        let divHalf = document.createElement('div')
        divHalf.classList.add("w3-half")
        divHalf.classList.add("plot-half")
        let plotDiv = document.createElement('div')
        plotDiv.classList.add("plot-spline-container")
        plotDiv.style.height = '100px'
        let plotCanvas = document.createElement('canvas')
        plotCanvas.id = `plot-spline-${i}`
        plotDiv.append(plotCanvas)
        divHalf.append(plotDiv)
        histHalf[nodeSelect(i)].append(divHalf)
        let histData = createHistData(featureData, d)
        console.log(histData.countsNorm)
        cjsSpline(`plot-spline-${i}`, histData)
    })
}
function addHistograms ( featureData ) { let spfeatures = [ "acousticness" , "danceability" , "energy" , "instrumentalness" , "liveness" , "speechiness" , "valence" , "acousticness" ] spfeatures . forEach ( ( d , i ) => { function nodeSelect ( x ) { return x <= 1 ? 0 : x <= 3 ? 1 : x <= 5 ? 2 : 3 ; } let histHalf = document . querySelector ( "#hist-half" ) . children let divHalf = document . createElement ( 'div' ) divHalf . classList . add ( "w3-half" ) divHalf . classList . add ( "plot-half" ) let plotDiv = document . createElement ( 'div' ) plotDiv . classList . add ( "plot-spline-container" ) plotDiv . style . height = '100px' let plotCanvas = document . createElement ( 'canvas' ) plotCanvas . id = ` ${ i } ` plotDiv . append ( plotCanvas ) divHalf . append ( plotDiv ) histHalf [ nodeSelect ( i ) ] . append ( divHalf ) let histData = createHistData ( featureData , d ) console . log ( histData . countsNorm ) cjsSpline ( ` ${ i } ` , histData ) } ) }
Build containers, add plots and append results
Build containers add plots and append results
/*, 'loudness'*/ // 4 hardcoded