2017-04-03 1 views
1

팬 끝에 zoomCallback과 같은 함수를 첨부 할 방법을 찾고 있습니다. 일반 JS에서 응용 프로그램을 작성하고 있지만 팬이 끝날 때까지 을 제대로 감지 할 수있는 방법을 찾을 수 없습니다. 나는 무엇을 시도했다 :Dygraphs panEnd 콜백

  • 이 팬 핸들러 here 교체에 대한 예를 찾을 수 있지만 나를 위해 작동하지 않습니다, Dygraph.Interaction = 정의되지 않은.
  • {endPan : function() {...}}을 Dygraph.defaultInteractionModel에 추가하면 해당 함수는 호출되지 않습니다.
  • Dygraph 함수 here에 endPan을 추가하는 또 다른 예가 있지만 작동하지 않습니다.
  • mouseup/touchend 이벤트가 첨부되었지만 mouseup/touchend 이후에만 dateWindow_가 업데이트됩니다. dygraph.js의 주석을 통해 읽기

, 그것은 panEnd (라인 2861)에 기능을 설정할 수로 사용하지만, 그 코드는 "이러한 방법/등록 정보에 액세스 옛날 방식"으로 주석,하지만하지 않습니다 새로운 방식이 무엇인지 말하십시오. 나는 drawCallback을 실험했지만 dygraph 객체를 걷는 것은 사용자가 여전히 바둑판 무늬로 바쁜지 여부를 알려주는 변수를 드러내지 않습니다.

팬 엔드에서 코드를 실행하는 방법이 있습니까?

감사합니다,

답변

0

당신은 당신의 자신의 interactionModel (나는 확대를 위해 그것을했다) 설정뿐만 아니라 패닝 작동 할 수 있습니다. 차트 초기화 내

const myInteractions = Object.assign({}, Dygraph.defaultInteractionModel, { 
     dblclick: (event, g, context) => { 
     console.log("double-click!", event, g, context); 
     }, 
     mousedown: (event, g, context) => { 
     console.log("start mousedown"); 
     context.initializeMouseDown(event, g, context); 
     Dygraph.startPan(event, g, context); 
     }, 
     mousemove: (event, g, context) => { 
     if(context.isPanning) { 
      console.log("mouse is moving", event, g, context); 
      Dygraph.movePan(event, g, context); 
     } 
     }, 
     mouseup: (event, g, context) => { 
     console.log("mouseup", event, g, context); 
     Dygraph.endPan(event, g, context); 
     context.isPanning = false; 
     } 
}); 

: 예를 들어, 시작하는 당신이 다른 키를 확인할 수 있습니다, 당신의 myInteractions 옵션 마우스 다운 이벤트 내에서

{ 
    // other options 
    interactionModel: myInteractions, 
} 

에 추가 줌 또는 팬

if (event.altKey || event.shiftKey) { 
    Dygraph.startZoom(event, g, context); 
} else { 
    Dygraph.startPan(event, g, context); 
}