-
Notifications
You must be signed in to change notification settings - Fork 122
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
feat: debug state for the heatmap chart #976
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1eef3a1
feat: debug state
darnautov 26aa2f5
Merge remote-tracking branch 'upstream/master' into swimlane-debug-data
darnautov faa8296
feat: use common debug state
darnautov 1f5208a
Merge remote-tracking branch 'upstream/master' into swimlane-debug-data
darnautov a54e683
feat: update charts.api.md, add api:check:local command
darnautov 7540d5f
feat: update storybook with cells seleciton actions
darnautov a86c4f2
feat: debug state control
darnautov ebc9123
feat: log debug state
darnautov 077a91b
feat: add highlighted data to the debug state
darnautov 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
87 changes: 87 additions & 0 deletions
87
src/chart_types/heatmap/state/selectors/get_debug_state.ts
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,87 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import createCachedSelector from 're-reselect'; | ||
|
||
import { RGBtoString } from '../../../../common/color_library_wrappers'; | ||
import { LegendItem } from '../../../../common/legend'; | ||
import { getChartIdSelector } from '../../../../state/selectors/get_chart_id'; | ||
import { DebugState, DebugStateLegend } from '../../../../state/types'; | ||
import { Position } from '../../../../utils/common'; | ||
import { computeLegendSelector } from './compute_legend'; | ||
import { geometries } from './geometries'; | ||
import { getHighlightedAreaSelector } from './get_highlighted_area'; | ||
|
||
/** | ||
* Returns a stringified version of the `debugState` | ||
* @internal | ||
*/ | ||
export const getDebugStateSelector = createCachedSelector( | ||
[geometries, computeLegendSelector, getHighlightedAreaSelector], | ||
(geoms, legend, pickedArea): DebugState => { | ||
return { | ||
// Common debug state | ||
legend: getLegendState(legend), | ||
axes: { | ||
x: [ | ||
{ | ||
id: 'x', | ||
position: Position.Left, | ||
labels: geoms.heatmapViewModel.xValues.map(({ text }) => text), | ||
values: geoms.heatmapViewModel.xValues.map(({ value }) => value), | ||
// vertical lines | ||
gridlines: geoms.heatmapViewModel.gridLines.x.map((line) => ({ x: line.x1, y: line.y2 })), | ||
}, | ||
], | ||
y: [ | ||
{ | ||
id: 'y', | ||
position: Position.Bottom, | ||
labels: geoms.heatmapViewModel.yValues.map(({ text }) => text), | ||
values: geoms.heatmapViewModel.yValues.map(({ value }) => value), | ||
// horizontal lines | ||
gridlines: geoms.heatmapViewModel.gridLines.y.map((line) => ({ x: line.x2, y: line.y1 })), | ||
}, | ||
], | ||
}, | ||
// Heatmap debug state | ||
heatmap: { | ||
cells: geoms.heatmapViewModel.cells.map(({ x, y, fill, formatted, value }) => ({ | ||
x, | ||
y, | ||
fill: RGBtoString(fill.color), | ||
formatted, | ||
value, | ||
})), | ||
selectedArea: pickedArea, | ||
}, | ||
}; | ||
}, | ||
)(getChartIdSelector); | ||
|
||
function getLegendState(legendItems: LegendItem[]): DebugStateLegend { | ||
const items = legendItems | ||
.filter(({ isSeriesHidden }) => !isSeriesHidden) | ||
.map(({ label: name, color, seriesIdentifiers: [{ key }] }) => ({ | ||
key, | ||
name, | ||
color, | ||
})); | ||
|
||
return { items }; | ||
} |
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
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.
👍🏼