想要删除 Google 日历图表上的 coloraxis 图例。颜色轴位于图表的右上角。我的图表试图说明堪萨斯两栖动物和爬行动物的事件日期以及 Frog 和蟾蜍的事件类型(呼唤与不呼唤)。所显示的色轴无法提供信息......但是另一种解决方案是将色轴标签更改为文本标签(例如调用,其他事件)。
例子在 http://webapps.fhsu.edu/ksfaunatest/account.aspx?o=30&t=3
<script type="text/javascript">
google.charts.load("current", { packages: ["calendar"] });
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'date', id: 'Date' });
dataTable.addColumn({ type: 'number', id: 'Activity' });
dataTable.addRows([
[new Date(2012, 4, 3), 1],
[new Date(2012, 4, 16), -1],
[new Date(2012, 5, 6), -1],
// many rows removed
[new Date(2012, 7, 15), 1],
[new Date(2012, 7, 25), -2],
]);
var chart = new google.visualization.Calendar(document.getElementById('calendar_basic'));
var options = {
legend: 'none',
title: '',
calendar: {
daysOfWeek: '',
yearLabel: {
fontName: 'Times-Roman',
fontSize: 1,
color: '#000000',
bold: false,
italic: false
},
}
};
chart.draw(dataTable, options);
}
drawChart();
</script>
最佳答案
我想删除整个图例,并根据 WhiteHat 的答案对其进行了调整。基本上我试图找到只影响图例的相关属性并隐藏它们:
google.visualization.events.addListener(chart, 'ready', function () {
$($('#calendar_basic text')[0]).hide();
$($('#calendar_basic text')[1]).hide();
$($('#calendar_basic text')[2]).hide();
$('#calendar_basic linearGradient').hide();
$('#calendar_basic')
.find('[fill-opacity="1"]').hide();
});
关于javascript - 删除 Google 日历图表上的色轴图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44654966/