<!--
/**
 * OData v4 Chart

 * mandatory parameters:
 * @param metadataContext:collection mandatory context to a collection (entitySet or 1:n navigation)
 * @param metadataContext:presentation mandatory context to a presentation (UI.Chart w or w/o qualifier / PV)
 * optional parameters:
 * @param [id] of the chart
 * @param [data] binding information for chart - if not specified it is created from the metadata information
 * @param [chartType] the chart type (Column, Bar, etc.) - if not specified chartType is picked from the metadata information
 * @param [header] the header of the chart - if not specified it is picked up from the metadata information
 * @param [height] the height of the chart / Default - 400px
 * @param [width] the width of the chart / Default - 1000px
 * @param [selectionMode] Specifies the selection mode (None,Single,Multi,Auto) / Default: None - should be Auto
 */
-->

<core:FragmentDefinition xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"
						 xmlns:mdc="sap.ui.mdc"
						 xmlns:core="sap.ui.core"
						 xmlns:chart="sap.ui.mdc.chart"
						 template:require="{
							HELPER: 'sap/fe/macros/ChartHelper'
						}">

	<mdc:Chart
			id="{this>id}"
			data="{= ${this>data} || '{path: \'/' + ${collection>@sapui.name} + '\''} }"
			chartType="{= ${this>chartType} || HELPER.formatChartType(${$presentation>ChartType})}"
			header="{= ${this>header} || ${presentation>Title} }"
			height="{this>height}"
			width="{this>width}"
			selectionMode="{this>selectionMode}" metadataDelegate="sap/fe/macros/ChartDelegate">
		<mdc:items>
			<template:with path="presentation>" helper="HELPER.formatDimensions" var="dimensions">
				<template:repeat list="{dimensions>}" var="dimension">
					<chart:DimensionItem
							id="{this>id}__{dimension>key}"
							key="{dimension>key}"
							label="{dimension>label}"
							role="{dimension>role}"
							criticality="{dimension>criticality}"/>
				</template:repeat>
			</template:with>
			<template:with path="presentation>" helper="HELPER.formatMeasures" var="measures">
				<template:repeat list="{measures>}" var="measure">
					<chart:MeasureItem
							id="{this>id}__{measure>key}"
							key="{measure>key}" propertyPath="{measure>propertyPath}"
							label="{measure>label}"
							role="{measure>role}" aggregationMethod="{measure>aggregationMethod}"
							dataPoint="{measure>dataPoint}" />
				</template:repeat>
			</template:with>
		</mdc:items>
	</mdc:Chart>
</core:FragmentDefinition>
