谷歌堆积条形图api与两个hAxis

时间:2014-04-10 04:19:22

标签: javascript google-visualization bar-chart

我正在使用google api绘制堆积条形图,我想要两个hAxis for graph(数字格式中的前一个和%格式下的一个)。我正在使用此代码来渲染图形。

任何人都可以建议如何将顶级hAxis添加为数字吗?

   function drawVisualization() {
      // Create and populate the data table.
      var data = google.visualization.arrayToDataTable([
        ['Year', 'Austria', 'Bulgaria', 'Denmark', 'Greece'],
        ['2003',1360,1001,1082,1974],
        ['2004',1556,1649,1150,1495]
      ]);

      // Create and draw the visualization.
      new google.visualization.BarChart(document.getElementById('visualization')).
          draw(data,
               {title:"Yearly Coffee Consumption by Country",
                width:600, height:400,
                vAxis: {title: "Year"},
                isStacked:true,
                hAxes:{0:{title:'Losses in percentage',format:'#,#%'},
                       1:{title:'Losses in number'}
                      },
                series:{0:{targetAxisIndex:0},1:{targetAxisIndex:1}} 
               }
          );
    }
    ​

0 个答案:

没有答案