2012-10-19 7 views
2

나는이 문제에 대한 해결책을 찾기 위해 오늘 아침 내 마음을 파고 있었고, 차트를 항목으로 넣을 Extjs 창을 가지고있다.창에 항목 추가하기 Extjs 4

Ext.define('Metrics.view.ChartWin', { 
extend: ['Ext.window.Window'], 
alias: 'widget.chartwin', 
requires :['Ext.chart.*','Ext.Window', 'Ext.fx.target.Sprite', 'Ext.layout.container.Fit', 'Ext.window.MessageBox', 'Metrics.view.DrawChart'], 
    width: 800, 
    height: 600, 
    minHeight: 400, 
    minWidth: 550, 
    hidden: false, 
    shadow: false, 
    maximizable: true, 
    title: 'Area Chart', 
    renderTo: Ext.getBody(), 
    layout: 'fit', 
    tbar: [{ 
     text: 'Save Chart', 
     handler: function() { 
      Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function(choice){ 
       if(choice == 'yes'){ 
        chart.save({ 
         type: 'image/png' 
        }); 
       } 
      }); 
     } 
    }], 
    items:[{ 
        //I guess the problem comes from here?? 
     xtype : 'drawchart' 
    }] 
    }); 

내 차트 :

Ext.define('Metrics.view.DrawChart', { 
extend: 'Ext.chart.Chart', 
alias: 'widget.drawchart', 
requires: ['Ext.chart.*'], 
renderTo: Ext.getBody(), 
width: 700, 
height: 600, 
animate: true, 
store: 'GraphData', 
shadow : true, 
legend: { 
      position: 'right' 
     }, 
axes: [ 
    { 
     title: 'Week', 
     type: 'Numeric', 
     position: 'left', 
     fields: ['Week'], 
    grid : true 

    }, 
    { 
     title: 'In Out Backlog', 
     type: 'Numeric', 
     position: 'bottom', 
     fields: ['BL1 Alt'] 

    } 
], 

theme: 'Red', 


series: [ 
{ 
//BLA BLA BLA  
}] 
}); 

내 차트가 잘 작동 내가는 ExtJS 4를 사용하고, 여기 내 창입니다. 이제 제게 말해주십시오.이 차트를 내 창에 어떻게 추가합니까? 이 오류 메시지가 표시됩니다.

Cannot read property 'isInstance' of undefined 

감사합니다. 차트 정의에서

답변

3

제거

renderTo: Ext.getBody() 

. 차트가 창에 렌더링되어야합니다. 다음 윈도우를 인스턴스화하고이 항목으로 차트를 설정합니다 http://jsfiddle.net/AMx6r/1282/

: 여기에 코드에서

Ext.create('Ext.window.Window', { 
... 
items: [{ 
    xtype: 'drawchart' 
}] 
...