2014-05-18 6 views
1

체크 박스를 클릭 한 후에 만 ​​jqplot에서 오버레이를 트리거하는 방법 (html이로드되지 않을 때). 처음에 overlay 옵션 show를 false로 설정하면 첫 번째 플롯에 오버레이가 표시되지 않고 트리거 함수를 사용할 때 오버레이가 나타나지 않습니다. 그때 사용canvasOverlay in jqplot

<div id="fastest" style="margin-top:20px; margin-left:20px; margin-right:200px; width:800px; height:400px;"> 
<script class="code" type="text/javascript"> 
$(document).ready(function(){ 
var dataset="too long to be displayed here" 
plot1 = $.jqplot('fastest', dataset, { 
    title: 'Test_figs', 
    legend: {show:false}, 
    series: [{ 
     showMarker: false, 
     color: '#ED0E0E', 
     label: 'R spectrum', 
     neighborThreshold: -1 
    }], 
    axes:{ 
     xaxis:{ 
      label:'Restframe Wavelength' 
     }, 
     yaxis:{ 
      label:'Flux', 
      tickOptions:{formatString:'%.3e'} 
     } 
    }, 
    cursor:{ 
     show:true, 
     zoom:true, 
     tooltipLocation:'sw' 
    }, 

    Canvasoverlay: { 
     show: false, 
     objects: [ 

      {verticalLine: { 
       name: 'Na-ID', 
       x: 5893.000000, 
       lineWidth: 2, 
       color: '#F0630C', 
       lineCap:'butt', 
       yOffset:0, 
       shadow: true 
      }} 
     ] 
    } 
}); 
}); 

function NaID_trigger() { 
var co = plot1.plugins.canvasOverlay; 
var line = co.get('Na-ID'); 
if (line.options.show==false) line.options.show = true; 
else line.options.show = false; 
co.draw(plot1); 
} 
</script> 

:

<button onclick="NaID_trigger()">Na-ID</button> 

가 또는 예를 들어 떨어져 오버레이를 트리거 는 여기 플롯에 사용하는 코드입니다.

추신 : 나는 오버레이 옵션에서 show = false를했을 때 작동하지 않는다고 권고 한대로 replot에 의해 draw를 대체 해 보았습니다.

+0

아직 시도한 내용으로 몇 가지 코드를 제공해 주시겠습니까? co.draw (plot1)를 co.replot()으로 대체하려고 했습니까? – AnthonyLeGovic

+0

방금 ​​질문에 qjplot에 대해 사용한 함수를 추가했습니다. – Demetrius

+0

나는 co.draw (plot1)를 plot1.replot()으로 변경하려고 시도했다. – Demetrius

답변

0

마침내 해결책을 직접 찾았습니다. jqplot이로드 될 때 오버레이를 표시하지 않기 위해 전체 오버레이 "show"옵션을 true로 설정했습니다. 그런 다음 각 객체 내에서 show를 false로 설정합니다. 대신에 I 폼의 짝수 핸들러로 전환하기 전에 사용 플롯 함수 외부의

는 : 체크 박스가 초기에 틱 아닌 경우

$("input[type=checkbox][name=Na-ID]").change(function(){ 
    plot1.plugins.canvasOverlay.get('Na-ID').options.show = this.checked; 
    plot1.replot(); 
}); 

지금 플롯 선택된 오버레이를 표시. 희망 사항은 동일한 문제가있는 사람에게 도움이되기를 바랍니다.