forked from MapComplete/MapComplete
Small tweaks
This commit is contained in:
parent
3a158a6155
commit
141d5330a7
1 changed files with 50 additions and 38 deletions
|
@ -36,14 +36,20 @@ export class PreviewPanel extends Combine implements FlowStep<{ features: { prop
|
||||||
for (const key of Array.from(propertyKeys)) {
|
for (const key of Array.from(propertyKeys)) {
|
||||||
|
|
||||||
const values = Utils.NoNull(geojson.features.map(f => f.properties[key]))
|
const values = Utils.NoNull(geojson.features.map(f => f.properties[key]))
|
||||||
|
console.log("There are ",values.length,"features with attribute",key, "namely",values)
|
||||||
const allSame = !values.some(v => v !== values[0])
|
const allSame = !values.some(v => v !== values[0])
|
||||||
|
let countSummary: BaseUIElement
|
||||||
|
if (values.length === n) {
|
||||||
|
countSummary = t.allAttributesSame
|
||||||
|
} else {
|
||||||
|
countSummary = t.someHaveSame.Subs({
|
||||||
|
count: values.length,
|
||||||
|
percentage: Math.floor(100 * values.length / n)
|
||||||
|
})
|
||||||
|
}
|
||||||
if (allSame) {
|
if (allSame) {
|
||||||
attributeOverview.push(new Title(key + "=" + values[0]))
|
attributeOverview.push(new Title(key + "=" + values[0]))
|
||||||
if(values.length === n){
|
attributeOverview.push(countSummary)
|
||||||
attributeOverview.push(t.allAttributesSame)
|
|
||||||
}else{
|
|
||||||
attributeOverview.push(t.someHaveSame.Subs({count: values.length, percentage: Math.floor(100 * values.length / n)}))
|
|
||||||
}
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,15 +57,18 @@ export class PreviewPanel extends Combine implements FlowStep<{ features: { prop
|
||||||
if (uniqueCount !== values.length) {
|
if (uniqueCount !== values.length) {
|
||||||
attributeOverview.push()
|
attributeOverview.push()
|
||||||
// There are some overlapping values: histogram time!
|
// There are some overlapping values: histogram time!
|
||||||
let hist : BaseUIElement = new Histogram(
|
let hist: BaseUIElement =
|
||||||
|
new Combine([
|
||||||
|
countSummary,
|
||||||
|
new Histogram(
|
||||||
new UIEventSource<string[]>(values),
|
new UIEventSource<string[]>(values),
|
||||||
"Value",
|
"Value",
|
||||||
"Occurence",
|
"Occurence",
|
||||||
{
|
{
|
||||||
sortMode: "count-rev"
|
sortMode: "count-rev"
|
||||||
}
|
})
|
||||||
|
]).SetClass("flex flex-col")
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
const title = new Title(key + "=*")
|
const title = new Title(key + "=*")
|
||||||
if (uniqueCount > 15) {
|
if (uniqueCount > 15) {
|
||||||
|
@ -78,7 +87,10 @@ export class PreviewPanel extends Combine implements FlowStep<{ features: { prop
|
||||||
// All values are different, we add a boring (but collapsable) list
|
// All values are different, we add a boring (but collapsable) list
|
||||||
attributeOverview.push(new Toggleable(
|
attributeOverview.push(new Toggleable(
|
||||||
new Title(key + "=*"),
|
new Title(key + "=*"),
|
||||||
|
new Combine([
|
||||||
|
countSummary,
|
||||||
new List(values)
|
new List(values)
|
||||||
|
])
|
||||||
))
|
))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue