-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(partition): improving on chart events and callbacks #991
Merged
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
09fa9be
test: flame chart in playground
monfera 7717760
feat: add more metadata for event handlers
monfera b2ece70
test: add more metadata for event handlers
monfera 4f4f719
refactor: pure rename of model to viewModel
monfera 1552e98
refactor: initiate renaming of ShapeTreeNode => ArrayNode link
monfera 5ad4644
Merge branch 'master' into partition-events
monfera b2ee431
Merge remote-tracking branch 'origin/master' into partition-events
monfera 56d3511
chore: api update and addition of property documentation
monfera be1cb79
chore: added model key
monfera d93d092
fix: undid unwanted image update
monfera e1bef27
chore: further linting and minor renames
monfera 6be5580
Merge branch 'master' into partition-events
monfera f9ec72d
chore: pr feedback ht Nick
monfera 9c562fb
Merge remote-tracking branch 'origin/master' into partition-events
monfera 3daca1a
Merge remote-tracking branch 'monfera/partition-events' into partitio…
monfera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
import { CategoryKey } from '../../../../common/category'; | ||
import { LegendPath } from '../../../../state/actions/legend'; | ||
import { Datum } from '../../../../utils/common'; | ||
import { Datum, ValueAccessor } from '../../../../utils/common'; | ||
import { Relation } from '../types/types'; | ||
|
||
export const AGGREGATE_KEY = 'value'; | ||
|
@@ -60,6 +60,7 @@ interface MapNode extends NodeDescriptor { | |
/** @internal */ | ||
export const HIERARCHY_ROOT_KEY: Key = '__root_key__'; | ||
|
||
/** @public */ | ||
export type PrimitiveValue = string | number | null; // there could be more but sufficient for now | ||
type Key = CategoryKey; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a huge fan of redefining types like this. But can be changed later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, let's chat |
||
export type Sorter = (a: number, b: number) => number; | ||
|
@@ -88,10 +89,17 @@ export function pathAccessor(n: ArrayEntry) { | |
const ascending: Sorter = (a, b) => a - b; | ||
const descending: Sorter = (a, b) => b - a; | ||
|
||
/** @public */ | ||
export function getNodeName(node: ArrayNode) { | ||
const index = node[SORT_INDEX_KEY]; | ||
const arrayEntry: ArrayEntry = node[PARENT_KEY][CHILDREN_KEY][index]; | ||
return entryKey(arrayEntry); | ||
} | ||
|
||
/** @internal */ | ||
export function groupByRollup( | ||
keyAccessors: Array<((a: Datum) => Key) | ((a: Datum, i: number) => Key)>, | ||
valueAccessor: (v: any) => any, | ||
valueAccessor: ValueAccessor, | ||
{ | ||
reducer, | ||
identity, | ||
|
@@ -108,7 +116,7 @@ export function groupByRollup( | |
const keyCount = keyAccessors.length; | ||
let pointer: HierarchyOfMaps = p; | ||
keyAccessors.forEach((keyAccessor, i) => { | ||
const key = keyAccessor(n, index); | ||
const key: Key = keyAccessor(n, index); | ||
const last = i === keyCount - 1; | ||
const node = pointer.get(key); | ||
const inputIndices = node?.[INPUT_KEY] ?? []; | ||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems fine to me. Are you trying to avoid breaking changes? I'd say this would be breaking.
One way to somewhat deafen a breaking change would be to keep the
parent
key but add the@deprecated
flag. Replace all usage in kibana with theMODEL_KEY
string. Then later we could change the name but it would be a cleaner breaking change when we removeparent
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Nick! The plan would be:
Full compatibility stage, no breaking API, eg. after merging this PR (
"whatever"
changed back to"parent"
)parent
MODEL_KEY
Deprecation stage:
.parent
with[MODEL_KEY]
@deprecated
tag, at least conceptually, as I think we can't have two identically named props at the same time, though haven't triedBreaking change:
.parent
for the model, we make the breaking change ofconst MODEL_KEY = 'model'
I'm not sure if the proposed commit would still work, pls. indicate if that's the case, glad to try.
At least from the diff, it's not clear what the deprecation line belongs to