src/JsPlot3D.js
/**
     * updates the legend with new information. basically recreates the innerHTML of this.legend.element
     * @param {object} colorMap COLORLIB.getColorMap(...) information. can be null
     * @param {object} options json object containing one or more of x1title, x2title, x3title and title
     * @private
     */
updates the legend with new information. basically recreates the innerHTML of this.legend.element
@param {object} colorMap COLORLIB.getColorMap(...) information. can be null
@param {object} options json object containing one or more of x1title, x2title, x3title and title
@private
updates the legend with new information . basically recreates the innerHTML of this . legend . element @param { object } colorMap COLORLIB . getColorMap ( ... ) information . can be null @param { object } options json object containing one or more of x1title x2title x3title and title @private
populateLegend(options)
    {
        let legendHTML = ""
        if(options.title && options.title != "")
        {
            legendHTML += "<h1>"+options.title+"</h1>"
        }
        if(options.colorMap && options.colorMap.labelColorMap != {})
        {
            legendHTML += "<table class =\"jsP3D_labelColorLegend\"><tbody>" 
            for(let key in options.colorMap.labelColorMap)
            {
                legendHTML += "<tr>"
                legendHTML += "<td><span class =\"jsP3D_labelColor\" style =\"background-color:#" + options.colorMap.labelColorMap[key].color.getHexString() + ";\"></span></td>"
                legendHTML += "<td>" + key + "</td>"
                legendHTML += "</tr>"
            }
            legendHTML += "</tbody></table>"
        }
        legendHTML += "<table class =\"jsP3D_axesTitleLegend\"><tbody>"
        if(this.SceneHelper.cameraMode != LEFTCAMERA  && options.x1title) legendHTML += "<tr><td>x:</td><td>"+options.x1title+"</td></tr>"
        if(this.SceneHelper.cameraMode != TOPCAMERA   && options.x2title) legendHTML += "<tr><td>y:</td><td>"+options.x2title+"</td></tr>"
        if(this.SceneHelper.cameraMode != FRONTCAMERA && options.x3title) legendHTML += "<tr><td>z:</td><td>"+options.x3title+"</td></tr>"
        legendHTML += "</tbody></table>"
        if(this.legend.element.innerHTML.trim() != legendHTML) 
        {
            this.legend.element.innerHTML = legendHTML
        }
    }
populateLegend ( options ) { let legendHTML = "" if ( options . title && options . title != "" ) { legendHTML += "<h1>" + options . title + "</h1>" } if ( options . colorMap && options . colorMap . labelColorMap != { } ) { legendHTML += "<table class =\"jsP3D_labelColorLegend\"><tbody>" for ( let key in options . colorMap . labelColorMap ) { legendHTML += "<tr>" legendHTML += "<td><span class =\"jsP3D_labelColor\" style =\"background-color:#" + options . colorMap . labelColorMap [ key ] . color . getHexString ( ) + ";\"></span></td>" legendHTML += "<td>" + key + "</td>" legendHTML += "</tr>" } legendHTML += "</tbody></table>" } legendHTML += "<table class =\"jsP3D_axesTitleLegend\"><tbody>" if ( this . SceneHelper . cameraMode != LEFTCAMERA && options . x1title ) legendHTML += "<tr><td>x:</td><td>" + options . x1title + "</td></tr>" if ( this . SceneHelper . cameraMode != TOPCAMERA && options . x2title ) legendHTML += "<tr><td>y:</td><td>" + options . x2title + "</td></tr>" if ( this . SceneHelper . cameraMode != FRONTCAMERA && options . x3title ) legendHTML += "<tr><td>z:</td><td>" + options . x3title + "</td></tr>" legendHTML += "</tbody></table>" if ( this . legend . element . innerHTML . trim ( ) != legendHTML ) { this . legend . element . innerHTML = legendHTML } }
updates the legend with new information.
updates the legend with new information .
// update the legend with the label color information // open legend, add title // add info about the labels and the colors // label colors: // can't append to innerHTML directly for some funny reason // axes titles: // is the content similar? Then don't overwrite because it will trigger rerenders every time (observed in the chromium Elements view) // for some reason I have to trim the current innerHTML