有没有办法在线条或条形图表上始终显示阴影? 我尝试用css,svg,rect和g搜索解决方案,但没有运气。
基本上,线条阴影应该与在图例上悬停时显示的相同。
谢谢, 伊万
答案 0 :(得分:0)
没有配置选项或设置,特别是阴影
但使用style column role,可以添加半透明边框
请参阅以下工作片段,
数据视图用于将样式应用于每个其他行
(所以你可以看到与正常风格的区别)
google.charts.load('current', {
packages: ['controls', 'corechart', 'table']
}).then(function () {
var data = new google.visualization.DataTable();
data.addColumn('number', 'X');
data.addColumn('number', 'y0');
data.addRows([
[0, 0], [1, 10], [2, 23], [3, 17], [4, 18], [5, 9],
[6, 11], [7, 27], [8, 33], [9, 40], [10, 32], [11, 35],
[12, 30], [13, 40], [14, 42], [15, 47], [16, 44], [17, 48],
[18, 52], [19, 54], [20, 42], [21, 55], [22, 56], [23, 57],
[24, 60], [25, 50], [26, 52], [27, 51], [28, 49], [29, 53],
[30, 55], [31, 60], [32, 61], [33, 59], [34, 62], [35, 65],
[36, 62], [37, 58], [38, 55], [39, 61], [40, 64], [41, 65],
[42, 63], [43, 66], [44, 67], [45, 69], [46, 69], [47, 70],
[48, 72], [49, 68], [50, 66], [51, 65], [52, 67], [53, 70],
[54, 71], [55, 72], [56, 73], [57, 75], [58, 70], [59, 68],
[60, 64], [61, 60], [62, 65], [63, 67], [64, 68], [65, 69]
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, {
calc: function (dt, row) {
var columnStyle = '';
if (row % 2 === 0) {
columnStyle = 'fill-color: #f44336; stroke-color: #d50000; stroke-opacity: 0.35; stroke-width: 5;';
}
return columnStyle;
},
role: 'style',
type: 'string'
}]);
var container = document.getElementById('chart-column');
var chartColumn = new google.visualization.ColumnChart(container);
var options = {
chartArea: {
bottom: 24,
left: 36,
right: 16,
top: 24,
width: '100%',
height: '100%'
},
colors: ['#f44336'],
height: '100%',
legend: {
position: 'none'
},
width: '100%'
};
window.addEventListener('resize', function () {
chartColumn.draw(view, options);
});
chartColumn.draw(view, options);
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart-column"></div>