Google Charts添加不需要的文字

时间:2018-01-08 19:18:43

标签: javascript charts google-visualization google-chartwrapper

我与Google Spreadsheets进行了整合,效果非常好,但是在BARS和LINES图表的Y-AXIS上," General"打印范围号!

我的代码:

// Load the Visualization API and the corechart package.
  google.charts.load('current', {'packages':['corechart']});

  // Set a callback to run when the Google Visualization API is loaded.
  google.charts.setOnLoadCallback(drawChart);

  // Callback that creates and populates a data table,
  // instantiates the pie chart, passes in the data and
  // draws it.
  function drawChart() {
    var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1LTV_2_dyMFr2KGeNHGnyHmITa-TsUD76k2WQ8Cb59Bs/edit?usp=sharing');
    query.send(handleQueryResponse);
  }

  function handleQueryResponse(response) {
    var data = response.getDataTable();
    var chart = new google.visualization.ChartWrapper({
     containerId: 'chart_div'
    });
    var barsButton = document.getElementById('b1');
    var lineButton = document.getElementById('b2');
    var options = {
      width: 800,
      height: 640,
      animation: {
        duration: 500,
        easing: 'ease-in-out',
        startup: true
      },        
    };

    console.log(data);

    chart.setOptions(options);

    function drawBars() {
       chart.setChartType('ColumnChart');
       chart.setDataTable(data);
       chart.draw();
    }

    function drawLine() {
       chart.setChartType('LineChart');
       chart.setDataTable(data);
       chart.draw();
    }

    barsButton.onclick = function () {
       drawBars();
    }

    lineButton.onclick = function () {
       drawLine();
    }

   drawBars();

  }

"将军"恼人的字印!

enter image description here

之前有人经历过吗?

1 个答案:

答案 0 :(得分:0)

尝试为y轴设置特定格式......

  var options = {
    vAxis: {
      format: '#,##0'
    }
  };