2016-10-19 54 views
2

我的谷歌条形图选项变量是:谷歌图表改变轴线线和文本颜色

var Baroptions = { 
legend: {position: 'none'}, 
hAxis: { 
    textPosition: 'none', 
    gridlines: { 
     color: "#FFFFFF" 
    }, 
    baselineColor: '#FFFFFF' 
}, 
bars: 'horizontal', 
animation:{ 
duration: 500, 
easing: 'out', 
} 
}; 

但是轴心线和文字仍然被显示出来。 Rendered Graph

我需要删除0和50k文本。

问候

回答

2

代替 - >textPosition: 'none'

试...

textStyle: { 
    color: "#FFFFFF" 
    }, 

看到下面的工作片段...

google.charts.load('current', { 
 
    callback: drawChart, 
 
    packages: ['bar'] 
 
}); 
 

 
function drawChart() { 
 
    var chart = new google.charts.Bar(document.getElementById('chart_div')); 
 

 
    var dataTable = new google.visualization.DataTable(); 
 
    dataTable.addColumn('string', ''); 
 
    dataTable.addColumn('number', 'Value'); 
 
    dataTable.addRows([ 
 
    ['18-25', 25], 
 
    ['26-35', 46], 
 
    ['36-45', 30], 
 
    ['46-55', 10], 
 
    ['55 Above', 7] 
 
    ]); 
 

 
    var Baroptions = { 
 
    legend: {position: 'none'}, 
 
    hAxis: { 
 
     textStyle: { 
 
     color: "#FFFFFF" 
 
     }, 
 
     gridlines: { 
 
     color: "#FFFFFF" 
 
     }, 
 
     baselineColor: '#FFFFFF' 
 
    }, 
 
    bars: 'horizontal' 
 
    }; 
 

 
    chart.draw(dataTable, google.charts.Bar.convertOptions(Baroptions)); 
 
}
<script src="https://www.gstatic.com/charts/loader.js"></script> 
 
<div id="chart_div"></div>

也不会从问题,如果使用材料图表如在上面的例子中

animation.*several options that don't work on material charts

+0

三江源 只是需要google.charts.Bar.convertOptions之间(Baroptions)确定,但 – user2610333