2014-09-20 3 views
1

방향에 따라 Jqplot 차트의 크기를 조정하고 싶습니다. 아래 코드가 있습니다. 작동하지 않습니다.JQPlot 차트 문제 크기 조정

var plot = $.jqplot('chartDivId', dataArray, options); 
     var w = parseInt($(".jqplot-yaxis").width(), 10) + parseInt($("#chartDivId").widt(), 10); 
     var h = parseInt($(".jqplot-title").height(), 10) + parseInt($(".jqplot-xaxis").height(), 10) + 
    parseInt($("#chartDivId").height(), 10); 
     $("#chartDivId").width(w).height(h); 
     plot.replot(); 

     $(window).on("orientationchange",function(event){ 
     alert("Orientation is: " + event.orientation); 
     plot.replot({ resetAxes: true }); 
    }); 

주석으로 아래의 코드

/* var w = parseInt($(".jqplot-yaxis").width(), 10) + parseInt($("#chartDivId").width(), 10); 
     var h = parseInt($(".jqplot-title").height(), 10) + parseInt($(".jqplot-xaxis").height(), 10) + parseInt($("#chartDivId").height(), 10); 
     $("#chartDivId").width(w).height(h); 
     plot.replot(); 
    */  

나는 위의 코드를 주석 처리하지 않으려는, 내가 어떻게이 문제를 해결할 경우 그것은 작동합니까? 사업부/용기/윈도우의 크기 변화 방향 결과에

Thanks..Johnson

+0

누군가 pls 내 질문에 대답 할 수 있습니까? –

+0

안녕하세요 @ 존슨 Tummalapalli, 아래 게시물은 당신을 도와 줬나요? –

+0

안녕하세요 Anish, 나는 바빴고 그것을 점검 할 기회가 없었습니다. 나는 확인하고 확인하겠습니다. 당신의 도움을 주셔서 감사합니다!! –

답변

0

변경합니다. 따라서 resize 이벤트 인 jQuery를 사용하여이 작업을 수행 할 수 있습니다.

그래서 코드는 다음과 같습니다. 여기에 작업 바이올린 밖으로

$(window).on("resize",function(event){ 
    plot.destroy(); // Destroy the chart.. 
    plot.replot(); // Replot the chart with new/old values.. 
}); 

점검 : Google 크롬의 출력 (차트)를 참조 할 수없는 경우 jqPlot Line Chart - Replot on resize event

대신 다른 브라우저를 시도하십시오.

도움이되지 않는 경우 일부 코드로 스 니펫을 업데이트하고 싶습니다.

희망이 있습니다.

+0

안녕하세요 Anish, 아직 작동하지 않습니다. 아래 코드는 범인입니다. 그러나 나는 그것을 논평하고 싶지 않다. var w = parseInt ($ (".jqplot-yaxis"). width(), 10) + parseInt ($ ("# chartDivId"). width(), 10); height(), 10) + parseInt ($ ("# chartDivId").). 높이(), 10); $ ("# chartDivId") 너비 (w). 높이 (h); plot.replot(); –