Google Charts更改轴线和文本颜色

时间:2016-10-19 12:38:16

标签: charts google-visualization

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

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

但轴线和文字仍在显示中。 Rendered Graph

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

此致

1 个答案:

答案 0 :(得分: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>
&#13;
&#13;
&#13;

另外,不确定问题,但如果使用材料图表,如上例所示

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