### Clone and Run Vue Pivottable Locally
Source: https://github.com/vue-pivottable/vue3-pivottable/blob/main/README.md
Steps to clone the repository, install dependencies, and start the development server for local development.
```bash
# Clone the repo
git clone https://github.com/vue-pivottable/vue3-pivottable.git
cd vue-pivottable
# Install dependencies
pnpm install
# Start the dev server
pnpm dev
```
--------------------------------
### Vue 3 Quick Start Example
Source: https://github.com/vue-pivottable/vue3-pivottable/blob/main/README.md
Basic usage of the VuePivottableUi component in a Vue 3 application. Ensure you import the necessary CSS.
```vue
```
--------------------------------
### Install vue-pivottable with NPM
Source: https://github.com/vue-pivottable/vue3-pivottable/blob/main/README.md
Use this command to install the vue-pivottable package using NPM.
```bash
npm install vue-pivottable
```
--------------------------------
### Install vue-pivottable with PNPM
Source: https://github.com/vue-pivottable/vue3-pivottable/blob/main/README.md
Use this command to install the vue-pivottable package using PNPM.
```bash
pnpm add vue-pivottable
```
--------------------------------
### Integrate Plotly Chart Renderers with Vue Pivottable
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Utilize Plotly-based chart visualizations by importing PlotlyRenderers and merging them with the base Renderer object. This example uses a 'Grouped Bar Chart'.
```vue
```
--------------------------------
### Customize Heatmap Colors with tableColorScaleGenerator
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Use the tableColorScaleGenerator prop to pass a function that maps data values to specific RGB colors. This example demonstrates both a blue-scale gradient and a green-to-red variance scale.
```vue
```
--------------------------------
### Configure localization and language packs
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Demonstrates how to apply a locale and custom language pack to the VuePivottableUi component.
```vue
```
--------------------------------
### VuePivottableUi Component Usage
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Use VuePivottableUi for an interactive pivot table with drag-and-drop configuration. Import the component and its CSS, then provide data and configuration props. It emits pivot model changes.
```vue
```
--------------------------------
### VuePivottable Component Usage
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Use VuePivottable for a non-interactive pivot table rendering. Import the component and its CSS, then provide data and configuration props. It supports row and column totals.
```vue
```
--------------------------------
### Configure Vue Pivottable with Custom Renderers
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Integrate Vue Pivottable with custom renderers, including built-in options like 'Table Heatmap'. Ensure the CSS is imported for proper styling.
```vue
```
--------------------------------
### Create reactive pivot data with usePivotData
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Uses the usePivotData composable to generate reactive pivot table data with automatic cleanup on component unmount.
```vue
```
--------------------------------
### PivotData Class for Programmatic Analysis
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Utilize the PivotData class for direct data processing, aggregation, and analysis outside of the UI components. Import PivotUtilities to access PivotData and aggregators.
```javascript
import { PivotUtilities } from 'vue-pivottable'
const { PivotData, aggregators } = PivotUtilities
const data = [
{ product: 'Widget', region: 'North', sales: 100, units: 10 },
{ product: 'Widget', region: 'South', sales: 150, units: 15 },
{ product: 'Gadget', region: 'North', sales: 200, units: 8 },
{ product: 'Gadget', region: 'South', sales: 180, units: 12 }
]
const pivotData = new PivotData({
data: data,
rows: ['product'],
cols: ['region'],
vals: ['sales'],
aggregators: aggregators,
aggregatorName: 'Sum',
valueFilter: {},
rowOrder: 'key_a_to_z',
colOrder: 'key_a_to_z'
})
// Get row and column keys
const rowKeys = pivotData.getRowKeys() // [['Widget'], ['Gadget']]
const colKeys = pivotData.getColKeys() // [['North'], ['South']]
// Get aggregated value for a specific cell
const aggregator = pivotData.getAggregator(['Widget'], ['North'])
console.log(aggregator.value()) // 100
console.log(aggregator.format(aggregator.value())) // "100.00"
// Get row total
const rowTotal = pivotData.getAggregator(['Widget'], [])
console.log(rowTotal.value()) // 250 (100 + 150)
// Get grand total
const grandTotal = pivotData.getAggregator([], [])
console.log(grandTotal.value()) // 630
// Access filtered data
const filteredRecords = pivotData.getFilteredData()
```
--------------------------------
### Define Built-in and Custom Aggregators in Vue Pivottable
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Access and utilize built-in aggregators from PivotUtilities. Demonstrates creating custom aggregators with specific number formatting.
```javascript
import { PivotUtilities, VuePivottableUi } from 'vue-pivottable'
const { aggregators, aggregatorTemplates, numberFormat } = PivotUtilities
// Available built-in aggregators:
const builtInAggregators = {
'Count': aggregators['Count'],
'Count Unique Values': aggregators['Count Unique Values'],
'List Unique Values': aggregators['List Unique Values'],
'Sum': aggregators['Sum'],
'Integer Sum': aggregators['Integer Sum'],
'Average': aggregators['Average'],
'Median': aggregators['Median'],
'Sample Variance': aggregators['Sample Variance'],
'Sample Standard Deviation': aggregators['Sample Standard Deviation'],
'Minimum': aggregators['Minimum'],
'Maximum': aggregators['Maximum'],
'First': aggregators['First'],
'Last': aggregators['Last'],
'Sum over Sum': aggregators['Sum over Sum'],
'Sum as Fraction of Total': aggregators['Sum as Fraction of Total'],
'Sum as Fraction of Rows': aggregators['Sum as Fraction of Rows'],
'Sum as Fraction of Columns': aggregators['Sum as Fraction of Columns'],
'Count as Fraction of Total': aggregators['Count as Fraction of Total'],
'Count as Fraction of Rows': aggregators['Count as Fraction of Rows'],
'Count as Fraction of Columns': aggregators['Count as Fraction of Columns']
}
// Create custom aggregator with custom formatter
const customFormatter = numberFormat({
digitsAfterDecimal: 0,
thousandsSep: ',',
decimalSep: '.',
prefix: '$',
suffix: ''
})
const customAggregators = {
...aggregators,
'Dollar Sum': aggregatorTemplates.sum(customFormatter),
'Percentage': aggregatorTemplates.runningStat('mean', 1, numberFormat({
digitsAfterDecimal: 1,
scaler: 100,
suffix: '%'
}))
}
```
--------------------------------
### Implement Lazy Table Rendering
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Use the lazy table renderer to handle large datasets through chunked rendering. Import the renderer and merge it into the component's renderers object.
```vue
```
--------------------------------
### Configure Custom Sorting
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Control row and column ordering using the sorters prop and PivotUtilities.sortAs. Row and column order can be further refined using predefined sort keys.
```vue
```
--------------------------------
### Create Derived Attributes
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Define calculated fields using PivotUtilities derivers for date formatting and value binning. Custom functions can also be provided to transform record data.
```vue
```
--------------------------------
### Filter Data Values
Source: https://context7.com/vue-pivottable/vue3-pivottable/llms.txt
Exclude specific items from analysis by providing a filter object where keys are attribute names and values are objects mapping items to exclude to true.
```vue
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.