2011-03-11 2 views
0

나는 그것이 마술 지정된 DIV의에 chart1에 플롯 주입 jqplot 사용하고 있습니다 :삽입 jqPlot는

var chart1 = $.jqplot('chart1', weeks , {... 

동일 ExtJS에 대한 사실이다 '정보'로 생성 된 코드를 삽입 div에 :

var testPanel = new Ext.Panel({ 
    title: "Test", 
}); 
testPanel.render('info'); 

하지만 어떻게 차트 1을 패널에 플롯 할 수 있습니까? 다음 HTML은 작동하지 않습니다

<div id="info">    
    <div id="chart1" class="plot" style="width:400px;height:260px;"></div> 
</div> 

은 또한에 extjs에 HTML을 퍼팅 작동하지 않습니다에 chart1의 HTML이 (!?이 시점에서) 널 (null)이기 때문에 :

var testPanel = new Ext.Panel({ 
    title: "Test", 
    html: $('chart1').html() 
}); 
testPanel.render('info'); 

답변

1

당신은 설정해야합니다 패널 인스턴스의 수신기로 render 이벤트를 수신 한 다음 차트를 패널 본문에 그립니다.

http://jsfiddle.net/chrisramakers/ZXDru/

Ext.onReady(function(){ 

    new Ext.Panel({ 
     renderTo: Ext.getBody(), 
     frame: true, 
     title: 'Test panel', 
     height: 250, 
     listeners: { 
      render: function(){ 

       // this.body.dom is the raw dom object of the body element of this panel 
       // render your plot to this.body.dom 
       console.log(this.body.dom) 
       this.body.update('This is the new content'); 
      } 
     } 
    }); 

}); 
+0

덕분에 빠른 답변을 많이. 이제 extj에 대한 타이밍을 올바르게 만드는 방법을 알고 있습니다. 하지만 jqplot을 플로팅하는 방법을 조사해야 할 것입니다. 간단한 접근법은 작동하지 않습니다 : var chart1 = $ .jqplot (this.body.dom, weeks, { – Karussell

+0

플롯을 본문으로 렌더링하는 버튼에 플롯 기능을 바인딩하면 패널을로드 또는 렌더링하지 않습니다 그게 작동합니까? – ChrisR

+0

hmmh, 'chart1'에 대한 html 코드가 'info'div (패널)에 있지만 차트와 패널이 별도로 표시됩니다 (패널에 텍스트가없는 버튼이있는 경우)이 패널은 차트 아래에 있습니다 ... – Karussell