Results 1 to 2 of 2

Thread: extjs6 chart, add/remove series, when removeall series done, new series cannot be loa

  1. #1
    Sencha User
    Join Date
    Feb 2016
    Posts
    33
    Answers
    1

    Default extjs6 chart, add/remove series, when removeall series done, new series cannot be loa

    In my ExtJs6 project I dynamically load data into a line chart by clicking on a combobox (adding multiple series). Everything works fine.
    The issue is when I change the selection on the combobox that launches data FOR THE SECOND TIME (not initial selection), the load fails. Screenshot of error attached.

    er.jpg

    something about the getYRange
    By stepping through the code, I realize the error occurs the second time around when I remove all the old series. If I do not remove the series, the charts load a second time successfully, but the series are added to the first time around, and I am showing previous data in error.
    I get the error while my store is being loaded the second time around. Can someone please help with this... I've been tinkering around for days with no luck.

    Code:
    onComboboxSelect:function(combo, record, eOpts){
    Code:
    
        console.log('combobox changed');
    
        var me =this;
    
        //me.windowCumulative.mask('loading account data...');
    
        var selectedAcctNum;
    
        if(combo.text !='View Portfolio'){
            selectedAcctNum = record.get('AcctNum');
        }        
    
        //suspend all events
        myStoreTab1.suspendEvents(true);
        me.chartTab1.suspendEvents(true);
    
        console.log('remove all items from store');
        myStoreTab1.removeAll();
    
        console.log('remove all series from chart');
        me.chartTab1.removeSeries(me.chartTab1.series);
    
        console.log('loading store with new data');
    
        if(combo.text !='View Portfolio'){
            //account view
            myStoreTab1.load({
                url: x.util.GlobalVar.urlHistorical_getCumPl,
                params:{
                    acctNum: selectedAcctNum
                },
                callback:function(response, opts){
    
                    console.log('store successfully loaded');                    
                    me.windowCumulative.unmask();
                    me.addMethod();
                }
            });
        }else{
            //portfolio view
            myStoreTab1.load({
                url: x.util.GlobalVar.urlHistorical_getCumPl3,
                params:{
                    cid: me.cid
                },
                callback:function(response, opts){
                    console.log('store successfully loaded');
                    me.windowCumulative.unmask();
                    me.addMethod();
                }
            });
        }
    
    
    
        addMethod:function(){
    
        var me =this;
        count =0;
    
        //convert sql date to date datatype
        console.log('convert sql date to date datatype');
        myStoreTab1.each(function(record){
            record.set('filedate',newDate(record.get('filedate')));
        });
    
        console.log('sort and group');
        myStoreTab1.sort('filedate');
        myStoreTab1.group('instrument');
    
        testArray.length =0;
        var countGroups = myStoreTab1.getGroups().length -1;
        console.log('groupCount: '+ countGroups);
        myStoreTab1.getGroups().each(function(group, i){
    
            me.windowCumulative.mask('starting process...');
    
            var groupName =group._groupKey;
    
            console.log(count +": "+ groupName);
            DoMask(count, me.windowCumulative, countGroups,group, me.chartTab1, groupName);
    
        });
    
    },function DoMask(step, panel, countGroups, group, chart, groupName) {
    if(groupName !=''){
    
        var targetStore =Ext.create('Ext.data.Store',{
            model:'x.model.HistoricalInstrumentProfitModel'
        });
        console.log('targetStore created');
    
        var records =[];
    
        group.each(function(record){
            records.push(record.copy());
        });
        console.log('array populated with 1 group of trades');
    
        targetStore.add(records);
        console.log('added record array to targetStore');
    
        var series ={
            type:'line',
            axis:'left',
            xField:'filedate',
            yField:'cumulativePl',
            store: targetStore,
            title: groupName,
            tooltip:{
                trackMouse:true,
                renderer:'onSeriesTooltipRender'
            }
        };
        console.log('created series');
    
        testArray.push(series);
        console.log('added series to testArray');
    
        panel.mask('step : '+ groupName);
    
    }
    
    if(count == countGroups){
    
        console.log('attempt to add all series');
        chart.addSeries(testArray);
    
        console.log('attempt to chart: resume events');
        myStoreTab1.resumeEvents();
        chart.resumeEvents();
    
        panel.unmask();
    }
    
    count++;}



  2. #2
    Sencha User
    Join Date
    Feb 2016
    Posts
    33
    Answers
    1

    Default

    disregard this problem... can't figure out how to erase post

Similar Threads

  1. Replies: 0
    Last Post: 7 Sep 2017, 10:13 PM
  2. Replies: 2
    Last Post: 28 Feb 2013, 4:43 AM
  3. Replies: 11
    Last Post: 10 Jul 2012, 11:48 AM
  4. Replies: 3
    Last Post: 20 Jan 2012, 12:45 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •