2017-04-21 42 views
0

我使用下面的谷歌圖的擴展性和代碼來查看圖表在谷歌餅圖擴展如下:無法在QlikView的

Qva.LoadScript("http://www.google.com/jsapi?callback=loadGoogleCoreChart", function() { 
     }); 

    function loadGoogleCoreChart() { 
google.load('visualization', '1', { 
    packages: ['corechart'], 
    callback: googleCoreChartLoaded 
}); 
} 

function googleCoreChartLoaded() { 
Qva.AddExtension('GooglePieChart', function() { 

    //Declaring a two dimensional array (an array of arrays) 
    var row = new Array(this.Data.Rows.length + 1); 
    for (var i = 0; i <= this.Data.Rows.length; i++) { 
     row[i] = new Array(2); 
    } 

    //Getting the data from QlikView 
    for (var j = 1; j <= this.Data.Rows.length; j++) { 
     row[j][0] = this.Data.Rows[j - 1][0].text; 

     var temp = this.Data.Rows[j - 1][1].text; 
     row[j][1] = Number(temp); 
    } 

    //Changing the array to a data table 
    var data = google.visualization.arrayToDataTable(row); 

    //Instantiating and drawing the chart 
    new google.visualization.PieChart(this.Element).draw(data, { chartArea: 
    { left: 20, top: 20, width: "100%", height: "100%"} }); 
}); 
    } 

我已經使用腳本編輯器,選擇加載的樣本數據後在擴展中的維度我無法看到圖表。任何人都可以幫助我什麼是錯的?

回答

0

這是工作的功能:

Qva.LoadScript("http://www.google.com/jsapi?callback=loadGoogleCoreChart", function() { 
}); 

    function loadGoogleCoreChart() { 
google.load('visualization', '1', { 
    packages: ['corechart'], 
    callback: googleCoreChartLoaded 
}); 
} 

function googleCoreChartLoaded() { 

Qva.AddExtension('QlikView/Examples/GooglePieChart', function() { 

    var html = "<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>"; 
    html += "<div id=\"piechart\" style=\"width: 900px; height: 500px;\"></div>"; 

    this.Element.innerHTML = html; 
    this.Element.innerHTML = "<h1>Testing Extension</h1>"; 

    var data = google.visualization.arrayToDataTable([ 
     ['Task', 'Hours per Day'], 
     ['Work',  11], 
     ['Eat',  2], 
     ['Commute', 2], 
     ['Watch TV', 2], 
     ['Sleep', 7] 
    ]); 

    var options = { 
     title: 'My Daily Activities' 
    }; 
    new google.visualization.PieChart(this.Element).draw(data, { chartArea: { left: 20, top: 20, width: "100%", height: "100%"} }); 
}); 
} 

雖然,在這裏我有存在於功能本身的數據。我仍然需要弄清楚如何接受Qlikview的投入,我敦促任何知道這個技巧的人幫助我。