2
페이지를로드 할 때 입력 필드에서 간단한 jqPlot 차트로 소스 데이터를 가져 오려고합니다.변수를 jqPlot 차트에 전달
표준 구문을 사용하면 jqPlot이 정상적으로 작동합니다. 예를 들면 다음과 같습니다.
var plot1 = $.jqplot ('chart1', [[1,2,3,4,]]);
변수를 사용하면 차트가 변수의 첫 번째 정수에만 반응합니다. Var의 숫자 값/문자열 품질에 문제가 있다고 생각합니다.
나는 돈을 벌고 있나? 아니면 불가능한 일을하려고합니까?
HTML :
<div class="dataforchart"> <!-- VALUES -->
<input type="text" value="5">
<input type="text" value="2">
<input type="text" value="8">
<input type="text" value="1">
</div>
<div id="chart1"> <!-- CHART -->
</div>
스크립트 : SO에
$('.dataforchart').each(function(){
str = '';
$(this).children("input").each(function() {
str = str + ', ' + $(this).val();
});
alert(str);
var plot1 = $.jqplot ('chart1', [[str]]);
});
내가 찾은 매우 유사한 문제, 그러나 나는 작업 솔루션을 발견하지 않았습니다.
업데이트 :
...
var points = [];
$(this).children("input").each(function(index) {
points[index] = $(this).val();
});
var plot1 = $.jqplot('chart1',[points]);
업데이트 바이올린 : http://jsfiddle.net/fdKRw/3/
감사합니다. –