Sunday, May 19, 2024
HomeC#Efficiency Optimization in React Pivot Desk with Information Compression

Efficiency Optimization in React Pivot Desk with Information Compression


TL;DR: Uncover the facility of information compression within the Syncfusion React Pivot Desk! Learn the way this system improves efficiency by compressing uncooked knowledge based mostly on uniqueness, leading to quicker processing and diminished complexity, particularly with giant knowledge units.

The Syncfusion React Pivot Desk is an environment friendly management for organizing and summarizing enterprise knowledge, able to displaying the ends in a cross-table format. The info processed in real-time to generate a pivot desk typically reached the thousands and thousands. By using the info compression possibility, we will rapidly analyze giant quantities of information within the React Pivot Desk

It’s a way inside the Pivot Desk that compresses uncooked knowledge based mostly on uniqueness. The compressed knowledge is then utilized for subsequent operations, resulting in a notable enhancement in efficiency, particularly when the dataset comprises fewer distinctive information.

Why go for knowledge compression?

When binding a big knowledge supply, the Pivot Desk will course of all uncooked knowledge to generate aggregated outcomes for preliminary rendering and report manipulation.

In knowledge compression, the uncooked knowledge is compressed based mostly on its uniqueness and used as enter for the Pivot Desk. The compressed knowledge might be used for preliminary rendering and extra report manipulation choices akin to up-and-down drilling, filtering, sorting, modifying, and so on. It reduces loop complexity and improves pivot desk efficiency.

Let me clarify the way it works!

How does knowledge compression work?

Take into account, now we have a JSON knowledge supply with 156 rows. Since displaying all 156 uncooked JSON knowledge within the weblog will not be possible, I’ll present only a few knowledge for illustration functions.

    
let pivotData = [
  {
    'Sold': 31,
    'Amount': 52824,
    'Country': 'France',
    'Products': 'Mountain Bikes',
    'Year': 'FY 2015',
    'Quarter': 'Q1'
  },
  {
    'Sold': 51,
    'Amount': 86904,
    'Country': 'France',
    'Products': 'Mountain Bikes',
    'Year': 'FY 2015',
    'Quarter': 'Q2'
  },
  {
    'Sold': 90,
    'Amount': 153360,
    'Country': 'France',
    'Products': 'Mountain Bikes',
    'Year': 'FY 2015',
    'Quarter': 'Q3'
  },
  {
    'Sold': 25,
    'Amount': 42600,
    'Country': 'France',
    'Products': 'Mountain Bikes',
    'Year': 'FY 2015',
    'Quarter': 'Q4'
  }
];

After we render the Pivot Desk with the above uncooked knowledge, it can course of all 156 uncooked knowledge factors to supply aggregated knowledge based mostly on the report we sure and displayed within the Pivot Desk.

Let’s discover how the info compression method works in our Pivot Desk. To allow the Information Compression possibility within the Pivot Desk, set the allowDataCompression property to true. Assume that now we have sure the next report back to the Pivot Desk.

  
import { createRoot } from 'react-dom/consumer';
import './index.css';
import * as React from 'react';
import { PivotViewComponent } from '@syncfusion/ej2-react-pivotview';
let dataSourceSettings = {
    enableSorting: true,
    columns: [{ name: 'Year' }],
    rows: [{ name: 'Country' }],
    valueSortSettings: { headerDelimiter: ' - ' },
    values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }],
    dataSource: getPivotData(),
    formatSettings: [{ name: 'Amount', format: 'C0' }],
    expandAll: false,
    filters: []
};
perform Default() {
    return (<div className="control-pane">
            <div className="control-section" fashion={{ overflow: 'auto' }}>
                <PivotViewComponent id='PivotView' dataSourceSettings={dataSourceSettings} width={'100%'} top={'290'} gridSettings={{ columnWidth: 140 }} allowDataCompression={true}>
                </PivotViewComponent>
            </div>
        </div>);
}
export default Default;
const root = createRoot(doc.getElementById('pattern'));
root.render(<Default />);                    

