<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/