Commit 74f703ee authored by Anne Blankert's avatar Anne Blankert

support 2 classes, fix reclass, textual changes

parent 47f87a56
...@@ -357,6 +357,15 @@ ...@@ -357,6 +357,15 @@
return result; return result;
} }
} }
if (numClasses === 2) {
return colorbrewer.filter(scheme=>scheme.type===legendType)
.map(scheme=>{
const result = {colors: [scheme.sets[0].colors[0],scheme.sets[0].colors[2]]}
result.name = scheme.name;
result.type = scheme.type;
return result;
})
}
return []; return [];
} }
...@@ -400,7 +409,7 @@ ...@@ -400,7 +409,7 @@
let percentileBreaks = globalStats.percentiles.reduce((result, percentile)=>{ let percentileBreaks = globalStats.percentiles.reduce((result, percentile)=>{
percentile.pcount = 1; percentile.pcount = 1;
if (result.length === 0) { if (result.length === 0) {
result.push(percentile); result.push(Object.assign({}, percentile)); // spread operator not supported by current Edge
return result; return result;
} }
if (result[result.length - 1].to === percentile.from) { if (result[result.length - 1].to === percentile.from) {
...@@ -409,10 +418,10 @@ ...@@ -409,10 +418,10 @@
result[result.length - 1].pcount++; result[result.length - 1].pcount++;
return result; return result;
} }
result.push(percentile); result.push(Object.assign({}, percentile));
return result; return result;
},[]); },[]);
const legendType = (typeof percentileBreaks[0].value === "string") ? 'qual' : 'seq'; const legendType = (typeof percentileBreaks[0].from === "string") ? 'qual' : 'seq';
const seqSchemes = getColorSchemes(classCount, legendType); const seqSchemes = getColorSchemes(classCount, legendType);
classCount = seqSchemes[0].colors.length; classCount = seqSchemes[0].colors.length;
if (classCount > percentileBreaks.length) { if (classCount > percentileBreaks.length) {
...@@ -424,7 +433,7 @@ ...@@ -424,7 +433,7 @@
let sumClassCount = 0 let sumClassCount = 0
percentileBreaks = percentileBreaks.reduce((result, percentile)=>{ percentileBreaks = percentileBreaks.reduce((result, percentile)=>{
sumPCount += percentile.pcount; sumPCount += percentile.pcount;
if (sumPCount > sumClassCount * pCountPerClass) { if (sumPCount >= sumClassCount * pCountPerClass && result.length < classCount) {
// new class // new class
result.push(percentile); result.push(percentile);
sumClassCount++; sumClassCount++;
...@@ -436,10 +445,7 @@ ...@@ -436,10 +445,7 @@
return result; return result;
},[]) },[])
} }
mapboxPaint = [ mapboxPaint = ["case"]
"case"
]
percentileBreaks.forEach((brk, index, arr)=>{ percentileBreaks.forEach((brk, index, arr)=>{
addLegendLine(seqSchemes[0].colors[index], `${brk.from} - ${brk.to}`, layerType); addLegendLine(seqSchemes[0].colors[index], `${brk.from} - ${brk.to}`, layerType);
mapboxPaint.push(["<",["get", globalStats.column],brk.to],seqSchemes[0].colors[index]) mapboxPaint.push(["<",["get", globalStats.column],brk.to],seqSchemes[0].colors[index])
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
</head> </head>
<body onload="init()"> <body onload="init()">
<h1>Layers in database</h1> <h1>Layers in database</h1>
<input id="filter" type="text" placeholder="Filter.." size="20" oninput="filterLayerInfo()"><br> <input id="filter" type="text" placeholder="Search..." size="20" oninput="filterLayerInfo()"><br>
<table id="layerinfo"></table> <table id="layerinfo"></table>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -87,6 +87,6 @@ ...@@ -87,6 +87,6 @@
<h2 id="tablename"></h2> <h2 id="tablename"></h2>
<div id="bbox">waiting for table stats...</div> <div id="bbox">waiting for table stats...</div>
<ul id="columns"></ul> <ul id="columns"></ul>
<a href="info.html">Back to layer overviewe</a> <a href="info.html">Back to layer overview</a>
</body> </body>
</html> </html>
\ No newline at end of file
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