-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XY] Order by metric/custom metric doesn't work well for split chart (#…
…128185) * [XY] Order by metric/custom metric doesn't work well for split chart * Update Predicate import paths Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
3e2761d
commit 0a4f0fc
Showing
4 changed files
with
46 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Accessor, AccessorFn, GroupBy, SmallMultiples, Predicate } from '@elastic/charts'; | ||
|
||
interface ChartSplitProps { | ||
splitColumnAccessor?: Accessor | AccessorFn; | ||
splitRowAccessor?: Accessor | AccessorFn; | ||
} | ||
|
||
const CHART_SPLIT_ID = '__chart_split__'; | ||
|
||
export const ChartSplit = ({ splitColumnAccessor, splitRowAccessor }: ChartSplitProps) => { | ||
if (!splitColumnAccessor && !splitRowAccessor) return null; | ||
|
||
return ( | ||
<> | ||
<GroupBy | ||
id={CHART_SPLIT_ID} | ||
by={(spec, datum) => { | ||
const splitTypeAccessor = splitColumnAccessor || splitRowAccessor; | ||
if (splitTypeAccessor) { | ||
return typeof splitTypeAccessor === 'function' | ||
? splitTypeAccessor(datum) | ||
: datum[splitTypeAccessor]; | ||
} | ||
return spec.id; | ||
}} | ||
sort={Predicate.DataIndex} | ||
/> | ||
<SmallMultiples | ||
splitVertically={splitRowAccessor ? CHART_SPLIT_ID : undefined} | ||
splitHorizontally={splitColumnAccessor ? CHART_SPLIT_ID : undefined} | ||
/> | ||
</> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters