我有一个AmCharts序列图,其中一些列表示数值。根据这些值,有时其中一个轴从地面“拔出”making a weird effect。我没有成功尝试将属性valueAxis.minimum设置为零。
有没有办法强制valueAxis从零开始?
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(function() {
});
function recordData()
{
var responses=[];
var cm=',';
var divs = document.getElementsByTagName("div");
for(var i=0;i<divs.length;i++)
{
var id=divs[i].getAttribute(['id']);
var qnum=$('div#' + id + ' ' + 'input.hiding').val();
var question=document.getElementById(id).innerHTML;
var answer=$('input[name="n' + qnum + '"]:checked').val();
if(id!='controls')
{
if(!answer)
{
window.alert('You did not answer question number ' + Number(i+1) + '. It is a requirement of this survey that all questions must be answered.' );
return;
}
else
{
var end='is near';
var s=qnum + cm + question + cm + answer;
responses.push(s.split(cm));
}
}
}
google.script.run
.withSuccessHandler(displayThanks)
.recordData(responses);
}
function displayThanks()
{
var divs = document.getElementsByTagName("div");
for(var i=0;i<divs.length;i++)
{
divs[i].style.cssText="display:none;text-align:center";
}
var elemDiv = document.createElement('div');
elemDiv.innerHTML="<br /><h1>Thank You For Your Participation in This Survey</h1>";
document.body.appendChild(elemDiv);
}
console.log('My Code Here');
</script>
<style>
#reply{display:none;}
#collect{display:block;}
body {
background-image: url("http://myrabridgforth.com/wp-content/uploads/blue-sky-clouds.jpg");
background-color: #ffffff;
background-repeat: no-repeat;
background-position: left bottom;
}
</style>
</head>
<body>
答案 0 :(得分:3)
有时,AmCharts不尊重您设置的minimum
,具体取决于您的数据和其他因素。您可以尝试通过将strictMinMax
设置为true来强制执行每个valueAxis,以强制执行minimum
(当然,您必须确保在每个值轴中设置minimum
)。
AmCharts.makeChart("chartdiv", {
"type": "serial",
//"synchronizeGrid": true,
"valueAxes":
[{
"minimum": 0,
"strictMinMax": true,
// ...
},
//repeat if you have multiple value axes that need to start from 0
]
// ...
});
请注意,如果您使用this example底部提到的synchronizeGrid
功能,则必须禁用它,否则根本不会考虑您的最小值/最大值。< / p>