Вставить jqPlot в панель ExtJs - PullRequest
0 голосов
/ 11 марта 2011

Когда я использую jqplot, он волшебным образом внедряет график в указанный div-график1:

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

то же самое верно и для ExtJ, которые вводят созданный код в div 'info':

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>

Также помещение html в extjs не работает, потому что html chart1 имеет значение null (на данный момент!?):

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

1 Ответ

1 голос
/ 11 марта 2011

Вам необходимо настроить прослушиватель на экземпляре панели для прослушивания события 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');
            }
        }
    });

});
...