我使用以下Google Chart扩展程序,代码如下:
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 :(得分: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获取输入,我敦促任何知道这个技巧的人帮助我。