-
Notifications
You must be signed in to change notification settings - Fork 524
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
Allow passing CustomIcon to Symbol in VictoryLegend and VictoryScatter #2900
Closed
acharyakavita
wants to merge
5
commits into
main
from
2892-victorylegend-items-should-support-an-element-to-allow-for-custom-icons
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6e7cb03
feat: CustomIcon to VictoryLegend and VictoryScatter
acharyakavita 3eb5478
feat: CustomIcon to VictoryLegend and VictoryScatter
acharyakavita 8ebd47f
fix conflict
acharyakavita aa484c6
update type
acharyakavita 868b44c
add changeset
acharyakavita 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"victory-core": minor | ||
"victory-scatter": minor | ||
--- | ||
|
||
Allow passing CustomIcon to Symbol in VictoryLegend and VictoryScatter |
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 | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ category: charts | |||||
type: docs | ||||||
scope: | ||||||
- sampleData | ||||||
- reactIconsFa | ||||||
--- | ||||||
|
||||||
# VictoryScatter | ||||||
|
@@ -530,16 +531,52 @@ _default (provided by default theme):_ See [grayscale theme][] for more detail | |||||
|
||||||
`type: function || options` | ||||||
|
||||||
The `symbol` prop determines which symbol should be drawn to represent data points. Options are: "circle", "cross", "diamond", "plus", "minus", "square", "star", "triangleDown", "triangleUp". When this prop is given as a function, it will be evaluated for each point with the props corresponding to that point. If no `symbol` prop is specified, a circle will be rendered. `symbol` may also be set directly on each data object. | ||||||
The `symbol` prop determines which symbol should be drawn to represent data points. Options are: "circle", "cross", "diamond", "plus", "minus", "square", "star", "triangleDown", "triangleUp".It also supports "custom React icons". When this prop is given as a function, it will be evaluated for each point with the props corresponding to that point. If no `symbol` prop is specified, a circle will be rendered. `symbol` may also be set directly on each data object. | ||||||
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. Minor fix for spacing and slight reword
Suggested change
|
||||||
|
||||||
_default:_ `symbol="circle"` | ||||||
|
||||||
```jsx | ||||||
import { FaSun,FaStar, FaVolleyballBall } from "react-icons/fa"; | ||||||
const CustomIcon = (props) => <FaStar x={props.x - 25} y={props.y - 25} /> | ||||||
const App(){ | ||||||
return <VictoryScatter | ||||||
data={[ | ||||||
{ x: 1, y: 85, symbol: <FaVolleyballBall size={20} /> }, | ||||||
{ x: 2, y: 55, symbol: <CustomIcon /> }, | ||||||
{ x: 3, y: 25, symbol: (props) => { | ||||||
const x = props.x - 20; | ||||||
const y = props.y - 20; | ||||||
return <FaFootballBall x={x} y={y} size={40} />; | ||||||
} | ||||||
} | ||||||
]} | ||||||
size={50} | ||||||
/> | ||||||
} | ||||||
``` | ||||||
|
||||||
```playground | ||||||
<VictoryScatter | ||||||
symbol={({ datum }) => datum.y > 3 ? "triangleUp" : "triangleDown"} | ||||||
size={7} | ||||||
data={sampleData} | ||||||
<> | ||||||
<VictoryScatter | ||||||
symbol={({ datum }) => datum.y > 3 ? "triangleUp" : "triangleDown"} | ||||||
size={7} | ||||||
data={sampleData} | ||||||
/> | ||||||
<VictoryScatter | ||||||
size={10} | ||||||
data={[ | ||||||
{ x: 1, y: 85, symbol: "star" }, | ||||||
{ x: 2, y: 55, | ||||||
symbol: (props)=>{ | ||||||
const FaSun = reactIconsFa['FaSun']; | ||||||
const x = props.x - 8; | ||||||
const y = props.y - 8; | ||||||
return <FaSun size={30} x={x} y={y}/> | ||||||
} | ||||||
}, | ||||||
]} | ||||||
/> | ||||||
</> | ||||||
``` | ||||||
|
||||||
## theme | ||||||
|
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.
Adds a bit more description