-
Notifications
You must be signed in to change notification settings - Fork 103
fix(Charts-New): fix labels of donut chart, fix yAxis width calculation of bar chart #498
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
MarcusNotheis
merged 17 commits into
master
from
fix(Charts---New)-fix-labels-of-donut-chart
May 8, 2020
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b8f37fb
fix(Charts-New): displaying labels in Pie charts when rerendering, ca…
kleinju1017 c47b32d
Merge branch 'master' into fix(Charts---New)-fix-labels-of-donut-chart
kleinju1017 8b7f3ac
fix(Pie Chart): data point click handler works now as expected
kleinju1017 6eca108
fix(Bar Chart): fixed calculation of yAxisWidth when there's a second…
kleinju1017 79896db
Update useLongestYAxisLabel.ts
kleinju1017 b3ac622
use x axis padding for line and area charts
MarcusNotheis b8df91a
fix(bar chart): fix calculation of marginLeft
kleinju1017 186989b
Merge branch 'fix(Charts---New)-fix-labels-of-donut-chart' of https:/…
kleinju1017 4f92a8f
Update useLongestYAxisLabelBar.ts
kleinju1017 093cc5d
Merge branch 'master' into fix(Charts---New)-fix-labels-of-donut-chart
MarcusNotheis f22909e
fix labels in pie chart
kleinju1017 42ed5bc
Code clean up
kleinju1017 47e5bf2
Merge branch 'master' into fix(Charts---New)-fix-labels-of-donut-chart
kleinju1017 d313fb8
Update PieChart.tsx
kleinju1017 cfab42a
Improve secondary dimensions
MarcusNotheis c2ba047
Merge branch 'fix(Charts---New)-fix-labels-of-donut-chart' of https:/…
MarcusNotheis 0ccd56b
Update useLongestYAxisLabelBar.ts
MarcusNotheis 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { getTextWidth } from '@ui5/webcomponents-react-charts/lib/Utils'; | ||
import { useMemo } from 'react'; | ||
import { getValueByDataKey } from 'recharts/lib/util/ChartUtils'; | ||
import { defaultMaxYAxisWidth } from '../internal/defaults'; | ||
|
||
export const useLongestYAxisLabelBar = (dataset: unknown[], elements): [number[], object] => | ||
useMemo(() => { | ||
let axisWidths = Array(elements.length).fill(0); | ||
let marginLeft = 0; | ||
|
||
if (dataset instanceof Array && elements) { | ||
const resolveAllMeasureLabels = (item): string[] => { | ||
return elements.map((elementConfig) => | ||
elementConfig.formatter(getValueByDataKey(item, elementConfig.accessor, '')) | ||
); | ||
}; | ||
|
||
const allFormattedDataLabels = dataset.map(resolveAllMeasureLabels); | ||
allFormattedDataLabels.forEach((dimensionLabels) => { | ||
dimensionLabels.forEach((label, dimensionIndex) => { | ||
axisWidths[dimensionIndex] = Math.max(getTextWidth(label), axisWidths[dimensionIndex]); | ||
}); | ||
}); | ||
|
||
axisWidths = axisWidths.map((length) => Math.min(defaultMaxYAxisWidth, length)); | ||
marginLeft = axisWidths.reduce((acc, val) => acc + val, 0); | ||
} | ||
|
||
return [axisWidths, { marginLeft, maxWidth: `calc(100% - ${marginLeft + 8}px)` }]; | ||
}, [dataset, elements]); |
23 changes: 0 additions & 23 deletions
23
packages/charts/src/internal/SecondaryDimensionXAxisTick.tsx
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
packages/charts/src/internal/SecondaryDimensionYAxisTick.tsx
This file was deleted.
Oops, something went wrong.
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
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.
Uh oh!
There was an error while loading. Please reload this page.