javascript - 为什么谷歌图表 api 选项给我错误名为 "uncaught syntax error"

标签 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 选项时发生错误。

最佳答案

Google 文档似乎有点古怪;我认为那应该是一个对象:

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

关于javascript - 为什么谷歌图表 api 选项给我错误名为 "uncaught syntax error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9844766/

相关文章:

javascript - 如何打开模态 onclick?

Javascript ' Array ' 和 ' Loop ' "variable[i] "如何成为条件

jquery - Klout 样式饼图

ios - 图表 lineChartDataset 舍入值

javascript - 转义引号 - 是否有其他字符可以使用?

javascript - ReactJS 这个 Prop 不是一个函数

php - Google Charts API,包含 4 个图的散点图,每个图有 4000 个点,可杀死 HTTPD

javascript - 如何在没有鼠标悬停的情况下始终在 chartjs 中显示标签?

charts - 从 Zingchart 中的 CSV 数据中获取系列和值

javascript - JS-用随机单引号解析数据