kibana/dev_docs/lens/table.mdx
Stratoula Kalafateli 10e34e4723
Make the formula api optional for the lens builder (#179255)
## Summary

For ES|QL charts the formula api should be redundant. This is going to
make the api lighter as there is no need to import the lens plugin if
you want to use the builder to create ES|QL charts.
2024-03-25 07:09:37 -07:00

68 lines
No EOL
2 KiB
Text

---
id: kibDevLensConfigAPITable
slug: /kibana-dev-docs/lens/config-builder/table
title: Lens Config Builder API - Table
description: Lens Config Builder API - Table
date: 2024-03-04
tags: ['kibana', 'dev', 'lens', 'table']
---
import Dataset from './dataset.mdx';
import Breakdown from './breakdown.mdx';
Understanding `LensTableConfig` in detail
## Required Properties
### `chartType`
- **Type:** Fixed value `'table'`
- **Description:** Sets the chart type to table, allowing for the display of data in a tabular format. Tables are versatile for detailed data analysis, enabling the display of multiple dimensions and metrics side by side.
### `title`
- **Type:** `string`
- **Description:** The title of the visualization.
<Dataset />
## Optional Properties
### `splitBy`
- **Type:** `LensBreakdownConfig[]`
- **Optional**
- **Description:** An array of breakdown configurations to segment the data into different sections within the table. Each breakdown can create a new column or row based on the field specified, allowing for complex data organization and grouping. Check breakdown configuration details below.
### `breakdown`
- **Type:** `LensBreakdownConfig[]`
- **Optional**
- **Description:** Similar to `splitBy`, but specifically used for creating additional columns based on the breakdown of a particular field. It's useful for comparing metrics across different categories directly within the table. Check breakdown configuration details below.
<Breakdown />
## Example
```
const tableConfig: LensConfig = {
chartType: 'table',
title: 'Table chart',
dataset: {
esql: 'from kibana_sample_data_logs | stats bytes=sum(bytes) by geo.dest, geo.src',
},
splitBy: [
'geo.src'
],
breakdown: [
'geo.dest'
],
value: 'bytes',
};
const configBuilder = new LensConfigBuilder(dataViewsAPI, lensFormulaAPI);
const lensConfig = configBuilder.build(tableConfig, {
timeRange: { from: 'now-1y', to: 'now', type: 'relative' },
embeddable: true,
});
```