【问题标题】:Google Charts change axis line and text color谷歌图表改变轴线和文字颜色
【发布时间】:2016-10-19 12:38:15
【问题描述】:

我的谷歌条形图选项变量是:

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

但仍在显示轴线和文字。

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

问候

【问题讨论】:

    标签: charts google-visualization


    【解决方案1】:

    而不是 --> textPosition: 'none'

    试试……

      textStyle: {
        color: "#FFFFFF"
      },
    

    请参阅以下工作 sn-p...

    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>

    同样,从问题中不确定,但如果使用上面示例中的 material 图表

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

    【讨论】:

    • 谢谢你只需要 google.charts.Bar.convertOptions(Baroptions)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-06
    • 2016-07-23
    • 1970-01-01
    • 1970-01-01
    • 2014-12-31
    相关资源
    最近更新 更多