| 
									
										
										
										
											2022-07-25 18:55:15 +02:00
										 |  |  | import { VariableUiElement } from "../Base/VariableUIElement" | 
					
						
							|  |  |  | import Loading from "../Base/Loading" | 
					
						
							|  |  |  | import Title from "../Base/Title" | 
					
						
							|  |  |  | import TagRenderingChart from "./TagRenderingChart" | 
					
						
							|  |  |  | import Combine from "../Base/Combine" | 
					
						
							|  |  |  | import Locale from "../i18n/Locale" | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  | import { FeatureSourceForLayer } from "../../Logic/FeatureSource/FeatureSource" | 
					
						
							|  |  |  | import BaseUIElement from "../BaseUIElement" | 
					
						
							| 
									
										
										
										
											2022-07-25 18:55:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  | export default class StatisticsForLayerPanel extends VariableUiElement { | 
					
						
							|  |  |  |     constructor(elementsInview: FeatureSourceForLayer) { | 
					
						
							|  |  |  |         const layer = elementsInview.layer.layerDef | 
					
						
							| 
									
										
										
										
											2022-07-25 18:55:15 +02:00
										 |  |  |         super( | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  |             elementsInview.features.stabilized(1000).map( | 
					
						
							| 
									
										
										
										
											2022-07-25 18:55:15 +02:00
										 |  |  |                 (features) => { | 
					
						
							|  |  |  |                     if (features === undefined) { | 
					
						
							|  |  |  |                         return new Loading("Loading data") | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     if (features.length === 0) { | 
					
						
							|  |  |  |                         return "No elements in view" | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  |                     const els: BaseUIElement[] = [] | 
					
						
							|  |  |  |                     const featuresForLayer = features | 
					
						
							|  |  |  |                     if (featuresForLayer.length === 0) { | 
					
						
							|  |  |  |                         return | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     els.push(new Title(layer.name.Clone(), 1).SetClass("mt-8")) | 
					
						
							| 
									
										
										
										
											2022-07-25 18:55:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  |                     const layerStats = [] | 
					
						
							|  |  |  |                     for (const tagRendering of layer?.tagRenderings ?? []) { | 
					
						
							|  |  |  |                         const chart = new TagRenderingChart(featuresForLayer, tagRendering, { | 
					
						
							|  |  |  |                             chartclasses: "w-full", | 
					
						
							|  |  |  |                             chartstyle: "height: 60rem", | 
					
						
							|  |  |  |                             includeTitle: false, | 
					
						
							|  |  |  |                         }) | 
					
						
							|  |  |  |                         const title = new Title( | 
					
						
							|  |  |  |                             tagRendering.question?.Clone() ?? tagRendering.id, | 
					
						
							|  |  |  |                             4 | 
					
						
							|  |  |  |                         ).SetClass("mt-8") | 
					
						
							|  |  |  |                         if (!chart.HasClass("hidden")) { | 
					
						
							|  |  |  |                             layerStats.push( | 
					
						
							|  |  |  |                                 new Combine([title, chart]).SetClass( | 
					
						
							|  |  |  |                                     "flex flex-col w-full lg:w-1/3" | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                                 ) | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  |                             ) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                         } | 
					
						
							| 
									
										
										
										
											2022-07-25 18:55:15 +02:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  |                     els.push(new Combine(layerStats).SetClass("flex flex-wrap")) | 
					
						
							| 
									
										
										
										
											2022-07-25 18:55:15 +02:00
										 |  |  |                     return new Combine(els) | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |                 [Locale.language] | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             ) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-07-25 18:55:15 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } |