Commit 47f87a56 authored by anneb's avatar anneb

addjust classCount to max available colors

parent 98f1d353
...@@ -345,18 +345,24 @@ ...@@ -345,18 +345,24 @@
// legendTypes 'div', 'qual', 'seq' // legendTypes 'div', 'qual', 'seq'
// for diverging, qualitative and sequential legends // for diverging, qualitative and sequential legends
function getColorSchemes(numClasses, legendType) { function getColorSchemes(numClasses, legendType) {
return colorbrewer.filter(scheme=>scheme.type===legendType && scheme.sets.length > numClasses - 3) for (; numClasses > 2; numClasses--) {
let result = colorbrewer.filter(scheme=>scheme.type===legendType && scheme.sets.length > numClasses - 3)
.map(scheme=>{ .map(scheme=>{
const result = scheme.sets[numClasses - 3]; const result = scheme.sets[numClasses - 3];
result.name = scheme.name; result.name = scheme.name;
result.type = scheme.type; result.type = scheme.type;
return result; return result;
}); });
if (result.length) {
return result;
}
}
return [];
} }
function classButton(classType) { function classButton(classType) {
if (prepareLegend()) { if (prepareLegend()) {
const classCount = Number(document.querySelector('#classcount').value); let classCount = Number(document.querySelector('#classcount').value);
if (classCount === 1) { if (classCount === 1) {
// special case, single classification // special case, single classification
} else { } else {
...@@ -406,7 +412,9 @@ ...@@ -406,7 +412,9 @@
result.push(percentile); result.push(percentile);
return result; return result;
},[]); },[]);
const seqSchemes = getColorSchemes(classCount, 'qual'); const legendType = (typeof percentileBreaks[0].value === "string") ? 'qual' : 'seq';
const seqSchemes = getColorSchemes(classCount, legendType);
classCount = seqSchemes[0].colors.length;
if (classCount > percentileBreaks.length) { if (classCount > percentileBreaks.length) {
classCount = percentileBreaks.length classCount = percentileBreaks.length
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment