Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌图表:增加x轴标签和x轴之间的间距_Javascript_Angular_Google Visualization - Fatal编程技术网

Javascript 谷歌图表:增加x轴标签和x轴之间的间距

Javascript 谷歌图表:增加x轴标签和x轴之间的间距,javascript,angular,google-visualization,Javascript,Angular,Google Visualization,我正在使用GoogleChart()一个GoogleChart的角度包装器来显示柱状图。我想增加x轴标签和x轴之间的边距。 在下图中,红色部分表示我想增加间隙的位置 在文档之后,我添加了以下代码: options: { ... hAxis: { textStyle: { fontSize: 10, fontStyle: "Arial", marginTop: '10', c

我正在使用GoogleChart()一个GoogleChart的角度包装器来显示柱状图。我想增加x轴标签和x轴之间的边距。 在下图中,红色部分表示我想增加间隙的位置

在文档之后,我添加了以下代码:

options: {
      ...

      hAxis: {
        textStyle: {
          fontSize: 10,
          fontStyle: "Arial",
          marginTop: '10',
          color: '#808080'
        },
   ...

颜色、字体大小和字体样式正常工作,但无法获得页边空白。有什么想法吗?提前谢谢

使用
chartArea.bottom
增加x轴上的空间

options: {
      ...
      chartArea: {
        bottom: 60
      },

      hAxis: {
        textStyle: {
          fontSize: 10,
          fontStyle: "Arial",
          marginTop: '10',
          color: '#808080'
        },
   ...  

编辑

虽然您可以使用
bottom
增加x轴的高度,
标签仍与x轴的顶部对齐

但是我们可以在图表的
'ready'
事件上手动向下移动它们,
通过增加
'y'
属性,
请参阅以下工作片段

google.charts.load('current'{
包:['controls','corechart']
}).然后(函数(){
var dataTable=new google.visualization.dataTable();
addColumn('timeofday','Time of Day');
dataTable.addColumn('number','Motivation Level');
dataTable.addRows([
[[8, 0, 0], 46],
[[9, 0, 0], 46],
[[10, 0, 0], 34],
[[11, 0, 0], 4],
[[12, 0, 0], 5],
[[13, 0, 0], 6],
[[14, 0, 0], 7],
[[15, 0, 0], 8],
[[16, 0, 0], 9],
[[17, 0, 0], 10],
]);
变量选项={
图表区:{
高度:“100%”,
宽度:“100%”,
排名:24,
左:60,,
右:16,
底数:100
},
高度:“100%”,
宽度:“100%”,
哈克斯:{
文本样式:{
尺寸:10,
字体:“Arial”,
玛金托普:“10”,
颜色:'#808080'
}
}
};
var container=document.getElementById('chart_div');
var chart=新的google.visualization.ColumnChart(容器);
google.visualization.events.addListener(图表'ready',函数(){
var labels=container.getElementsByTagName('text');
Array.prototype.forEach.call(标签,函数(标签){
if(label.getAttribute('text-anchor')=='middle'){
label.setAttribute('y',parseFloat(label.getAttribute('y'))+20);
}
});
});
图表绘制(数据表、选项);
});


感谢您的回复…设置“底部:60”不起作用…在我的尝试中,如果我将底部属性设置为小于25,则X轴标签将消失…因此我猜底部属性设置X轴标签的高度是的,这是唯一可以增加空间的选项,
60
只是一个例子……我的意思是将底部属性设置为小于25会使x标签消失……设置为大于25(任何值)只会在常规位置显示x标签……所以我认为它代表x标签的高度……奇怪的是,没有chartArea。底部属性不包括在正式文档中