gpt4 book ai didi

google-visualization - 谷歌可视化禁用用户选择

转载 作者:行者123 更新时间:2023-12-03 23:22:46 24 4
gpt4 key购买 nike

无论如何要禁用谷歌可视化图表(特别是组织结构图)中的用户选择

在 javascript 中,我以编程方式在节点之一上设置了选择。无论如何,从那时起禁用用户选择,以便即使用户单击图表上的其他部分时选择也不会改变?

最佳答案

你不能禁用,但你可以覆盖

聆听 'select'事件和 setSelection到所需的 row
看下面的例子...

google.charts.load('current', {
callback: function () {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('string', 'Manager');
data.addColumn('string', 'ToolTip');

// For each orgchart box, provide the name, manager, and tooltip to show.
data.addRows([
[{v:'Mike', f:'Mike<div style="color:red; font-style:italic">President</div>'},
'', 'The President'],
[{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice President</div>'},
'Mike', 'VP'],
['Alice', 'Mike', ''],
['Bob', 'Jim', 'Bob Sponge'],
['Carol', 'Bob', '']
]);

var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));

// set selection on 'ready' and 'select'
google.visualization.events.addListener(chart, 'ready', setSelection);
google.visualization.events.addListener(chart, 'select', setSelection);

function setSelection() {
chart.setSelection([{row: 1}]);
}

chart.draw(data, {allowHtml: true});
},
packages:['orgchart']
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

关于google-visualization - 谷歌可视化禁用用户选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37687745/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com