14 Replies Latest reply: Dec 18, 2014 10:03 AM by Paul Walker RSS

    Could not complete the development of Raphael Pie Chart Extension Object

      Dear All,

       

      I'm learning Qlikview Extension Object and i'm trying to build raphael Pie Chart extension. I'm struck and could not complete it.

      Could you please have a look at my script and let me know what i'm missing?

       

      I have less knowledege in Scripting and hence i could have missed few things. Please help me.

       

      var template_path = Qva.Remote + "?public=only&name=Extensions/RaphelPieChart/";

      function extension_Init()

      {

                // Use QlikView's method of loading other files needed by an extension. These files should be added to your extension .zip file (.qar)

                if (typeof jQuery == 'undefined') {

                    Qva.LoadScript(template_path + 'raphael.js', function() {

                  Qva.LoadScript(template_path + 'pie.js', extension_Done);

                    });

                }

                else {

                    Qva.LoadScript(template_path + 'raphael.js', function() {

                      Qva.LoadScript(template_path + 'jquery.js', function() {

                        Qva.LoadScript(template_path + 'pie.js', extension_Done);

                                    });

                    });

                }       

      }

       

       

      function extension_Done(){

                //Add extension

                Qva.AddExtension('RaphelPieChart',

                function(){

                          //Load a CSS style sheet

                          Qva.LoadCSS(template_path + "demo.css");

                          Qva.LoadCSS(template_path + "demo-print.css");

       

                var _this = this;

       

                var iFrameWidth = _this.GetWidth();

                var iFrameHeight = _this.GetHeight();

       

       

                var divName = _this.Layout.ObjectId.replace("\\", "_");

       

       

                if (_this.Element.children.length == 0) {

                          var ui = document.createElement("div");

                          ui.setAttribute("id", divName);

                          _this.Element.appendChild(ui);

                          $("#" + divName).css("height", iFrameHeight + "px").css("width", iFrameWidth + "px");

                } else {

                          $("#" + divName).css("height", iFrameHeight + "px").css("width", iFrameWidth + "px");

                          $("#" + divName).empty();

                };

       

        for (var i=0,k=_this.Data.Rows.length;i<k;i++){

                          var row = _this.Data.Rows[i];

                                    var th = row[0].text;

                                    var td = row[1].text;

                                    var temptd = Number(td);

                                    var renderer = new Raphael.fn.pieChart(iFrameWidth, iFrameHeight, 200, td, th, "#fff");

                          }

                renderer.draw();

                });

      }

       

       

      //Initiate extension

      extension_Init();

       

      Thanks in advance,

      Srini.