Line chart doesn't show in Object Page - Vizframe - SAPUI5 - charts

I am trying to make a line chart using Vizframe in an Object Page. Does anybody have an example how to do it? I searched the APIs and the sdn but find just samples with Layout element and not Object Page Layout element.
So when I test it within a simple Layout element (< layout > element) the line charts works fine. But when I try it with Object Page Layout elementt, the chart doesn't show and there is no errors in the console.
Thanks a lot,
Haylee N.
I joined the two different views here:
View.xml with Layout element ( that works )
<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core"
xmlns:u="sap.uxap" xmlns:layout="sap.ui.layout" xmlns="sap.m" xmlns:f="sap.f"
xmlns:t="sap.ui.table" xmlns:viz="sap.viz.ui5.controls" xmlns:viz.data="sap.viz.ui5.data"
xmlns:viz.feeds="sap.viz.ui5.controls.common.feeds" xmlns:sample="test.controller.ChartsOverview"
xmlns:goals="test.view.goals" controllerName="test.controller.ChartsOverview"
height="100%">
<Page title="SAPUI5 App">
<layout:FixFlex id='chartFixFlex' minFlexSize="250">
<layout:fixContent>
<Panel id='settingsPanel' class="panelStyle" expandable="true"
expanded="true" headerText="Summary" width="auto">
<content>
<HBox class='settingsHBox'>
<VBox width="200px">
<Label text='Reports' design="Bold" class='settingsLabel'></Label>
</VBox>
</HBox>
</content>
</Panel>
</layout:fixContent>
<layout:flexContent>
<viz:Popover id="idPopOver"></viz:Popover>
<viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
height='50%' width="50%" vizType='timeseries_line'>
<viz:dataset>
<viz.data:FlattenedDataset data="{/milk}">
<viz.data:dimensions>
<viz.data:DimensionDefinition name="Date"
value="{Date}" dataType="date" />
</viz.data:dimensions>
<viz.data:measures>
<viz.data:MeasureDefinition name="Revenue"
value="{Revenue}" />
</viz.data:measures>
</viz.data:FlattenedDataset>
</viz:dataset>
<viz:feeds>
<viz.feeds:FeedItem uid="valueAxis" type="Measure"
values="Revenue" />
<viz.feeds:FeedItem uid="timeAxis" type="Dimension"
values="Date" />
</viz:feeds>
</viz:VizFrame>
</layout:flexContent>
</layout:FixFlex>
</Page>
</mvc:View>
View.xml with Object Page Layout element ( that doesn't work )
<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core"
xmlns="sap.uxap" xmlns:layout="sap.ui.layout" xmlns:m="sap.m" xmlns:f="sap.f"
xmlns:t="sap.ui.table" xmlns:viz="sap.viz.ui5.controls" xmlns:viz.data="sap.viz.ui5.data"
xmlns:viz.feeds="sap.viz.ui5.controls.common.feeds" xmlns:sample="test.controller.ChartsOverview"
xmlns:goals="test.view.goals" controllerName="test.controller.ChartsOverview"
height="100%">
<m:Page showHeader="true" title="{i18n>appTitle}" showFooter="true"
showNavButton="false">
<ObjectPageLayout id="ObjectPageLayout"
enableLazyLoading="false" subSectionLayout="TitleOnLeft"
showTitleInHeaderContent="true" showHeaderContent="true">
<headerTitle>
<ObjectPageHeader objectTitle="Quality Monitor"
objectSubtitle="Reports based on errors processed"
isObjectIconAlwaysVisible="false" isObjectTitleAlwaysVisible="false"
isObjectSubtitleAlwaysVisible="false" isActionAreaAlwaysVisible="true"
id="ObjectPageLayoutHeaderTitle">
<actions>
</actions>
</ObjectPageHeader>
</headerTitle>
<sections>
<ObjectPageSection title="Charts">
<subSections>
<ObjectPageSubSection>
<blocks>
<viz:Popover id="idPopOver"></viz:Popover>
<viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
height='50%' width="50%" vizType='timeseries_line'>
<viz:dataset>
<viz.data:FlattenedDataset data="{/milk}">
<viz.data:dimensions>
<viz.data:DimensionDefinition
name="Date" value="{Date}" dataType="date" />
</viz.data:dimensions>
<viz.data:measures>
<viz.data:MeasureDefinition name="Revenue"
value="{Revenue}" />
</viz.data:measures>
</viz.data:FlattenedDataset>
</viz:dataset>
<viz:feeds>
<viz.feeds:FeedItem uid="valueAxis" type="Measure"
values="Revenue" />
<viz.feeds:FeedItem uid="timeAxis" type="Dimension"
values="Date" />
</viz:feeds>
</viz:VizFrame>
</blocks>
</ObjectPageSubSection>
</subSections>
</ObjectPageSection>
</sections>
</ObjectPageLayout>
</m:Page>
</mvc:View>

Whoever may come here for an answer, giving the height of vizframe with pixels does the trick.

As pointed by people in this question some controls use adaptive containers that adapt height to fit their content. If that content uses "100%" of height (which is initially 0) the content efectively becomes 0px and those controls end up adapting their hight to 0px height of the content. For the same reason if you use fixed height instead of a percentage it actually works.
For me personally, this problem only occurred because I blindly copied sample code for VizFrame into IconTabBar container, without realizing the difference in containers used.
Solution to my problem: remove the height="100%" property from VizFrame, which will not force height and in turn will allow the height of VizFrame to be calculated based on its content (title, actual chart, legend and such), instead of container that VizFrame is placed into.

Related

Error: Cannot add direct child without default aggregation defined for control sap.f.cards.Header

I'm trying to add the custom data aggregation to a card control header. I've tried a lot of things but nothing seems to work, I'm always getting the same error:
Cannot add direct child without default aggregation defined for control sap.f.cards.Header
I also tried attaching the aggregation through the controller an it worked fine but I need it in my XML view.
This is my code:
<mvc:View controllerName="Dashboard2.Dashboard2.controller.View2" xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m"
xmlns:f="sap.f" xmlns:w="sap.ui.integration.widgets" xmlns:card="sap.f.cards" xmlns:layout="sap.ui.layout"
xmlns:core="sap.ui.core.customData" xmlns:viz.feeds="sap.viz.ui5.controls.common.feeds" xmlns:viz.data="sap.viz.ui5.data"
xmlns:viz="sap.viz.ui5.controls">
<ScrollContainer height="100%" width="100%" vertical="true">
<f:GridContainer snapToRow="false" id="containerid">
<f:layout>
<f:GridContainerSettings rowSize="84px" columnSize="84px" gap="6px"/>
</f:layout>
<f:layoutXS>
<f:GridContainerSettings rowSize="70px" columnSize="70px" gap="6px"/>
</f:layoutXS>
<f:Card class="sapUiMediumMargin" width="300px" height="23rem" id="batchlectura">
<f:layoutData>
<f:GridContainerItemLayoutData columns="4"/>
</f:layoutData>
<f:header>
<card:Header title="{datos>Proceso}" subtitle="{path:'datos>Hora', formatter:'.formatter.Hour' }" iconSrc="sap-icon://insurance-house"
statusText="{path:'datos>Estatus', formatter:'.formatter.Estatus'}">
<customData>
<core:CustomData key="Name" value="Contactname"/>
</customData>
</card:Header>
</f:header>
<f:content>
<viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}" height='100%' width="100%" vizType='column'>
<viz:dataset>
<viz.data:FlattenedDataset data="{datos>/results}">
<viz.data:dimensions>
<viz.data:DimensionDefinition name="Week" value="1"/>
</viz.data:dimensions>
<viz.data:measures>
<viz.data:MeasureDefinition name="Estimado" value="{datos>Estimado}"/>
<viz.data:MeasureDefinition name="Actual" value="{datos>Actual}"/>
</viz.data:measures>
</viz.data:FlattenedDataset>
</viz:dataset>
<viz:feeds>
<viz.feeds:FeedItem id='valueAxisFeed' uid="valueAxis" type="Measure" values="Estimado"/>
<viz.feeds:FeedItem id='valueAxisFeed2' uid="valueAxis" type="Measure" values="Actual"/>
<viz.feeds:FeedItem id='categoryAxisFeed' uid="categoryAxis" type="Dimension" values="Week"/>
</viz:feeds>
</viz:VizFrame>
</f:content>
</f:Card>
</f:GridContainer>
</ScrollContainer>
</mvc:View>
Nothing seems to work.
I hope someone can help me.
I believe <customData> should be <card:customData> otherwise the default namespace which is sap/m will be used.