When knowledge compression is enabled, the assigned uncooked knowledge might be compressed based mostly on the individuality of the fields sure within the row and column axes of the React Pivot Desk.

Within the above code, you’ll see that we added the Nation and 12 months fields from the assigned enter knowledge to the row and column axes, respectively. Each fields have 4 distinctive values, as listed under:

For the Nation discipline, now we have:

  • France
  • Germany
  • United Kingdom
  • United States

For the 12 months discipline, now we have:

  • FY 2015
  • FY 2016
  • FY 2017
  • FY 2018

When the Pivot Desk begins up, the assigned uncooked knowledge is compressed from 156 to 16 based mostly on the header values within the sure row and column fields. Have a look at the compressed knowledge under.

 
[
  {
    "Sold": 729,
    "Amount": 1160099.5,
    "Country": "France",
    "Products": "Mountain Bikes",
    "Year": "FY 2015",
    "Quarter": "Q1"
  },
  {
    "Sold": 609,
    "Amount": 983317,
    "Country": "France",
    "Products": "Mountain Bikes",
    "Year": "FY 2016",
    "Quarter": "Q1"
  },
  {
    "Sold": 703,
    "Amount": 1140998,
    "Country": "France",
    "Products": "Mountain Bikes",
    "Year": "FY 2017",
    "Quarter": "Q1"
  },
  {
    "Sold": 68,
    "Amount": 108401.5,
    "Country": "France",
    "Products": "Mountain Bikes",
    "Year": "FY 2018",
    "Quarter": "Q1"
  },
  {
    "Sold": 528,
    "Amount": 845472,
    "Country": "Germany",
    "Products": "Road Bikes",
    "Year": "FY 2015",
    "Quarter": "Q1"
  },
  {
    "Sold": 667,
    "Amount": 1067220,
    "Country": "Germany",
    "Products": "Road Bikes",
    "Year": "FY 2016",
    "Quarter": "Q1"
  },
  {
    "Sold": 579,
    "Amount": 945569,
    "Country": "Germany",
    "Products": "Road Bikes",
    "Year": "FY 2017",
    "Quarter": "Q1"
  },
  {
    "Sold": 130,
    "Amount": 211902.5,
    "Country": "Germany",
    "Products": "Mountain Bikes",
    "Year": "FY 2018",
    "Quarter": "Q1"
  },
  {
    "Sold": 782,
    "Amount": 1263109.5,
    "Country": "United Kingdom",
    "Products": "Mountain Bikes",
    "Year": "FY 2015",
    "Quarter": "Q1"
  },
  {
    "Sold": 640,
    "Amount": 1031630.5,
    "Country": "United Kingdom",
    "Products": "Mountain Bikes",
    "Year": "FY 2016",
    "Quarter": "Q1"
  },
  {
    "Sold": 657,
    "Amount": 1041050.5,
    "Country": "United Kingdom",
    "Products": "Mountain Bikes",
    "Year": "FY 2017",
    "Quarter": "Q1"
  },
  {
    "Sold": 161,
    "Amount": 265366.5,
    "Country": "United Kingdom",
    "Products": "Mountain Bikes",
    "Year": "FY 2018",
    "Quarter": "Q1"
  },
  {
    "Sold": 682,
    "Amount": 1085398.5,
    "Country": "United States",
    "Products": "Road Bikes",
    "Year": "FY 2015",
    "Quarter": "Q1"
  },
  {
    "Sold": 480,
    "Amount": 770362,
    "Country": "United States",
    "Products": "Road Bikes",
    "Year": "FY 2016",
    "Quarter": "Q1"
  },
  {
    "Sold": 644,
    "Amount": 1022551.5,  # This object remains unchanged
    "Country": "United States",
    "Products": "Road Bikes",
    "Year": "FY 2017",
    "Quarter": "Q1"
  },
  {
    "Sold": 232,
    "Amount": 366358,
    "Country": "United States",
    "Products": "Road Bikes",
    "Year": "FY 2018",
    "Quarter": "Q1"
  }
]

