-
Notifications
You must be signed in to change notification settings - Fork 72
LG-5588 more chart customization points #3274
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
Changes from 2 commits
55bbf4a
6e257d7
b3fdac1
7134bf4
961335d
021fba4
b51f729
9f9bcd1
65bd9cd
6ab1097
8f439c4
a297942
489efc5
29f71a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@lg-charts/core': minor | ||
| --- | ||
|
|
||
| Adds more customization points to charts including 'axisPointer' prop for ChartTooltip, 'emphasis' prop for Bar, and 'type' prop for XAxis. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # IDE files | ||
| .idea | ||
| *.iml | ||
| .vscode | ||
|
|
||
| # Locally-installed dependencies | ||
| node_modules/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ export function ChartTooltip({ | |
| seriesValueFormatter, | ||
| seriesNameFormatter, | ||
| sort, | ||
| axisPointer, | ||
| }: ChartTooltipProps) { | ||
| const { | ||
| chart: { | ||
|
|
@@ -117,14 +118,21 @@ export function ChartTooltip({ | |
| /** | ||
| * using `extraCssText` instead of `className` because emotion-defined class | ||
| * didn't have high-enough specificity | ||
| * | ||
| * darkreader-ignore-inline-style class helps avoid the darkreader tampering | ||
| * with the tooltip styles. | ||
| */ | ||
| className: CHART_TOOLTIP_CLASSNAME, | ||
| className: `${CHART_TOOLTIP_CLASSNAME} darkreader-ignore-inline-style`, | ||
|
||
| extraCssText: getRootStylesText(theme), | ||
| borderWidth: 0, | ||
| padding: 0, | ||
| showDelay: 0, | ||
| hideDelay: 0, | ||
| transitionDuration: 0, | ||
| axisPointer: { | ||
| type: axisPointer, | ||
| }, | ||
|
|
||
| /** | ||
| * Since the formatter trigger is set to 'axis', the seriesData will be | ||
| * an array of objects. Additionally, it should contain axis related | ||
|
|
@@ -148,6 +156,7 @@ export function ChartTooltip({ | |
| theme, | ||
| tooltipPinned, | ||
| updateOptions, | ||
| axisPointer, | ||
| ]); | ||
|
|
||
| return null; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,12 @@ export interface ChartTooltipProps { | |||||||||||||
| seriesValueFormatter?: (value: OptionDataValue) => ReactNode; | ||||||||||||||
| seriesNameFormatter?: (name: SeriesName) => ReactNode; | ||||||||||||||
| headerFormatter?: (value: number | string) => ReactNode; | ||||||||||||||
| /** | ||||||||||||||
| * Controls the type of axis pointer shown with the tooltip. Default is 'line' | ||||||||||||||
| * which shows a vertical dashed line on hover. Set to 'none' for bar charts to | ||||||||||||||
| * avoid the dashed line from being rendered on top of the bars. | ||||||||||||||
|
||||||||||||||
| * Controls the type of axis pointer shown with the tooltip. Default is 'line' | |
| * which shows a vertical dashed line on hover. Set to 'none' for bar charts to | |
| * avoid the dashed line from being rendered on top of the bars. | |
| * Controls the type of axis pointer shown with the tooltip. | |
| * If not provided, the default is 'line', which shows a vertical dashed line on hover. | |
| * Set to 'none' for bar charts to avoid the dashed line from being rendered on top of the bars. |
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.
The axisPointer parameter now has a default value of 'line' in the component signature (ChartTooltip.tsx line 21), so the behavior matches the documentation π
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,33 +9,33 @@ export type BarProps = SeriesProps & { | |||||
| * Stack name for the series. Series with the same stack name are stacked together. | ||||||
| */ | ||||||
| stack?: string; | ||||||
|
|
||||||
| /** | ||||||
| * Hover focus behavior for the series. | ||||||
| * - `self`: Upon hovering over a bar, all other bars will be dimmed. | ||||||
| * - `none`: Other bars will not be affected by the hover. | ||||||
| */ | ||||||
| emphasis?: 'self'; | ||||||
|
||||||
| emphasis?: 'self'; | |
| emphasis?: 'self' | 'none'; |
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.
Fixed! β¨ The emphasis prop now includes both 'self' | 'none' in the type definition (commit b3fdac1).
Outdated
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.
Agree with copilot here, I think you missed 'none' in the type here.
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.
Fixed! Added 'none' to the type definition as you and Copilot both suggested (commit b3fdac1) π
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,13 @@ export const XAxisType = { | |
| Log: 'log', | ||
| Time: 'time', | ||
| Value: 'value', | ||
| /** | ||
| * The 'category' axis type is suitable for discrete types of data like bar charts, | ||
| * where each label should be aligned directly under its corresponding bar. Without | ||
| * using 'category', the charting library may automatically determine axis label positions, | ||
| * which might not correspond to each bar or data point. | ||
| */ | ||
| Category: 'category', | ||
|
||
| } as const; | ||
| type XAxisType = (typeof XAxisType)[keyof typeof XAxisType]; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.