我试图让Google Sankey图表为每个节点打开PDF;我打开了一个窗口,但它不会渲染PDF。它将拉出正常的网页,而不是渲染PDF。
在实践中,我会计算网址,但我现在只是使用测试页面。
我只是在小提琴中实现了这一点 - 是否存在与JSFiddle相关的某种阻塞可能是问题?
google.charts.load('current', {
callback: function () {
drawChart();
window.addEventListener('resize', drawChart, false);
},
packages:['sankey']
});
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'From');
data.addColumn('string', 'To');
data.addColumn('number', 'Weight');
data.addRows([
[ 'Geometry', 'Algebra 2', 7 ],
[ 'Geometry','FST',3],
[ 'FST','Precalculus',4],
[ 'FST','Concepts of Adv Math',6],
[ 'Honors Algebra 2', 'Honors Precalculus', 7 ],
[ 'Honors Algebra 2', 'Precalculus', 3 ],
[ 'Algebra', 'Geometry', 7 ],
[ 'Precalculus','Calculus',8],
[ 'Precalculus','AP Calculus AB',2],
[ 'Precalculus','Concepts of Adv Math',2],
[ 'Honors Precalculus','AP Calculus AB',8],
[ 'Honors Precalculus','Calculus',2],
[ 'AP Calculus AB','AP Calculus BC',8],
[ 'AP Calculus BC','AP Statistics',3],
[ 'Calculus', 'AP Statistics', 2]
]);
// Sets chart options.
var options = {
width: 600,
tooltip: { isHtml: true },
sankey: {
node: {
interactivity: true,
nodePadding: 60
},
}
};
var chart = new google.visualization.Sankey(document.getElementById('sankey_basic'));
google.visualization.events.addListener(chart, 'select', function() {
var sel = chart.getSelection();
if (sel.length) {
var sel = sel[0].name.replace(/ /g,'');
//var url = 'http://www.xb.org/images/currtest/'+sel+'.pdf';
var url = 'http://www.pdf995.com/samples/pdf.pdf';
window.open(url);
}
});
chart.draw(data, options);
}