javascript - 删除 Google 日历图表上的色轴图例

标签 javascript charts google-visualization

想要删除 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/

相关文章:

Javascript - chatjs donut 在悬停时运行脚本

php - 使用 php 和 mysql 两个日期之间的动态 Google 图表

javascript - Google 图表 - 柱形图 Y 轴不可见

javascript - 带有 Rhomobile 的 Google map Javascript V3 API

javascript - 拦截对 HTML5 canvas 元素的调用

javascript - 使用 reduce to group date 来制作 date_from 和 date_to

javascript - 如何通过导航选项卡使 Google 图表做出响应

java - 如何在 JFreeChart 中设置多个系列的线条粗细?

javascript - 带 Angular/水平标签的 d3.js 饼图

javascript - 如何使用 jinja 将 null 从 python 传递给 javascript