Need a special offer?Find out if your project fits.
+
List of all demos

React Pivot Table

A robust React Pivot table component for multi-dimensional data analysis and visualization.

    import React from "react";
    import * as FlexmonsterReact from "react-flexmonster";
    
    class PivotTableDemo extends React.Component {
      render() {
        return (
          <>
            <div className="App">
              <FlexmonsterReact.Pivot
                componentFolder="https://cdn.flexmonster.com/"
                height={550}
                toolbar={true}
                report={{
                  dataSource: {
                    type: "json",
                    filename: "data/retail-data.json",
                    mapping: {
                      "Quantity": {
                        type: "number",
                      },
                      "Price": {
                        type: "number",
                      },
                      "Retail Category": {
                        type: "string",
                      },
                      "Sales": {
                        type: "number",
                      },
                      "Order Date": {
                        type: "year/quarter/month/day",
                      },
                      "Date": {
                        type: "date",
                      },
                      "Status": {
                        type: "string",
                      },
                      "Product Code": {
                        type: "string",
                      },
                      "Phone": {
                        type: "string",
                      },
                      "Country": {
                        type: "string",
                        folder: "Location",
                      },
                      "City": {
                        type: "string",
                        folder: "Location",
                      },
                      "CurrencyID": {
                        type: "property",
                        hierarchy: "Country",
                      },
                      "Contact Last Name": {
                        type: "string",
                      },
                      "Contact First Name": {
                        type: "string",
                      },
                      "Deal Size": {
                        type: "string",
                      },
                    },
                  },
                  slice: {
                    rows: [
                      {
                        uniqueName: "Country",
                        filter: {
                          members: [
                            "country.[australia]",
                            "country.[usa]",
                            "country.[japan]",
                          ],
                        },
                      },
                      {
                        uniqueName: "Status",
                      },
                    ],
                    columns: [
                      {
                        uniqueName: "Order Date",
                      },
                      {
                        uniqueName: "[Measures]",
                      },
                    ],
                    measures: [
                      {
                        uniqueName: "Price",
                        aggregation: "sum",
                        format: "currency",
                      },
                    ],
                    sorting: {
                      column: {
                        type: "desc",
                        tuple: [],
                        measure: {
                          uniqueName: "Price",
                          aggregation: "sum",
                        },
                      },
                    },
                    expands: {
                      rows: [
                        {
                          tuple: ["country.[japan]"],
                        },
                      ],
                    },
                    drills: {
                      columns: [
                        {
                          tuple: ["order date.[2019]"],
                        },
                      ],
                    },
                    flatSort: [
                      {
                        uniqueName: "Price",
                        sort: "desc",
                      },
                    ],
                  },
                  conditions: [
                    {
                      formula: "#value > 35000",
                      measure: "Price",
                      aggregation: "sum",
                      format: {
                        backgroundColor: "#00A45A",
                        color: "#FFFFFF",
                        fontFamily: "Arial",
                        fontSize: "12px",
                      },
                    },
                    {
                      formula: "#value < 2000",
                      measure: "Price",
                      aggregation: "sum",
                      format: {
                        backgroundColor: "#df3800",
                        color: "#FFFFFF",
                        fontFamily: "Arial",
                        fontSize: "12px",
                      },
                    },
                  ],
                  formats: [
                    {
                      name: "",
                      thousandsSeparator: ",",
                      decimalSeparator: ".",
                      decimalPlaces: 2,
                      nullValue: "-"
                    },
                    {
                      name: "currency",
                      currencySymbol: "$"
                    },
                  ],
                }}
                customizeCell={this.customizeCellFunction}
                shareReportConnection={{
                  url: "https://olap.flexmonster.com:9500",
                }}
                beforetoolbarcreated={(toolbar) => {
                  toolbar.showShareReportTab = true;
                }}
              />
            </div>
          </>
        );
      }
    
      customizeCellFunction = (cell, data) => {
        if (data.type === "header" && data.hierarchy?.caption === "Country" && data.member?.properties) {
          const name = data.member.properties.CurrencyID;
          cell.addClass("fm-custom-cell");
          let flag;
          if (data.expanded) {
            flag = `<i class="fm-icon fm-expanded-icon" title="Click to collapse"></i>
    <img class="flag-icon" src="https://cdn.flexmonster.com/flags/${name.toLowerCase()}.svg">`;
          } else {
            flag = `<i class="fm-icon fm-collapsed-icon" title="Click to expand"></i>
    <img class="flag-icon" src="https://cdn.flexmonster.com/flags/${name.toLowerCase()}.svg">`;
          }
          cell.text = `<div style="display:flex; align-items:center; font-size:12px; position:relative;">
    ${flag}<span style="margin-left: 2px; line-height: 16px;">${data.member.caption}</span></div>`;
        }
      };
    }
    
    export default PivotTableDemo;
    
    .fm-custom-cell {
      display: flex !important;
      align-items: center !important;
      font-size: 12px !important;
    }
    
    .fm-custom-cell .flag-icon {
      width: 21px !important;
      height: 16px !important;
      margin-left: 0 !important;
      margin-right: 2px !important;
    }
    
    #fm-pivot-view .fm-grid-layout .fm-custom-cell.fm-expanded .fm-expanded-icon::before,
    #fm-pivot-view .fm-grid-layout .fm-custom-cell.fm-collapsed .fm-collapsed-icon::before {
      top: -2px;
      height: 16px;
    }
    

    Working with the Pivot table web component in integration with React has never been easier. Lightweight, yet full-functional to present your data in the best way - a React Pivot Table by Flexmonster is an enterprise solution for web developers.

    Create interactive reports on the data source you have your data stored: CSV, JSON, Elasticsearch, Microsoft Analysis Services, MongoDB, SQL databases (MySQL, PostgreSQL, Oracle, etc) or even custom data sources.

    Use feature-complete react pivot grid

    Collect the exact data you need with rich functionality: summarization, filtering, sorting, or grouping. This drag-n-drop react pivot table is also easy to use and navigate.

    Export the results of full-fledged data analysis to the files of the most common formats: PDF, CSV, Excel, HTML, or PNG or share them via link.

    Choose how the data is arranged on the grid using the classic (tabular), compact, or flat pivot table layouts. You can also show details about values cells by accessing the drill-through view.

    Embed React Pivot Grid into your application

    Flexmonster Pivot Table perfectly integrates with React using our ready-made wrappers. For Next.js users, check out our Integration with Next.js guide.

    Watch our detailed video guide on how to create React pivot table with all integration steps.