Skip to content
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

upcoming: [DI-21200] - Migration from ChartJS to Recharts in CloudPulse #11204

Draft
wants to merge 20 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7be47af
upcoming: [DI-20870] - Migrated chartjs to recharts for ACLP graphs
nikhagra-akamai Oct 16, 2024
c1d1808
upcoming: [DI-20870] - Removed unused imports
nikhagra-akamai Oct 16, 2024
aa9931a
upcoming: [DI-20870] - Removed CloudPulseWidgetColorPalette file
nikhagra-akamai Oct 16, 2024
48fb7bb
upcoming: [DI-20870] - Optimized code
nikhagra-akamai Oct 16, 2024
8482608
upcoming: [DI-21200] - Added connectNulls & color properties
nikhagra-akamai Oct 30, 2024
801ae23
upcoming: [DI-21200] - Added sort data based on timestamp
nikhagra-akamai Oct 30, 2024
3fc7ba9
upcoming: [DI-21200] - Updated x-axis tick format
nikhagra-akamai Oct 30, 2024
ef29f34
upcoming: [DI-21200] - Updated PR comments
nikhagra-akamai Oct 30, 2024
1fda168
upcoming: [DI-21200] - Hide legends if not data present
nikhagra-akamai Oct 30, 2024
b1b5248
upcoming: [DI-21200] - Updated legends height
nikhagra-akamai Nov 4, 2024
144818a
upcoming: [DI-21200] - Updated legend row color type
nikhagra-akamai Nov 4, 2024
62a5f98
upcoming: [DI-21200] - Code refactor
nikhagra-akamai Nov 4, 2024
a979311
upcoming: [DI-21200] - Added changeset
nikhagra-akamai Nov 4, 2024
75adf4d
upcoming: [DI-21200] - Moved DataSet type from types to CloudPulseLin…
nikhagra-akamai Nov 5, 2024
f36786d
upcoming: [DI-21200] - Synced with upstream develop
nikhagra-akamai Nov 5, 2024
6026adc
Merge branch 'develop' of github.com:linode/manager into recharts_mig…
nikhagra-akamai Nov 12, 2024
b8113b3
upcoming: [DI-21200] - updated height of chart & legend rows
nikhagra-akamai Nov 12, 2024
effca04
upcoming: [DI-21200] - Updated no data display positioning
nikhagra-akamai Nov 13, 2024
abc1fe3
upcoming: [DI-21200] - Merge conflicts resolved
nikhagra-akamai Nov 13, 2024
de10d79
upcoming: [DI-21841] - Removed connect nulls
nikhagra-akamai Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Upcoming Features
---

Add `DataSet` type in `types.ts` ([#11204](https://github.com/linode/manager/pull/11204))
5 changes: 5 additions & 0 deletions packages/api-v4/src/cloudpulse/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,8 @@ export interface ServiceTypes {
export interface ServiceTypesList {
data: ServiceTypes[];
}

export interface DataSet {
[label: string]: number;
timestamp: number;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interfaces in the API SDK should correspond to responses from a particular endpoint. This definition may be more appropriately located in CloudPulseWidgetUtils.ts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, thanks

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Replace `LineGraph` with `AreaChart` in `CloudPulseLineGraph` component. Add `connectNulls` property in `AreaChart.ts` ([#11204](https://github.com/linode/manager/pull/11204))
15 changes: 12 additions & 3 deletions packages/manager/src/components/AreaChart/AreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import {
import type { TooltipProps } from 'recharts';
import type { MetricsDisplayRow } from 'src/components/LineGraph/MetricsDisplay';

interface AreaProps {
export type ChartVariant = 'line' | 'area';

export interface AreaProps {
/**
* color for the area
*/
Expand All @@ -53,7 +55,7 @@ interface XAxisProps {
tickGap: number;
}

interface AreaChartProps {
export interface AreaChartProps {
/**
* list of areas to be displayed
*/
Expand All @@ -64,6 +66,11 @@ interface AreaChartProps {
*/
ariaLabel: string;

/**
* connect nulls value between two data points
*/
connectNulls? :boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
connectNulls? :boolean;
connectNulls?: boolean;

Copy link
Contributor Author

@nikhagra-akamai nikhagra-akamai Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, it was there in local changes but forgot to push. Thanks


/**
* data to be displayed on the graph
*/
Expand Down Expand Up @@ -114,7 +121,7 @@ interface AreaChartProps {
* make chart appear as a line or area chart
* @default area
*/
variant?: 'area' | 'line';
variant?: ChartVariant;

/**
* The width of chart container.
Expand Down Expand Up @@ -143,6 +150,7 @@ export const AreaChart = (props: AreaChartProps) => {
variant,
width = '100%',
xAxis,
connectNulls
} = props;

const theme = useTheme();
Expand Down Expand Up @@ -274,6 +282,7 @@ export const AreaChart = (props: AreaChartProps) => {
)}
{areas.map(({ color, dataKey }) => (
<Area
connectNulls={connectNulls}
dataKey={dataKey}
fill={color}
fillOpacity={variant === 'line' ? 0 : fillOpacity ?? 1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export const StyledButton = styled(Button, {
'&:before': {
backgroundColor: hidden
? theme.color.disabledText
: theme.graphs[legendColor],
: theme.graphs[legendColor]
? theme.graphs[legendColor]
: legendColor,
flexShrink: 0,
},
}),
Expand Down
11 changes: 1 addition & 10 deletions packages/manager/src/components/LineGraph/MetricsDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ const ROW_HEADERS = ['Max', 'Avg', 'Last'] as const;
type MetricKey = 'average' | 'last' | 'max';
const METRIC_KEYS: MetricKey[] = ['max', 'average', 'last'];

export type LegendColor =
| 'blue'
| 'darkGreen'
| 'green'
| 'lightGreen'
| 'purple'
| 'red'
| 'yellow';

interface Props {
/**
* Array of rows to hide. Each row should contain the legend title.
Expand All @@ -47,7 +38,7 @@ export interface MetricsDisplayRow {
data: Metrics;
format: (n: number) => string;
handleLegendClick?: () => void;
legendColor: LegendColor;
legendColor: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks worse from a type safety perspective. Is this change necessary?

Copy link
Contributor Author

@nikhagra-akamai nikhagra-akamai Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is already been discussed with @jaalah-akamai that instead of restricting to the 7 predefined colors, it should accept any color, so that legend rows greater than 7 won't collide with same color. Also, I don't think color has anything related to typesafety.

legendTitle: string;
}

Expand Down

This file was deleted.

Loading