SAPUI5 Development

Pie Chart using VizFrame in SAPUI5

Pre-requisites

1.sapui5 framework
2.basic javascript knowledge
3.sap.m and sap.viz library loaded 

              VizFrame is a viz control that manages a visualization’s initialization, layout, feeding, customization and interactions.VizFrame is available in sap.viz.ui5.controls library.We can see how we can create Pie chart using VizFrame.
              If you dont know how to create Bar chart using VizFrame see Bar Chart using VizFrame. 

Steps
  1. Create Application using SAP Web IDE or eclipse with a view and controller.If you dont know how to refer my previous tutorial.Application Using SAP Web IDE
  2. First inside onInit() method of the controller we will create a json model and set data to the model and set the model to the view.

  3. Create VizFrame control inside Page control in the view and give properties.



  4. Add dataset to the VizFrame.Set dimensions and measures.


  5. Add feeds to the VizFrame.


  6. All set now place the view at content div(Needed when using jsbin).Its automatically done when using IDE
  7. Output chart will look like this.
  8. See sample code in jsbin     

  9. Pie chart in XML View
    Pie chart in JS View
If you enjoyed this post, I’d be grateful if you’d help it spread by sharing.Thank you! See you soon

6 comments :

  1. Hi,

    How can I edit the "Title of the chart"?

    ReplyDelete
    Replies
    1. You can make use of 'vizProperties' property of control vizframe to achieve this.See the below sample.
      Title of Chart

      Delete
  2. How Can i add more feed item on select? like adding City and Profit?

    ReplyDelete
    Replies
    1. Hi,
      You can remove the feeds and dataset and set it again.
      see sample change feeds

      Delete

Powered by Blogger.