Removing gap between chart cloumns in ui5

I am working on sap fiori project which displays data in chart format. In a dual series chart, I want to remove the gap in between columns, which you can see below:
I tried searching for attributes for vizframe.
<layout:flexContent>
<viz:Popover id="idPopOver"></viz:Popover>
<viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
height='100%' width="100%" vizType='column'>
<viz:dataset>
<viz.data:FlattenedDataset data="{/milk}">
<viz.data:dimensions>
<viz.data:DimensionDefinition name="Week"
value="{Week}" />
</viz.data:dimensions>
<viz.data:measures>
<viz.data:MeasureDefinition name="Revenue"
value="{Revenue}" />
<viz.data:MeasureDefinition name="Cost"
value="{Cost}" />
</viz.data:measures>
</viz.data:FlattenedDataset>
</viz:dataset>
<viz:feeds>
<viz.feeds:FeedItem id='valueAxisFeed' uid="valueAxis" type="Measure"
values="Revenue" />
<viz.feeds:FeedItem id='categoryAxisFeed' uid="categoryAxis" type="Dimension"
values="Week" />
</viz:feeds>
</viz:VizFrame>
</layout:flexContent>
You can use the vizProperties and set plotArea => gap => innerGroupSpacing
<viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
height='100%' width="100%" vizType='column'
vizProperties="{ plotArea : {gap: {innerGroupSpacing:0}} }">

