I have a table(taken from google charts) and a line chart(also taken from there) and I want to embed it inside the table. I know there is a way to embed an html page inside a table by raising the flag "allow html" but didn't manage to find the exact syntax to do so.
I want it to look like this(used sparkline here):
This is my html for table:
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['table']});
google.charts.setOnLoadCallback(drawTable);
function drawTable() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('number', 'Salary');
data.addColumn('boolean', 'Full Time Employee');
data.addRows([
['Mike', {v: 10000, f: '$10,000'}, true, **HTML LINE CHART1 HERE**],
['Jim', {v:8000, f: '$8,000'}, false, **HTML LINE CHART2 HERE**],
['Alice', {v: 12500, f: '$12,500'}, true,**HTML LINE CHART3 HERE**],
['Bob', {v: 7000, f: '$7,000'}, true,**HTML LINE CHART4 HERE**]
]);
var table = new google.visualization.Table(document.getElementById('table_div'));
table.draw(data, {showRowNumber: true, width: '100%', height: '100%'});
}
</script>
</head>
<body>
<div id="table_div"></div>
</body>
</html>
折线图的 html:
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance',
curveType: 'function',
legend: { position: 'bottom' }
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="curve_chart" style="width: 900px; height: 500px"></div>
</body>
</html>
例如,我希望显示第二个 html,而不是布尔列。
谢谢!!!