<mvc:View controllerName="VizFrameCharts.controller.View1" xmlns:chart="sap.suite.ui.commons" xmlns:core="sap.ui.core"
xmlns:form="sap.ui.layout.form" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:layout="sap.ui.layout" xmlns:mvc="sap.ui.core.mvc"
xmlns:viz="sap.viz.ui5.controls" xmlns:vizData="sap.viz.ui5.data" xmlns:vizFeeds="sap.viz.ui5.controls.common.feeds" xmlns="sap.m">
<App>
<pages>
<Page title="{i18n>Stacked Bar/Column chart example}">
<content>
<chart:ChartContainer autoAdjustHeight="true" id="chartContainer" title="Reports">
<chart:ChartContainerContent icon="sap-icon://horizontal-stacked-chart" title="Stacked_bar Chart">
<chart:content>
<viz:VizFrame height="" id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
vizProperties="{plotArea: { drawingEffect: 'glossy'}, title:{ text:'Data analysis through Reports'},dataLabel:{visible:true,showTotal:true}}"
vizType="stacked_bar">
<viz:dataset>
<vizData:FlattenedDataset data="{/Reports}">
<vizData:dimensions>
<vizData:DimensionDefinition name="Year" value="{Year}"/>
</vizData:dimensions>
<vizData:measures>
<vizData:MeasureDefinition name="SAP" value="{SAP}"/>
<vizData:MeasureDefinition name="SAPUI5" value="{SAPUI5}"/>
<vizData:MeasureDefinition name="SAP ABAP" value="{SAP ABAP}"/>
<vizData:MeasureDefinition name="JAVA" value="{JAVA}"/>
</vizData:measures>
</vizData:FlattenedDataset>
</viz:dataset>
<viz:feeds>
<vizFeeds:FeedItem type="Measure" uid="valueAxis" values="JAVA,SAP ABAP,SAPUI5,SAP"/>
<vizFeeds:FeedItem type="Dimension" uid="categoryAxis" values="Year"/>
</viz:feeds>
</viz:VizFrame>
</chart:content>
</chart:ChartContainerContent>
</chart:ChartContainer>
</content>
</Page>
</pages>
</App>
</mvc:View>
{
"Reports": [{
"Year": "2017",
"SAP": 100,
"SAPUI5": 100,
"ABAP": 200,
"JAVA": 200
}, {
"Year": "2018",
"SAP": 200,
"SAPUI5": 50,
"ABAP": 200,
"JAVA": 200
}, {
"Year": "2019",
"SAP": 200,
"SAPUI5": 50,
"ABAP": 200,
"JAVA": 200
}, {
"Year": "2020",
"SAP": 200,
"SAPUI5": 100,
"ABAP": 200,
"JAVA": 200
}
]
}
onInit: function() {
var jsonData = new sap.ui.model.json.JSONModel("model/Data.json");
var oVizFrame = this.getView().byId("idVizFrame");
oVizFrame.setModel(jsonData);
}
onInit: function() {
SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function(elem) {
return elem.getScreenCTM().inverse().multiply(this.getScreenCTM());
};
var jsonData = new sap.ui.model.json.JSONModel("model/Data.json");
var oVizFrame = this.getView().byId("idVizFrame");
oVizFrame.setVizProperties({
plotArea: {
colorPalette: d3.scale.category20().range(),
dataLabel: {
showTotal: true
}
},
tooltip: {
visible: true
},
title: {
text: "Stacked Bar Chart"
}
});
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions: [{
name: "Year",
value: "{Year}"
}],
measures: [{
name: "SAP",
value: "{SAP}"
}, {
name: "SAPUI5",
value: "{SAPUI5}"
}, {
name: "ABAP",
value: "{ABAP}"
}, {
name: "JAVA",
value: "{JAVA}"
}],
data: {
path: "/Reports"
}
});
oVizFrame.setDataset(oDataset);
oVizFrame.setModel(jsonData);
var oFeedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
"uid": "valueAxis",
"type": "Measure",
"values": ["SAP"]
}),
oFeedValueAxis1 = new sap.viz.ui5.controls.common.feeds.FeedItem({
"uid": "valueAxis",
"type": "Measure",
"values": ["SAPUI5"]
}),
oFeedValueAxis2 = new sap.viz.ui5.controls.common.feeds.FeedItem({
"uid": "valueAxis",
"type": "Measure",
"values": ["ABAP"]
}),
oFeedValueAxis3 = new sap.viz.ui5.controls.common.feeds.FeedItem({
"uid": "valueAxis",
"type": "Measure",
"values": ["JAVA"]
}),
oFeedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
"uid": "categoryAxis",
"type": "Dimension",
"values": ["Year"]
});
oVizFrame.addFeed(oFeedValueAxis);
oVizFrame.addFeed(oFeedValueAxis1);
oVizFrame.addFeed(oFeedValueAxis2);
oVizFrame.addFeed(oFeedValueAxis3);
oVizFrame.addFeed(oFeedCategoryAxis);
}
<viz:VizFrame height="" id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
vizProperties="{plotArea: { drawingEffect: 'glossy'}, title:{ text:'Data analysis through Reports'},dataLabel:{visible:true,showTotal:true}}"
vizType="stacked_bar">
<chart:ChartContainer autoAdjustHeight="true" id="chartContainer" showFullScreen="true" title="Reports">
<chart:ChartContainerContent icon="sap-icon://table-view" title="Table">
<chart:content>
<Table id="chartContainerContentTable" items="{ path: '/Reports' }">
<columns>
<Column demandPopin="true">
<Label design="Bold" text="{i18n>Year}"/></Column>
<Column demandPopin="true">
<Label design="Bold" text="{i18n>SAP}"/></Column>
<Column demandPopin="true">
<Label design="Bold" text="{i18n>SAPUI5}"/></Column>
<Column demandPopin="true">
<Label design="Bold" text="{i18n>ABAP}"/></Column>
<Column demandPopin="true">
<Label design="Bold" text="{i18n>JAVA}"/></Column>
</columns>
<ColumnListItem press="">
<Text text="{Year}"></Text>
<Text text="{SAP}"></Text>
<Text text="{SAPUI5}"></Text>
<Text text="{ABAP}"></Text>
<Text text="{JAVA}"></Text>
</ColumnListItem>
</Table>
</chart:content>
</chart:ChartContainerContent>
var oVizFrameDataForTable = this.getView().byId("chartContainerContentTable");
oVizFrameDataForTable.setModel(sampleDatajson);
<Panel class="panelStyle" expandable="true" expanded="true" headerText="Settings" id='settingsPanel' width="auto">
<content>
<HBox class="sapUiSmallMarginBegin">
<VBox class='settingsBox'>
<Label design="Bold" text="{i18n>valueLabel}"></Label>
<Switch change='onDataLabelChanged' state="true">
<layoutData>
<FlexItemData growFactor="1"/>
</layoutData>
</Switch>
</VBox>
<VBox class="sapUiMediumMarginBegin">
<Label design="Bold" text="{i18n>sumValueLabel}"></Label>
<Switch change='onSumLabelChanged' state="false">
<layoutData>
<FlexItemData growFactor="1"/>
</layoutData>
</Switch>
</VBox>
<VBox class="sapUiMediumMarginBegin">
<Label design="Bold" text="{i18n>axisTitleLabel}"></Label>
<Switch change='onAxisTitleChanged' state="false">
<layoutData>
<FlexItemData growFactor="1"/>
</layoutData>
</Switch>
</VBox>
<VBox class="sapUiMediumMarginBegin">
<Label design="Bold" text="{i18n>stackedType}"></Label>
<RadioButtonGroup select="onTypeSelected">
<buttons>
<RadioButton text="{i18n>regular}"/>
<RadioButton text="{i18n>percentage}"/>
</buttons>
</RadioButtonGroup>
</VBox>
</HBox>
</content>
</Panel>
"sap/viz/ui5/data/FlattenedDataset",
"sap/viz/ui5/controls/common/feeds/FeedItem",
"sap/viz/ui5/controls/Popover",
"sap/viz/ui5/controls/VizFrame",
"sap/viz/ui5/format/ChartFormatter",
"sap/viz/ui5/api/env/Format"
onDataLabelChanged : function(oEvent){
var that=this;
var oVizFrame = that.getView().byId("idVizFrame");
oVizFrame.setVizProperties({
plotArea: {
dataLabel: {
visible: oEvent.getParameter("state")
}
}
});
},
onSumLabelChanged : function(oEvent){
var that=this;
var oVizFrame = that.getView().byId("idVizFrame");
var sumLabelSwitch = oEvent.getParameter("state");
oVizFrame.setVizProperties({
plotArea: {
dataLabel: {
showTotal: sumLabelSwitch
}
}
});
},
onAxisTitleChanged : function(oEvent){
var that=this;
var oVizFrame = that.getView().byId("idVizFrame");
var state = oEvent.getParameter("state");
oVizFrame.setVizProperties({
valueAxis: {
title: {
visible: state
}
},
categoryAxis: {
title: {
visible: state
}
}
});
},
onTypeSelected : function(oEvent){
var that=this;
var typeRadio = oEvent.getSource().getSelectedButton().getProperty("text");
var oVizFrame = that.getView().byId("idVizFrame");
if (typeRadio === "Regular") {
oVizFrame.setVizType("stacked_bar");
} else {
oVizFrame.setVizType("100_stacked_bar");
oVizFrame.setVizProperties({
plotArea: {
mode: "percentage",
drawingEffect: "glossy",
dataLabel: {
type: "percentage",
visible: true
}
}
});
}
}
var oVizFrame = this.getView().byId("idVizFrame");
var vizPopover = new sap.viz.ui5.controls.Popover({});
vizPopover.connect(oVizFrame.getVizUid());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
53 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |