sap.ui.jsview("chart1.chart1", {
getControllerName : function() {
return "chart1.chart1";
},
createContent : function(oController) {
var Vbox = new sap.m.VBox({
id:"vbox11",
items:[
new sap.m.Label({
id:"lb10",
text:" 1999 profit 117"
}),
new sap.m.Label({
id:"lb11",
text:" 1996 revenue profit "
}),
]
});
var oModel = new sap.ui.model.json.JSONModel({
businessData : [
{Year :"1995",revenue:410.87,profit:-141.25, population:34789000},
{Year :"1996",revenue:338.29,profit:133.82, population:1339724852},
{Year :"1997",revenue:487.66,profit:348.76, population:65350000},
{Year :"1998",revenue:470.23,profit:217.29, population:81799600},
{Year :"1999",revenue:170.93,profit:117.00, population:1210193422},
{Year :"2000",revenue:905.08,profit:609.16, population:313490000}
]
});
// A Dataset defines how the model data is mapped to the chart
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
// a Bar Chart requires exactly one dimension (x-axis)
dimensions : [
{
axis : 1, // must be one for the x-axis, 2 for y-axis
name : 'Year',
value : "{Year}"
}
],
// it can show multiple measures, each results in a new set of bars in a new color
measures : [
// measure 1
{
name : 'Profit', // 'name' is used as label in the Legend
value : '{profit}' // 'value' defines the binding for the displayed value
},
{
name : 'Revenue',
value : '{revenue}'
}
],
// 'data' is used to bind the whole data collection that is to be displayed in the chart
data : {
path : "/businessData"
}
});
// create a Bar chart
// you also might use Combination, Line, StackedColumn100, StackedColumn or Column
// for Donut and Pie please remove one of the two measures in the above Dataset.
var oChart = new sap.viz.ui5.Line({
width : "80%",
height : "400px",
plotArea : {
//'colorPalette' : d3.scale.category20().range()
},
title : {
visible : true,
text : 'Profit and Revenue By Country'
},
dataset : oDataset
});
// attach the model to the chart and display it
oChart.setModel(oModel);
var Vbox1a = new sap.m.VBox({
id:"vbox12",
items:[
Vbox,oChart
]
});
return new sap.m.Page({
title: "Title",
content: [
Vbox1a
]
});
}
});
INDEX.HTML
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m,sap.viz,sap.ui.layout,sap.ui.table,sap.ui.commons"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
<script>
sap.ui.localResources("chart1");
var app = new sap.m.App({initialPage:"idchart11"});
var page = sap.ui.view({id:"idchart11", viewName:"chart1.chart1", type:sap.ui.core.mvc.ViewType.JS});
app.addPage(page);
app.placeAt("content");
</script>
<style>
#lb10{
margin-left: 490px;
font-size:100%;
font-weight:bolder;
color:#333;
}
#lb11{
margin-left: 490px;
font-size:100%;
font-weight:bolder;
color:#333;
}
</style>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
OUTPUT
No comments:
Post a Comment