Not displayed everything from content in GenericTile

I am using OpenUI5, this is my code:
<GenericTile headerText="Header" subheader="Subheader" size="M" frameType="TwoByOne" press="press">
<tileContent>
<TileContent>
<content>
<Title text="Title" />
<NumericContent size="S" scale="M" value="{/para2}" valueColor="Error" indicator="Up" />
<Text text="Text1" />
<Link text="Link" press="viewMore" />
</content>
</TileContent>
</tileContent>
</GenericTile>
and all what I see is:
Why it doesn't display NumericContent, Text and Title?
As I noticed it only displaying the last element of content - it depends on order these elements.
Refer to this answer.
In short:
This is happening because content in sap.m.TileContent aggregations has the cardinality of 0..1 where 0 is the minimum cardinality, and 1 is the maximum cardinality. This means you can only have a single item inside the content property and so the Tile will only display the last element defined in your view.
You can work around this issue by adding a Sap.m.VBox inside your tile content like this:
<GenericTile subheader="Subheader" frameType="TwoByOne" press="press">
<TileContent>
<content>
<VBox>
<Title text="Title"/>
<NumericContent scale="M" value="{/para2}" valueColor="Error" indicator="Up"/>
<Text text="Text1"/>
<Link text="Link" press="viewMore"/>
</VBox>
</content>
</TileContent>
</GenericTile>
Although I really would advise you not to do this but instead use the properties on sap.m.TileContent such as footer and unit where you can insert text and number details to your Tile.

Why Does Object Page Section Title Come in Capital Letters and How to Disable It

When I try to add ObjectPageSection inside <sections> of an ObjectPageLayout, I see the title coming in capital letters.
Could anyone explain why? I would like to show it as title-cased.
Here is the snippet of the code:
<mvc:View
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.uxap"
xmlns:layout="sap.ui.layout"
xmlns:m="sap.m"
xmlns:blockcolor="sap.uxap.sample.SharedBlocks"
controllerName="personal.controller.Object"
height="100%"
>
<ObjectPageLayout id="ObjectPageLayout"
enableLazyLoading="false"
showAnchorBarPopover="false"
showFooter="true"
>
<headerTitle>
<ObjectPageHeader objectTitle="{DataAgingGroupName}"/>
</headerTitle>
<sections>
<ObjectPageSection title="Section 2">
<subSections>
<ObjectPageSubSection title="Deletable Data Subjects">
<blocks>
<Table xmlns="sap.m" id="table"
mode="SingleSelectLeft"
width="auto"
items="{invoice>/Invoices}"
noDataText="{worklistView>/tableNoDataText}"
busyIndicatorDelay="{worklistView>/tableBusyDelay}"
growing="true"
growingScrollToLoad="true"
updateFinished="onUpdateFinished"
>
<columns>
<Column id="nameColumn1">
<Text text="Data Subject"/>
</Column>
</columns>
<items>
<ColumnListItem
type="Navigation"
press="onPress"
>
<cells>
<Text id="__picker0"
text="{invoice>ProductName}"
width="100%"
/>
</cells>
</ColumnListItem>
</items>
</Table>
</blocks>
</ObjectPageSubSection>
</subSections>
</ObjectPageSection>
<ObjectPageSection title="Section 1">
<subSections>
<ObjectPageSubSection title="General Information"/>
</subSections>
</ObjectPageSection>
</sections>
<footer>
<m:OverflowToolbar>
<m:ToolbarSpacer/>
<m:Button
text="Delete"
type="Reject"
press="handleDelete"
/>
</m:OverflowToolbar>
</footer>
</ObjectPageLayout>
</mvc:View>
You can, and you should if you're following the Fiori Guidelines, disable the uppercase via upperCaseAnchorBar since the default value is true there. The same goes for the <ObjectPageSection> which has the property titleUppercase enabled by default. So, disable them explicitly:
<ObjectPageLayout upperCaseAnchorBar="false" ...>
<sections>
<ObjectPageSection titleUppercase="false" ...>
The <ObjectPageSubSection>, on the other hand, provides the property titleUppercase too, but its default value is already false there.
It comes from the css
.sapUxAPObjectPageSectionTitleUppercase {
text-transform: uppercase;
}
:)

