Skip to content

Commit

Permalink
[Table Visualization][BUG] partical rows shows metrics for all columns
Browse files Browse the repository at this point in the history
Currently, when we enable Show partial rows in the Options panel, we see metrics been
added to every column even though Show metrics for every bucket/level is not enabled.

Metrics are added and returned when we enable the partial rows. This PR fixed the bug
by slice the returned data to allow only the last set of metrices.

Partially resolved:
opensearch-project#2579 (comment)

Signed-off-by: Anan Zhuang <ananzh@amazon.com>
  • Loading branch information
ananzh committed Oct 21, 2022
1 parent c12b7c2 commit b1568c5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/plugins/vis_type_table/public/to_ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ export const toExpressionAst = (vis: Vis, params: any) => {
);

const schemas = getVisSchemas(vis, params);
// manul slice to remove duplicate metrics
const metrics =
schemas.bucket && vis.params.showPartialRows && !vis.params.showMetricsAtAllLevels
? schemas.metric.slice(-1 * (schemas.metric.length / schemas.bucket.length))
: schemas.metric;

const tableData = {
title: vis.title,
metrics: schemas.metric,
metrics,
buckets: schemas.bucket || [],
splitRow: schemas.split_row,
splitColumn: schemas.split_column,
Expand Down

0 comments on commit b1568c5

Please sign in to comment.