function colorScale(nodeMetric, treeIndex) {
            var curMetric = d3.select(element).select('#metricSelect').property('value');
            if (treeIndex == -1) {
                var colorSchemeUsed = setColors(treeIndex);
                var metric_range = forestMinMax[curMetric].max - forestMinMax[curMetric].min;
                var proportion_of_total = (nodeMetric - forestMinMax[curMetric].min) / metric_range;
            } else {
                var colorSchemeUsed = setColors(treeIndex);
                var metric_range = forestMetrics[treeIndex][curMetric].max - forestMetrics[treeIndex][curMetric].min;
                var proportion_of_total = nodeMetric / 1;

                if (metric_range != 0) {
                    proportion_of_total = (nodeMetric - forestMetrics[treeIndex][curMetric].min) / metric_range;
                }
            }

            if (proportion_of_total > 0.9) {
                return colorSchemeUsed[0];
            }
            if (proportion_of_total > 0.7) {
                return colorSchemeUsed[1];
            }
            if (proportion_of_total > 0.5) {
                return colorSchemeUsed[2];
            }
            if (proportion_of_total > 0.3) {
                return colorSchemeUsed[3];
            }
            if (proportion_of_total > 0.1) {
                return colorSchemeUsed[4];
            } else {
                return colorSchemeUsed[5];
            }
        }
// Update colorScale with min and max
Update colorScale with min and max
Update colorScale with min and max
function colorScale(nodeMetric, treeIndex) {
            var curMetric = d3.select(element).select('#metricSelect').property('value');
            if (treeIndex == -1) {
                var colorSchemeUsed = setColors(treeIndex);
                var metric_range = forestMinMax[curMetric].max - forestMinMax[curMetric].min;
                var proportion_of_total = (nodeMetric - forestMinMax[curMetric].min) / metric_range;
            } else {
                var colorSchemeUsed = setColors(treeIndex);
                var metric_range = forestMetrics[treeIndex][curMetric].max - forestMetrics[treeIndex][curMetric].min;
                var proportion_of_total = nodeMetric / 1;
                if (metric_range != 0) {
                    proportion_of_total = (nodeMetric - forestMetrics[treeIndex][curMetric].min) / metric_range;
                }
            }
            if (proportion_of_total > 0.9) {
                return colorSchemeUsed[0];
            }
            if (proportion_of_total > 0.7) {
                return colorSchemeUsed[1];
            }
            if (proportion_of_total > 0.5) {
                return colorSchemeUsed[2];
            }
            if (proportion_of_total > 0.3) {
                return colorSchemeUsed[3];
            }
            if (proportion_of_total > 0.1) {
                return colorSchemeUsed[4];
            } else {
                return colorSchemeUsed[5];
            }
        }
function colorScale ( nodeMetric , treeIndex ) { var curMetric = d3 . select ( element ) . select ( '#metricSelect' ) . property ( 'value' ) ; if ( treeIndex == - 1 ) { var colorSchemeUsed = setColors ( treeIndex ) ; var metric_range = forestMinMax [ curMetric ] . max - forestMinMax [ curMetric ] . min ; var proportion_of_total = ( nodeMetric - forestMinMax [ curMetric ] . min ) / metric_range ; } else { var colorSchemeUsed = setColors ( treeIndex ) ; var metric_range = forestMetrics [ treeIndex ] [ curMetric ] . max - forestMetrics [ treeIndex ] [ curMetric ] . min ; var proportion_of_total = nodeMetric / 1 ; if ( metric_range != 0 ) { proportion_of_total = ( nodeMetric - forestMetrics [ treeIndex ] [ curMetric ] . min ) / metric_range ; } } if ( proportion_of_total > 0.9 ) { return colorSchemeUsed [ 0 ] ; } if ( proportion_of_total > 0.7 ) { return colorSchemeUsed [ 1 ] ; } if ( proportion_of_total > 0.5 ) { return colorSchemeUsed [ 2 ] ; } if ( proportion_of_total > 0.3 ) { return colorSchemeUsed [ 3 ] ; } if ( proportion_of_total > 0.1 ) { return colorSchemeUsed [ 4 ] ; } else { return colorSchemeUsed [ 5 ] ; } }
Update colorScale with min and max
Update colorScale with min and max