为什么谷歌图表api选项给我错误命名为“未捕获的语法错误”

时间:2012-03-23 18:40:14

标签: javascript charts

  <script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});

function drawVisualization() {
   // Populate the data table.
    var dataTable = google.visualization.arrayToDataTable([
       ['Mon',20,28,38,45],
       ['Tues',31,38,55,66],
       ['Wed',50,55,77,80],
       ['Thurs',77,77,66,50],
       ['Fri',68,66,22,15],
    ], true);

    // Draw the chart.
    var chart = new google.visualization.CandlestickChart(document.getElementById('visualization'));
    chart.draw(dataTable, 
               {
                 legend:'none', 
                 width:600, 
                 height:400,
                 hAxis.textStyle: {color: 'red', fontName: 'arial', fontSize: 10}
               }
              );
}


google.setOnLoadCallback(drawVisualization);

当我在Google chart api playground中编写此代码并调试代码时,它会给我一些未捕获的语法错误。我在这个api中是全新的,我正在探索。所以有人可以告诉我为什么会出现这个错误?在代码中添加 hAxis.textStyle 选项时会发生错误。

1 个答案:

答案 0 :(得分:3)

似乎Google文档在那里有点时髦;我认为这应该是一个对象:

hAxis: { textStyle: {color: 'red', fontName: 'arial', fontSize: 10} }