SplitApp Container under ICONTAB Bar

Why is It not possible to add a SplitApp Container as an aggregation for ICONTab Bar. I have tried to add the splitApp under ICONTAB Bar and it is working. But it is not working with SplitApp Container.
<mvc:View controllerName="com.sap.controller.Main"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<App>
<pages>
<Page title="{i18n>title}">
<content>
<IconTabBar id="idIconTabBar" select="handleIconTabBarSelect"
class="sapUiResponsiveContentPadding">
<items>
<IconTabFilter>
<content></content>
</IconTabFilter>
<IconTabFilter>
<content>
<SplitApp id="SplitContDemo1" initialDetail="detail" initialMaster="master">
<detailPages>
<Page id="detail" title="Detail 1" class="sapUiStdPage">
<content>
<Label text="Detail page 1"/>
<Button text="Go to Detail page2" press="onPressNavToDetail"/>
</content>
</Page>
</detailPages>
<masterPages>
<Page id="master" title="Master 1" icon="sap-icon://action"
class="sapUiStdPage">
<content>
<List>
<items>
<StandardListItem title="To Master2" type="Navigation"
press="onPressGoToMaster"/>
</items>
</List>
</content>
</Page>
</masterPages>
</SplitApp>
</content>
</IconTabFilter>
</items>
</IconTabBar>
<SplitContainer id="SplitContDemo">
<detailPages>
<Button text="Detailed Button"/>
</detailPages>
<masterPages>
<Button text="Master Button"/>
</masterPages>
</SplitContainer>
</content>
</Page>
</pages>
</App>
</mvc:View>
Regards,
MS
It is not very clear what your problem is exactly. You can put anything inside the content aggregation of an IconTabFilter. In the items aggregation of an IconTabBar you can only put IconTabFilters and IconTabSeparators.
I have checked your example and made it to work by putting the Split Container inside an IconTabFilter: https://jsfiddle.net/enykp4h8/1/.
<IconTabFilter text="Split Container">
<SplitContainer id="SplitContDemo">
<detailPages>
<Button text="Detailed Button" />
</detailPages>
<masterPages>
<Button text="Master Button" />
</masterPages>
</SplitContainer>
</IconTabFilter>
Later update:
If you put the SplitContainer alone in the IconTabBar, it will seem as though it does not work because the tab's content has 0 height. This is because the SplitContainer has a height 100% of its parent element whilst the tab's height is determined based on the height of its children (so they are somehow codependent).
To go around this you can either use some custom CSS to give the container a fixed height or you can ask the IconTabBar to stretch to its parent's height (using stretchContentHeight):
CSS Solution:
.fixContHeight.sapMSplitContainer {
height: 300px
}
<SplitContainer id="SplitContDemo" class="fixContHeight" >
<!-- the pages... -->
</SplitContainer>
Stretch Content Solution:
<IconTabBar id="idIconTabBar" select="handleIconTabBarSelect"
class="sapUiResponsiveContentPadding" stretchContentHeight="true">
<items>
<IconTabFilter text="Split Container">
<SplitContainer id="SplitContDemo">
<detailPages>
<Button text="Detailed Button" />
</detailPages>
<masterPages>
<Button text="Master Button" />
</masterPages>
</SplitContainer>
</IconTabFilter>
<items>
</IconTabBar>