我的图表出了什么问题?我使用的是谷歌图表api
what is wrong with my chart? i am using google chart api
如红色箭头所示。为什么它在图表中显示-25行
我使用的javascript是.
<!DOCTYPE html>
<html>
<head> <meta http-equiv="refresh" content="30" />
<title>Analytics of Payment Service</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {
packages: ["corechart", "bar"]
});
google.setOnLoadCallback(function(){
drawChart2()
})
function drawChart2() {
var listOfDataCC =$!{dataForCCInvoice}
var outputArrayForInvoiceAndCredit = new Array();
// header
var headerArray1 = ['Day', 'cc', 'In'];
outputArrayForInvoiceAndCredit.push(headerArray1);
for (var i = 0; i < listOfDataCC.length; i++){
var obj1 = listOfDataCC[i];
var innerArray = new Array();
innerArray[0] = obj1.date;
innerArray[1] = obj1.CCount;
innerArray[2] = obj1.inCount;
outputArrayForInvoiceAndCredit.push(innerArray);
}
var data2 = google.visualization.arrayToDataTable(outputArrayForInvoiceAndCredit);
var options2 = {
title: 'CC/In Details',
curveType: 'function',
legend: {
position: 'bottom'
}
};
var chart2 = new google.visualization.LineChart(document.getElementById('cc/in'));
chart2.draw(data2, options2);
}
</script>
</head>
<body>
<div id="cc/in" style="width: 900px; height: 500px"></div>
</body>
</html>
价值$!{dataForCCInvoice}是json格式的值。json值为。
[
{
"date": "15-APR-16",
"CCount": 38,
"inCount": 18
},
{
"date": "16-APR-16",
"CCount": 9,
"inCount": 14
},
{
"date": "17-APR-16",
"CCount": 9,
"inCount": 3
},
{
"date": "18-APR-16",
"CCount": 52,
"inCount": 44
},
{
"date": "19-APR-16",
"CCount": 59,
"inCount": 44
},
{
"date": "20-APR-16",
"CCount": 9,
"inCount": 7
}
]
我在这里错过了什么。有时它工作正常,但不知道为什么-25行出现
要解决此问题,您可以在选项中添加以下内容:
vAxis: {viewWindow: {min: 0}}
所以它看起来是这样的:
var options2 = {
title: 'CC/In Details',
curveType: 'function',
legend: {
position: 'bottom'
},
vAxis: {
viewWindow: {
min: 0
}
}
};
我不知道为什么它一开始就显示-25线。我认为这是由于inCount中的值3,它足够低,可以使图表显示负值。
相关文章:
- 谷歌放置API:按国家或餐馆名称搜索餐馆
- 谷歌地图API v3不适用于移动浏览器或PhoneGap
- 谷歌地图JS API+JSON-多个标记没有显示
- 标记的实时更新,无需加载页面谷歌地图API V3
- 谷歌图表API:添加空白行到时间线
- 覆盖在赢得'不允许点击下面的标记,谷歌地图api v3
- 谷歌地图Api和JS代码不工作
- 谷歌地图API-InfoBubble赢得't关闭-关闭()不会'不起作用
- 如何在多承诺链中处理谷歌地图API V3事件
- 地理定位api和谷歌地图出错
- 谷歌地图api和gMapsLatLonPicker
- 谷歌地图地点API地图未显示
- 关于关键的API谷歌地图
- mark.setDragable(false)在API谷歌地图的main.js中抛出异常
- 隐藏标记出现后缩放- API谷歌地图V3
- Google Drive API;谷歌实时API -我可以把一个实时文件在应用程序文件夹
- 谷歌地图API -谷歌没有定义,异步加载的API
- 如何打印多个调用谷歌分析API谷歌表与应用程序脚本
- Mixpanel细分查询API谷歌电子表格
- 方向API谷歌方向请求失败,因为没有找到