Grid performance

Posted by: mark.nebrat on 3 December 2017, 3:21 am EST

    • Post Options:
    • Link

    Posted 3 December 2017, 3:21 am EST

    Hello

    We want to use grid as dashboard:

    1. We init grid with 300 rows.
    2. Every one second additional row was added.

    On i7 core the average CPU consuming time per every refresh (100 secs) is 50ms.

    Could you please check our code for correct usage of update grid datasource.

    Can we improve performance in our example?

    Our code:

    html:

    <wj-flex-grid [itemsSource]=“data” style=“max-height: 350px” #flex>

    <wj-flex-grid-column [header]=“‘Country’” [binding]=“‘country’” [width]=“‘*’”>

    <wj-flex-grid-column [header]=“‘Date’” [binding]=“‘date’”>

    <wj-flex-grid-column [header]=“‘Revenue’” [binding]=“‘amount’” [format]=“‘n0’”>

    <wj-flex-grid-column [header]=“‘Active’” [binding]=“‘active’”>

    ts:

    
    @Component({
      selector: 'app-wg',
      templateUrl: './wgrid.component.html',
      styleUrls: ['./wgrid.component.css']
    })
    
    export class WGridComponent {
      // generate some random data
      protected dataSvc: DataSvcService;
      dataArray = new wjcCore.ObservableArray();
    
      data: wjcCore.CollectionView;
      countries = 'US,Germany,UK,Japan,Italy,Greece'.split(',');
      count = 301;
      constructor() {
        this.init(300, this.dataArray);
    
        this.data = new wjcCore.CollectionView(this.dataArray);
    
        setInterval(() => {
          this.getData(this.count++, this.dataArray);
          this.data.refresh();
        }, 1000);
    
      }
    
      public init(count: number, data: any[]) {
        for (var i = 0; i < count; i++) {
          this.getData(i, data);
        }
        return data;
      }
    
      getData(i: number, data: any[]) {
    
        data.unshift({
          id: i,
          country: this.countries[i % this.countries.length],
          date: new Date(2014, i % 12, i % 28),
          amount: Math.trunc(Math.random() * 10000),
          active: i % 4 == 0
        });
        return data;
    
      }
    
    }
    
    
    
    
    
    

    Thanks in advance.

    Best Regards,

    Mark Nebrat

  • Posted 3 December 2017, 5:50 pm EST

    Hi,

    I would recommend using the invalidate method instead of using the refresh method.The “invalidate” method also calls “refresh” internally , but on a timeOut, so if you call “invalidate” 100 times without any delays, the grid will refresh only once.

    http://demos.wijmo.com/5/Angular/WijmoHelp/WijmoHelp/topic/wijmo.grid.FlexGrid.Class.html#invalidate

    Please let me know if you are still facing issues.

    Thanks,

    Abhishek

  • Posted 6 December 2017, 6:51 pm EST

    Thanks

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels