标签:
<!DOCTYPE html>
<html>
<head>
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m,sap.viz"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <script>
    var oModel = new sap.ui.model.json.JSONModel({
  riskData : [
  {category: "Category 01", severity: 9, cVulnerable: 15, cPotVulnerable: 32, cSafe: 5, cTotal: 52},           
  {category: "Category 02", severity: 8, cVulnerable: 12, cPotVulnerable: 15, cSafe: 2, cTotal: 29},
  {category: "Category 03", severity: 5, cVulnerable: 32, cPotVulnerable: 32, cSafe: 1, cTotal: 65},
  {category: "Category 04", severity: 6, cVulnerable: 26, cPotVulnerable: 31, cSafe: 5, cTotal: 62},
  {category: "Category 05", severity: 3, cVulnerable: 13, cPotVulnerable: 15, cSafe: 6, cTotal: 34},
  {category: "Category 06", severity: 2, cVulnerable: 9, cPotVulnerable: 15, cSafe: 1, cTotal: 25},
  {category: "Category 07", severity: 7, cVulnerable: 5, cPotVulnerable: 18, cSafe: 0, cTotal:23}
  ]
  });
 
  //set up dataset
  var PieChartData = new sap.viz.ui5.data.FlattenedDataset("dataForPie",{
  dimensions : [{
  axis : 1,
  name : ‘Severity‘,
  value : "{severity}"
  }],
  measures: [{
             group: 1,
             name : ‘cTotal‘,
             value : ‘{cTotal}‘
      },/*
    {
             group: 2,
             name : ‘cSafe‘,
             value : ‘{cSafe}‘
      
          
  },*/
            {
              group:2,
              name: ‘severity‘,
              value: ‘{severity}‘
            }],
  data :{
  path : "/riskData"
  }
  });
 
  //set up chart
  var PieChart = new sap.viz.ui5.Pie({
  id : "pie",
  width : "80%",
  height : "400px"
  });
 
  PieChartData.setModel(oModel);
  PieChart.setDataset(PieChartData);
    PieChart.placeAt(‘content‘);
  </script>
</head>
<body>
<div id=‘content‘/>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/abapscript/p/ui5piechart.html