### Install Dependencies and Start Dev Server (Yarn) Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-svelte.md Commands to install project dependencies and start the development server using Yarn. ```bash yarn yarn start // or yarn dev ``` -------------------------------- ### Navigate and Install Dependencies Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-angular.md Change directory into the newly created project and install all necessary dependencies using yarn. Then, start the development server. ```bash cd my-angular-pivot-app yarn yarn start // or yarn dev ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-react.md Install project dependencies and start the development server using npm. ```json npm install npm run dev ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-react.md Install project dependencies and start the development server using Yarn. ```jsx yarn yarn start // or yarn dev ``` -------------------------------- ### Install Dependencies for Documentation Source: https://github.com/dhtmlx/docs-pivot/blob/master/README.md Install the necessary project dependencies using Yarn. ```bash $ yarn ``` -------------------------------- ### Start Local Documentation Server Source: https://github.com/dhtmlx/docs-pivot/blob/master/README.md Run the documentation on a local server to explore it. ```bash $ yarn start ``` -------------------------------- ### Export Data Example Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/api/table/export.md Demonstrates how to export data from the table. This example is interactive and can be run directly. ```html ``` -------------------------------- ### Example Usage of api.on() Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/api/internal/on-method.md This example demonstrates how to use the api.on() method to listen for the 'open-filter' event and log the field label when a filter is activated. ```APIDOC ## Example Usage of api.on() ### Description The example below shows how to output the label of a field for which the filter was activated. ### Code ```javascript // create Pivot const table = new pivot.Pivot("#root", { fields, data: dataset, config: { rows: ["studio", "genre"], columns: [], values: [ { field: "title", method: "count" }, { field: "score", method: "max" } ] } }); table.api.on("open-filter", (ev) => { const fieldObj = ev.field; const field = fieldObj.base || fieldObj.field; if (field) { console.log("The field for which filter was activated:", ev.field.label); } }, {tag: "open-filter-tag"}); ``` ``` -------------------------------- ### Create React App Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-react.md Use npx to create a new React project. Ensure Node.js and optionally Vite are installed. ```bash npx create-react-app my-react-pivot-app ``` -------------------------------- ### Create Svelte Project with Vite Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-svelte.md Use this command to initialize a new Svelte project with Vite. Ensure Node.js is installed. ```bash npm create vite@latest ``` -------------------------------- ### Custom Header Template Example Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/api/config/headershape-property.md This example demonstrates how to customize the header text by converting the default label, subLabel, and method to lowercase. This is useful for standardizing header appearance. ```jsx new pivot.Pivot("#pivot", { data, headerShape: { // a custom template for header text template: (label, id, subLabel) => (label + (subLabel ? ` (${subLabel})` : "")).toLowerCase(), }, config: { rows: ["state", "product_type"], columns: [], values: [ { field: "profit", method: "sum" }, { field: "sales", method: "sum" }, // other values ], }, fields, }); ``` -------------------------------- ### Import Pivot Trial Package Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-svelte.md Import the Pivot component and its CSS file when using the trial version installed from the @dhx/trial-pivot package. ```html ``` -------------------------------- ### Create Vue Project Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-vue.md Use the official Vue project scaffolding tool to create a new Vue project. Ensure Node.js is installed before running this command. ```bash npm create vue@latest ``` -------------------------------- ### Import Pivot PRO Version Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-react.md Import Pivot source files for the PRO version when installed from a local folder. Ensure the CSS file is correctly referenced. ```jsx import { Pivot } from 'dhx-pivot-package'; import 'dhx-pivot-package/dist/pivot.css'; ``` -------------------------------- ### Import Pivot PRO Version Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/integration-with-vue.md Import Pivot source files for the PRO version when installing from a local folder. Ensure the CSS path is correct, using 'pivot.min.css' if the files are minified. ```html ``` -------------------------------- ### Pivot Initialization with Data Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/api/config/data-property.md Example of initializing the DHTMLX Pivot component with the `data` property. ```APIDOC ## Pivot Initialization with Data ### Example ```jsx const table = new pivot.Pivot("#root", { fields, data: [ { rank: 1, title: "Shingeki no Kyojin: The Final Season - Kanketsu-hen", popularity: 609, genre: "Action", studio: "MAPPA", type: "Special", episodes: 2, duration: 61, members: 347875, score: 9.17, }, { rank: 2, title: "Fullmetal Alchemist: Brotherhood", popularity: 3, genre: "Action", studio: "Bones", type: "TV", episodes: 64, duration: 24, members: 3109951, score: 9.11 }, //other data objects ], config: { rows: ["studio", "genre"], columns: [], values: [ { field: "title", method: "count" }, { field: "score", method: "max" } ] } }); ``` ``` -------------------------------- ### Expand/Collapse All Rows Example Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/api/table/open-row.md This example demonstrates how to open and close all rows in the DHTMLX Pivot table using a button click. It utilizes the getTable method to access the table instance and assumes tree mode is enabled. ```javascript { view: "pivot", id: "pivot1", //... other pivot config on: { "open-row": (args) => { console.log(args); return false; }, "close-row": (args) => { console.log(args); return false; } } } ``` -------------------------------- ### Implement Custom Sorting with UI Interaction Source: https://github.com/dhtmlx/docs-pivot/blob/master/docs/guides/working-with-data.md Set up default sorting for fields and enable UI interaction for sorting by clicking on column headers. This example includes updating icons and reconfiguring the table. ```jsx const bar = document.getElementById("bar"); let sorted = ["studio", "genre"]; setFields(); bar.addEventListener('click', (e) => switchSort(e.target.id), false); function setFields(){ let html = ""; let sortedFields = fields.filter(f => (sorted.indexOf(f.id) != -1)); sortedFields.forEach((f) =>{ const order = f.sort || "asc"; html += `