我正在使用google graph
设计图形。我不需要在x和y轴上放置标签,因此我通过设置以下选项将其隐藏:
var options = {
hAxis: {
baselineColor: 'none',
ticks: [],
position: 'none',
fontsize: 0 // do not do anything
},
vAxis: {
baselineColor: 'none',
ticks: [],
position: 'none',
fontsize: 0 // do not do anything
}
};
我的图表当前如下所示:
我想将其拉伸到元素的整个宽度和高度。这可能吗?
答案 0 :(得分:1)
您可以使用chartArea
选项...
var options = {
chartArea: {
height: '100%',
width: '100%',
},
height: '100%',
width: '100%',
...
请参阅以下工作片段...
google.charts.load('current', {
packages:['corechart']
}).then(function () {
var data = google.visualization.arrayToDataTable([
['X', 'Y'],
[0, 5],
[1, 6],
[2, 7],
[3, 5]
]);
var options = {
chartArea: {
height: '100%',
width: '100%',
},
height: '100%',
width: '100%',
hAxis: {
baselineColor: 'none',
ticks: [],
position: 'none',
fontsize: 0 // do not do anything
},
vAxis: {
baselineColor: 'none',
ticks: [],
position: 'none',
fontsize: 0 // do not do anything
}
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>