-
Notifications
You must be signed in to change notification settings - Fork 22
Bar on click #400
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
Merged
Merged
Bar on click #400
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
6b73276
onClick added to BarProps
e93ca6a
Added OnClick to Bar story
7cf5142
Made bar elements interactive
fd7c42a
Added onClick prop to bar element
e167cbe
Wrote mark click handler for chart render
093aa9d
defined mark click hook
4fc085b
wrote getAllMarkElements util function
ef72c15
markOnClick filter update
17388d3
cursor to pointer on enter for bar utils
ec95006
Added interactive logic for bar mark items, onClick default to undefi…
eff1c86
added additional bar onClick stories and getInteractive jest tests
ece73fd
lint fix
672be34
added click event testing
a899172
refactored getInteractive and getCursor for onClick prop check
e48d6a0
refactored getInteractive tests
d41dd8b
used barUpdateEncodings to control cursor
f15c159
removed extra interactive fields
66b0dc7
added cursor definitions for tests
a0de997
set interactive to false for background bars
3a125ec
Updated onMarkClick to register clicks as Actions
53aeb86
lint fix
994f98e
getCursor and getInteractive conditional fix
9964dfb
Merge pull request #1 from adrianTJenkins/bar-onClick
adrianTJenkins 0798c2e
set background bar interactive to false, added props arg for rect
03677a3
restored interactive: false lines on barTestUtils
2845145
defaultProps for dodged and stacked bar stories
54ddf53
removed background cursor definition from getStackedBackgroundBar
bb30e28
removed cursor definitions in test cases
44e7961
Update src/utils/utils.ts
marshallpete 4266556
Update src/utils/utils.ts
marshallpete 7998b8c
Update src/utils/utils.ts
marshallpete 454aea8
Update src/utils/utils.ts
marshallpete 683d569
Merge branch 'adobe:main' into main
adrianTJenkins c070383
Merge branch 'main' of https://github.com/adrianTJenkins/react-spectr…
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 hidden or 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 hidden or 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,42 @@ | ||
| /* | ||
| * Copyright 2023 Adobe. All rights reserved. | ||
| * This file is licensed 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 REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
| import { createElement, useMemo } from 'react'; | ||
|
|
||
| import { getAllMarkElements } from '@utils'; | ||
|
|
||
| import { Chart } from '../Chart'; | ||
| import { Bar } from '../components/Bar'; | ||
| import { BarElement, ChartChildElement, Datum } from '../types'; | ||
|
|
||
| type MappedMarkElement = { name: string; element: BarElement }; | ||
|
|
||
| export type MarkDetail = { | ||
| markName?: string; | ||
| onClick?: (datum: Datum) => void; | ||
| }; | ||
|
|
||
| export default function useMarkOnClicks(children: ChartChildElement[]): MarkDetail[] { | ||
| const markElements = useMemo( | ||
| () => getAllMarkElements(createElement(Chart, { data: [] }, children), Bar, []) as MappedMarkElement[], | ||
| [children] | ||
| ); | ||
| return useMemo( | ||
| () => | ||
| markElements | ||
| .filter((mark) => mark.element.props.onClick) | ||
| .map((mark) => ({ | ||
| markName: mark.name, | ||
| onClick: mark.element.props.onClick, | ||
| })) as MarkDetail[], | ||
| [markElements] | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Do you know what code got added/modified that caused these to be removed?
Uh oh!
There was an error while loading. Please reload this page.
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.
I'm not sure on this. I don't remember modifying myself. I will restore the
interactive: falselines