Fixes #39070 - Update AreaChart to PatternFly5#10803
Fixes #39070 - Update AreaChart to PatternFly5#10803tlabaj wants to merge 1 commit intotheforeman:developfrom
Conversation
f0cc83c to
d891a09
Compare
kmalyjur
left a comment
There was a problem hiding this comment.
I'm leaving an initial review, I might comment more tomorrow.
|
|
||
| return ( | ||
| <div style={{ height: chartHeight, width: chartWidth || '100%' }}> | ||
| <Chart |
There was a problem hiding this comment.
Could the chart fill the entire width of the card?
| legendData={legendData} | ||
| legendOrientation="horizontal" | ||
| legendPosition="bottom" | ||
| legendComponent={<ChartLegend />} |
There was a problem hiding this comment.
The old chart has clickable legend text, it would be nice to have it in the new one, too.
| <ChartAxis | ||
| tickFormat={t => { | ||
| if (config === 'timeseries' && t instanceof Date) { |
There was a problem hiding this comment.
The config === 'timeseries' can be removed since the data transformation always creates Date objects anyway.
| <ChartAxis | |
| tickFormat={t => { | |
| if (config === 'timeseries' && t instanceof Date) { | |
| <ChartAxis | |
| tickFormat={t => { | |
| if (t instanceof Date) { |
| expect(chartWrapper).toHaveStyle({ height: '300px', width: '500px' }); | ||
| }); | ||
|
|
||
| it('renders with onclick callback', () => { |
There was a problem hiding this comment.
The test checks if the chart renders, but it does not verify if the callback actually triggers when clicked.
| const handleClick = useMemo( | ||
| () => (event, datum) => { | ||
| if (onclick && datum && datum.name) { | ||
| onclick({ id: datum.name }); | ||
| } | ||
| }, | ||
| [onclick] | ||
| ); |
There was a problem hiding this comment.
I think this function is broken or not called.
webpack/assets/javascripts/react_app/components/common/charts/AreaChart/index.js
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| const timestamps = timeColumn.slice(1); | ||
| const dates = timestamps.map(epochSecs => new Date(epochSecs * 1000)); |
There was a problem hiding this comment.
The axis shows raw numbers (like "17709"). There could be a check if the backend is already sending milliseconds, and if so, it shouldn't use * 1000.
aff21d3 to
29cbd88
Compare
|
@kmalyjur Could you please re-review this one? |
| onclick, | ||
| noDataMsg, | ||
| config, | ||
| unloadData, |
There was a problem hiding this comment.
I'm so sorry, I think I told you before that it's unused, which it is, but I forgot about: "Received props should be kept the same, otherwise this task should also refactor the chart uses in the plugin."
It should be there, and the default should be false.
|
Thank you, the code looks right now. The only thing that works/looks different from the old chart is the timestamps. I explain how I understand it in the comment above. |
2a86311 to
f459f34
Compare
|
LGTM, I need to verify it now |
|
@tlabaj I have the same comment on it as on the BarChart PR - could the padding not be hardcoded? I worry it would be overlapping again for longer y-axis values. |
554dd27 to
7d45eda
Compare
|
@tlabaj Thank you for your changes, it looks good. |
2a383dd to
efcd088
Compare
| axisLabelComponent={ | ||
| yAxisLabel ? ( | ||
| <ChartLabel x={Y_AXIS_LABEL} dy={yAxisLabelOffset} /> | ||
| ) : undefined |
| : t; | ||
| }; | ||
|
|
||
| /** Match BarChart: fixed decimals for normal range; scientific notation for very large magnitudes. */ |
There was a problem hiding this comment.
Great comment, but "Match BarChart" is unnecessary
| const DEFAULT_HEIGHT = 250; | ||
| const DEFAULT_WIDTH = 800; | ||
|
|
||
| /** Left padding is computed from y-axis tick label width (see BarChart). */ |
There was a problem hiding this comment.
Good comment, but "(see BarChart)" seems unnecessary
kmalyjur
left a comment
There was a problem hiding this comment.
This fixes the label. Other than that, it's ready to get merged.
webpack/assets/javascripts/react_app/components/common/charts/AreaChart/index.js
Outdated
Show resolved
Hide resolved
Co-authored-by: kmalyjur <78563507+kmalyjur@users.noreply.github.com> Made-with: Cursor





Fixes: #39070
This PR updates the Area Chart to use PF5 components.
New images after latest Updates
Before:
After: