### Aggregate Data with Quartile Methods Source: https://context7.com/manufac-analytics/echarts-simple-transform/llms.txt Calculates statistical summaries including min, max, and quartiles (Q1, median, Q3) for box plot visualizations. The 'median' method serves as an alias for Q2. ```javascript import * as echarts from 'echarts'; import * as ecSimpleTransform from '@manufac/echarts-simple-transform'; echarts.registerTransform(ecSimpleTransform.aggregate); const option = { dataset: [{ source: [ ['category', 'value'], ['A', 10], ['A', 20], ['A', 30], ['A', 40], ['A', 50], ['B', 15], ['B', 25], ['B', 35], ['B', 45], ['B', 55], ['C', 5], ['C', 15], ['C', 25], ['C', 35], ['C', 45] ] }, { transform: { type: 'ecSimpleTransform:aggregate', config: { resultDimensions: [ { from: 'category' }, { from: 'value', method: 'min', name: 'min' }, { from: 'value', method: 'Q1', name: 'Q1' }, { from: 'value', method: 'median', name: 'median' }, // Q2 alias { from: 'value', method: 'Q3', name: 'Q3' }, { from: 'value', method: 'max', name: 'max' } ], groupBy: 'category' } } // Result: statistical summary for each category // [ // ['category', 'min', 'Q1', 'median', 'Q3', 'max'], // ['A', 10, 20, 30, 40, 50], // ['B', 15, 25, 35, 45, 55], // ['C', 5, 15, 25, 35, 45] // ] }], xAxis: { type: 'category' }, yAxis: {}, series: [{ type: 'boxplot', datasetIndex: 1 }] }; const myChart = echarts.init(document.getElementById('chart')); myChart.setOption(option); ``` -------------------------------- ### AggregateTransformConfig Interface Source: https://context7.com/manufac-analytics/echarts-simple-transform/llms.txt The configuration interface for the aggregate transform defines the structure for specifying result dimensions and grouping behavior. Each result dimension requires a `from` field referencing the source dimension, an optional `method` for aggregation (defaults to 'first'), and an optional `name` to rename the output dimension. ```APIDOC ## AggregateTransformConfig Interface The configuration interface for the aggregate transform defines the structure for specifying result dimensions and grouping behavior. Each result dimension requires a `from` field referencing the source dimension, an optional `method` for aggregation (defaults to 'first'), and an optional `name` to rename the output dimension. ### Interface Definition ```typescript interface AggregateTransformConfig { resultDimensions: Array<{ from: string; name?: string; method?: string }>; groupBy?: string; } ``` ### Parameters #### `resultDimensions` (Array of Objects) - Required An array of objects, where each object defines a resulting dimension. - **from** (string) - Required - The name of the source dimension to aggregate from. - **name** (string) - Optional - The name for the new aggregated dimension. If not provided, it defaults to the `from` dimension name. - **method** (string) - Optional - The aggregation method to apply. Defaults to 'first'. Supported methods include: 'sum', 'count', 'first', 'average', 'min', 'max', 'Q1', 'Q2', 'median', 'Q3'. #### `groupBy` (string) - Optional The name of the dimension to group the data by before aggregation. ### Request Example ```typescript import { AggregateTransformConfig } from '@manufac/echarts-simple-transform'; const aggregateConfig: AggregateTransformConfig = { resultDimensions: [ { from: 'category', name: 'category', method: 'first' }, { from: 'amount', name: 'totalAmount', method: 'sum' }, { from: 'amount', name: 'avgAmount', method: 'average' }, { from: 'amount', name: 'itemCount', method: 'count' }, { from: 'price', name: 'minPrice', method: 'min' }, { from: 'price', name: 'maxPrice', method: 'max' } ], groupBy: 'category' }; ``` ### Supported Aggregation Methods - `sum`: Sum of all values in the group - `count`: Number of items in the group - `first`: First value encountered (default) - `average`: Arithmetic mean of values - `min`: Minimum value in the group - `max`: Maximum value in the group - `Q1`: First quartile (25th percentile) - `Q2`: Second quartile (50th percentile) - `median`: Alias for Q2 - `Q3`: Third quartile (75th percentile) ``` -------------------------------- ### Register and Use Aggregate Transform Source: https://github.com/manufac-analytics/echarts-simple-transform/blob/main/README.md Registers the aggregate transform and applies it to a dataset to perform operations like sum, count, and median based on a grouping dimension. ```javascript echarts.registerTransform(ecSimpleTransform.aggregate); const option = { dataset: [{ source: [ ['aa', 'bb', 'cc', 'tag'], [12, 0.33, 5200, 'AA'], [21, 0.65, 7100, 'AA'], [51, 0.15, 1100, 'BB'], [71, 0.75, 9100, 'BB'], ... ] }, { transform: { type: 'ecSimpleTransform:aggregate', config: { resultDimensions: [ // by default, use the same name with `from`. { from: 'aa', method: 'sum' }, { from: 'bb', method: 'count' }, { from: 'cc' }, // method by default: use the first value. { from: 'dd', method: 'Q1' }, { from: 'tag' } ], groupBy: 'tag' } } // Then the result data will be: // [ // ['aa', 'bb', 'cc', 'tag'], // [12, 0.33, 5200, 'AA'], // [21, 0.65, 8100, 'BB'], // ... // ] }], // ... }; const myChart = echarts.init(dom); myChart.setOption(option); ``` -------------------------------- ### Configure Aggregate Transform Source: https://context7.com/manufac-analytics/echarts-simple-transform/llms.txt Defines the structure for grouping data and applying aggregation methods using the AggregateTransformConfig interface. ```typescript import { AggregateTransformConfig } from '@manufac/echarts-simple-transform'; // TypeScript configuration example const aggregateConfig: AggregateTransformConfig = { resultDimensions: [ { from: 'category', name: 'category', method: 'first' }, { from: 'amount', name: 'totalAmount', method: 'sum' }, { from: 'amount', name: 'avgAmount', method: 'average' }, { from: 'amount', name: 'itemCount', method: 'count' }, { from: 'price', name: 'minPrice', method: 'min' }, { from: 'price', name: 'maxPrice', method: 'max' } ], groupBy: 'category' }; // Supported aggregation methods (case-insensitive): // - 'sum' : Sum of all values in the group // - 'count' : Number of items in the group // - 'first' : First value encountered (default) // - 'average' : Arithmetic mean of values // - 'min' : Minimum value in the group // - 'max' : Maximum value in the group // - 'Q1' : First quartile (25th percentile) // - 'Q2' : Second quartile (50th percentile) // - 'median' : Alias for Q2 // - 'Q3' : Third quartile (75th percentile) ``` -------------------------------- ### Chain Multiple Transforms in ECharts Source: https://context7.com/manufac-analytics/echarts-simple-transform/llms.txt Register aggregate and id transforms, then chain them by referencing the previous dataset index in the configuration. ```javascript import * as echarts from 'echarts'; import * as ecSimpleTransform from '@manufac/echarts-simple-transform'; echarts.registerTransform(ecSimpleTransform.aggregate); echarts.registerTransform(ecSimpleTransform.id); const option = { dataset: [{ // Original data source: [ ['product', 'quantity', 'price', 'store'], ['Laptop', 5, 1000, 'Store A'], ['Laptop', 3, 1000, 'Store B'], ['Phone', 10, 500, 'Store A'], ['Phone', 8, 500, 'Store B'], ['Tablet', 7, 300, 'Store A'], ['Tablet', 4, 300, 'Store B'] ] }, { // Step 1: Aggregate by product transform: { type: 'ecSimpleTransform:aggregate', config: { resultDimensions: [ { from: 'product' }, { from: 'quantity', method: 'sum' }, { from: 'price', method: 'first' } ], groupBy: 'product' } } }, { // Step 2: Add unique IDs to aggregated data fromDatasetIndex: 1, transform: { type: 'ecSimpleTransform:id', config: { dimensionIndex: 3, dimensionName: 'id' } } // Final result: // [ // ['product', 'quantity', 'price', 'id'], // ['Laptop', 8, 1000, 0], // ['Phone', 18, 500, 1], // ['Tablet', 11, 300, 2] // ] }], xAxis: { type: 'category' }, yAxis: {}, series: [{ type: 'bar', datasetIndex: 2, encode: { x: 'product', y: 'quantity' } }] }; const myChart = echarts.init(document.getElementById('chart')); myChart.setOption(option); ``` -------------------------------- ### Aggregate Data by Dimension Source: https://context7.com/manufac-analytics/echarts-simple-transform/llms.txt Groups source data by a specified dimension and applies aggregation methods like sum, average, and count. Requires registering the transform with echarts.registerTransform before use. ```javascript import * as echarts from 'echarts'; import * as ecSimpleTransform from '@manufac/echarts-simple-transform'; // Register the aggregate transform echarts.registerTransform(ecSimpleTransform.aggregate); const option = { dataset: [{ // Source data with individual records source: [ ['product', 'sales', 'revenue', 'region'], ['Widget A', 150, 4500, 'North'], ['Widget A', 200, 6000, 'South'], ['Widget B', 80, 3200, 'North'], ['Widget B', 120, 4800, 'South'], ['Widget C', 300, 9000, 'North'], ['Widget C', 250, 7500, 'South'] ] }, { // Aggregated dataset grouped by region transform: { type: 'ecSimpleTransform:aggregate', config: { resultDimensions: [ { from: 'region' }, // groupBy dimension (no method) { from: 'sales', method: 'sum' }, // total sales per region { from: 'revenue', method: 'average' }, // average revenue per region { from: 'product', method: 'count' } // count of products per region ], groupBy: 'region' } } // Result data: // [ // ['region', 'sales', 'revenue', 'product'], // ['North', 530, 5566.67, 3], // ['South', 570, 6100, 3] // ] }], xAxis: { type: 'category' }, yAxis: {}, series: [{ type: 'bar', datasetIndex: 1, encode: { x: 'region', y: 'sales' } }] }; const myChart = echarts.init(document.getElementById('chart')); myChart.setOption(option); ``` -------------------------------- ### Register and Use ID Transform Source: https://github.com/manufac-analytics/echarts-simple-transform/blob/main/README.md Registers the ID transform to append a unique identifier dimension to the dataset. ```javascript echarts.registerTransform(ecSimpleTransform.aggregate); const option = { dataset: [{ source: [ ['aa', 'bb', 'cc', 'tag'], [12, 0.33, 5200, 'AA'], [21, 0.65, 8100, 'AA'], ... ] }, { transform: { type: 'ecSimpleTransform:id', config: { dimensionIndex: 4, dimensionName: 'ID' } } // Then the result data will be: // [ // ['aa', 'bb', 'cc', 'tag', 'ID'], // [12, 0.33, 5200, 'AA', 0], // [21, 0.65, 8100, 'BB', 1], // ... // ] }], // ... }; const myChart = echarts.init(dom); myChart.setOption(option); ``` -------------------------------- ### Register and Use ID Transform Source: https://context7.com/manufac-analytics/echarts-simple-transform/llms.txt Registers the ID transform with ECharts and applies it to a dataset to inject a sequential identifier. ```javascript import * as echarts from 'echarts'; import * as ecSimpleTransform from '@manufac/echarts-simple-transform'; // Register the id transform echarts.registerTransform(ecSimpleTransform.id); const option = { dataset: [{ source: [ ['name', 'score', 'grade'], ['Alice', 95, 'A'], ['Bob', 87, 'B'], ['Charlie', 78, 'C'], ['Diana', 92, 'A'] ] }, { transform: { type: 'ecSimpleTransform:id', config: { dimensionIndex: 3, // Insert ID at index 3 (after grade) dimensionName: 'ID' // Name the new dimension 'ID' } } // Result data: // [ // ['name', 'score', 'grade', 'ID'], // ['Alice', 95, 'A', 0], // ['Bob', 87, 'B', 1], // ['Charlie', 78, 'C', 2], // ['Diana', 92, 'A', 3] // ] }], xAxis: { type: 'category' }, yAxis: {}, series: [{ type: 'bar', datasetIndex: 1, encode: { x: 'name', y: 'score' } }] }; const myChart = echarts.init(document.getElementById('chart')); myChart.setOption(option); ``` -------------------------------- ### ID Transform Source: https://context7.com/manufac-analytics/echarts-simple-transform/llms.txt The id transform adds a unique sequential identifier to each row in the dataset. This is useful for animations, tracking data points across updates, and creating stable references for tooltip interactions. The transform inserts an auto-incrementing ID at the specified dimension index. ```APIDOC ## ID Transform The id transform adds a unique sequential identifier to each row in the dataset. This is useful for animations, tracking data points across updates, and creating stable references for tooltip interactions. The transform inserts an auto-incrementing ID at the specified dimension index. ### Configuration - **dimensionIndex** (number) - Required - The index where the new ID dimension will be inserted. - **dimensionName** (string) - Optional - The name for the new ID dimension. Defaults to 'ID'. ### Request Example ```javascript import * as echarts from 'echarts'; import * as ecSimpleTransform from '@manufac/echarts-simple-transform'; // Register the id transform echarts.registerTransform(ecSimpleTransform.id); const option = { dataset: [{ source: [ ['name', 'score', 'grade'], ['Alice', 95, 'A'], ['Bob', 87, 'B'], ['Charlie', 78, 'C'], ['Diana', 92, 'A'] ] }, { transform: { type: 'ecSimpleTransform:id', config: { dimensionIndex: 3, // Insert ID at index 3 (after grade) dimensionName: 'ID' // Name the new dimension 'ID' } } }], xAxis: { type: 'category' }, yAxis: {}, series: [{ type: 'bar', datasetIndex: 1, encode: { x: 'name', y: 'score' } }] }; const myChart = echarts.init(document.getElementById('chart')); myChart.setOption(option); ``` ### Response Example ```json [ ['name', 'score', 'grade', 'ID'], ['Alice', 95, 'A', 0], ['Bob', 87, 'B', 1], ['Charlie', 78, 'C', 2], ['Diana', 92, 'A', 3] ] ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.