This compressed knowledge is used for preliminary rendering and subsequent report manipulation operations inside the React Pivot Desk, considerably enhancing the Pivot Desk’s efficiency. Information compression turns into more practical when there’s a bigger quantity of uncooked knowledge with fewer distinctive mixtures.

For instance, think about the Pivot Desk, which is linked to at least one million uncooked knowledge factors aggregated into 1,000 distinctive mixtures. The rendering time may very well be diminished to roughly 2-3 seconds, in comparison with 7-8 seconds with out compression.

Try the efficiency metrics for fundamental report manipulation operations after the implementation of information compression within the pivot desk.

 

With out Information Compression

(in seconds)

With Information Compression

 (in seconds)

Preliminary Rendering 7 3
Scrolling 0.5 0.1
Sorting 0.5 0.1
Filtering 1.2 0.2

Observe: Try the stackblitz instance of our React Pivot Desk, which we constructed to gather the above statistics data.

Factors to recollect whereas utilizing knowledge compression in React Pivot Desk

Whereas knowledge compression is an efficient technique to spice up knowledge processing pace in Pivot Desk, it is very important concentrate on some limitations that may scale back its effectivity.

Coping with distinctive information of information

After we take care of a considerable amount of enter knowledge, particularly with minimal distinctive information obtainable within the enter knowledge, the info compression performs exceptionally effectively.

Nonetheless, the effectiveness of information compression diminishes when your enter knowledge consists completely of distinctive information. In such circumstances, utilizing knowledge compression in Pivot Desk will not be advisable as a result of the first aim of information compression is probably not achieved.

Keep away from frequent report manipulation throughout runtime

It’s extra helpful when the report will not be recurrently manipulated throughout runtime, notably for dynamically including or eradicating fields between axes. For instance, if we dynamically add new fields to the Pivot Desk, the unique knowledge is compressed once more in line with the report. In consequence, compressing the info based mostly on the unique uncooked knowledge would require extra time.

Altering the aggregation sort for worth fields throughout runtime will observe an identical technique. In consequence, the change in aggregation could influence efficiency.

Unsupported aggregation types

We advocate you keep away from setting complicated aggregation varieties akin to CommonPopulationsdevSamplestdevPopulationvar, and Samplevar within the pivot report fields, as they might hinder the info compression course of.

If these aggregation varieties are utilized, the consequence will default to the Sum aggregation sort. This limitation is crucial to think about when organizing compressed knowledge for analytical functions.

Aggregation transformation for particular varieties 

The Distinct rely aggregation perform behaves in a different way when knowledge is compressed. Reasonably than sustaining its distinctive counting functionality, it capabilities as a Rely aggregation sort. This alteration impacts analytical outcomes, and you need to concentrate on this transformation to interpret compressed knowledge precisely.

Calculated discipline dynamics 

When integrating an present discipline right into a calculated discipline, the inserted discipline’s default aggregation sort stays the identical. Even when the sphere’s default aggregation sort is modified, the calculated discipline will revert to the unique default aggregation sort for calculations. This habits ensures consistency and prevents unintended modifications within the aggregation course of.

Discover the limitless prospects with Syncfusion’s excellent React UI parts.

Attempt It Free

Conclusion

In conclusion, enhancing efficiency in React Pivot Desk is crucial for delivering high-quality internet apps able to managing giant datasets effectively. Builders can preserve responsive and high-performing pivot tables by exploring and implementing knowledge compression methods, even with substantial knowledge volumes.

Our Pivot Desk can be obtainable in our Blazor, ASP.NET(CoreMVC), JavaScriptAngularReact, and Vue element suites. It’s designed to arrange and summarize enterprise knowledge elegantly in any app!

For present clients, the most recent model of Important Studio is offered for obtain from the License and Downloads web page. In case you are not a Syncfusion buyer but, think about attempting our 30-day free trial to discover the options.

For questions, you may contact us by way of our help discussion boardhelp portal, or suggestions portal. We’re all the time pleased to help you!

Thanks for studying!

Associated blogs:

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments