Javascript 在Google图表中放置Html标记
我正在使用谷歌图表,我想把锚标签的木兰房,而不是例如木兰房单独有任何方法可以做到这一点? 谷歌图表链接Javascript 在Google图表中放置Html标记,javascript,charts,google-visualization,Javascript,Charts,Google Visualization,我正在使用谷歌图表,我想把锚标签的木兰房,而不是例如木兰房单独有任何方法可以做到这一点? 谷歌图表链接 Javascript代码: <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization', 'version':'1','packages':['timeline']}]}"></script>
Javascript代码:
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization',
'version':'1','packages':['timeline']}]}"></script>
<script type="text/javascript">
google.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('example5.3');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Room' });
dataTable.addColumn({ type: 'string', id: 'Name' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
[ '<a>Magnolia Room</a>' , 'CSS Fundamentals', new Date(0,0,0,test,0,0), new Date(0,0,0,14,0,0) ],
[ 'Magnolia Room', 'Intro JavaScript', new Date(0,0,0,14,30,0), new Date(0,0,0,16,0,0) ],
[ 'Magnolia Room', 'Advanced JavaScript', new Date(0,0,0,16,30,0), new Date(0,0,0,19,0,0) ],
[ 'Gladiolus Room', 'Intermediate Perl', new Date(0,0,0,12,30,0), new Date(0,0,0,14,0,0) ],
[ 'Gladiolus Room', 'Advanced Perl', new Date(0,0,0,14,30,0), new Date(0,0,0,16,0,0) ],
[ 'Gladiolus Room', 'Applied Perl', new Date(0,0,0,16,30,0), new Date(0,0,0,18,0,0) ],
[ 'Petunia Room', 'Google Charts', new Date(0,0,0,12,30,0), new Date(0,0,0,14,0,0) ],
[ 'Petunia Room', 'Closure', new Date(0,0,0,14,30,0), new Date(0,0,0,16,0,0) ],
[ 'Petunia Room', 'App Engine', new Date(0,0,0,21,30,0), new Date(0,0,1,0,30,0) ]]);
var options = {
timeline: { colorByRowLabel: true },
backgroundColor: '#ffd'
};
chart.draw(dataTable, options);
}
</script>
您不能在工具栏标签中使用HTML,但当有人单击工具栏时,您可以使用“选择”事件来执行任何您想执行的操作。但我如何设置事件,因为它只是名称?我如何收集它?请查看您上一个问题的答案:我想我上一个问题的答案,事件是关于项目非行标签的,所以我不能使用该事件,因为当我在项目非行标签中单击时,它是有效的,所以我应该使用另一个事件,我认为它不再是“选择”,而是“单击”?请帮我一下,我只需要一个行标签事件,至少可以很好地指导我!!!!
google.visualization.events.addListener(chart, 'click', function (e) {
var match = e.targetID.match(/vAxis#\d+#label#(\d+)/);
if (match) {
var rowIndex = parseInt(match[1]);
var axisLabel = data.getValue(rowIndex, 0);
alert(axisLabel);
}
});