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

feat: [DI-21463] - Added capability to transform area chart into line chart #11136

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11136-added-1729581444483.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

Add hideFill & fillOpacity property to AreaChart component ([#11136](https://github.com/linode/manager/pull/11136))
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
Add hideFill & fillOpacity property to AreaChart component ([#11136](https://github.com/linode/manager/pull/11136))
Add `hideFill` & `fillOpacity` properties to `AreaChart` component ([#11136](https://github.com/linode/manager/pull/11136))

10 changes: 8 additions & 2 deletions packages/manager/src/components/AreaChart/AreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import {
Legend,
ResponsiveContainer,
Tooltip,
TooltipProps,
XAxis,
YAxis,
} from 'recharts';

import { AccessibleAreaChart } from 'src/components/AreaChart/AccessibleAreaChart';
import { Box } from 'src/components/Box';
import MetricsDisplay from 'src/components/LineGraph/MetricsDisplay';
import { MetricsDisplayRow } from 'src/components/LineGraph/MetricsDisplay';
import { Paper } from 'src/components/Paper';
import { StyledBottomLegend } from 'src/features/NodeBalancers/NodeBalancerDetail/NodeBalancerSummary/TablesPanel';

Expand All @@ -27,6 +25,9 @@ import {
tooltipValueFormatter,
} from './utils';

import type { TooltipProps } from 'recharts';
import type { MetricsDisplayRow } from 'src/components/LineGraph/MetricsDisplay';

interface AreaProps {
color: string;
dataKey: string;
Expand All @@ -41,7 +42,9 @@ interface AreaChartProps {
areas: AreaProps[];
ariaLabel: string;
data: any;
fillOpacity?: number;
Copy link
Member

Choose a reason for hiding this comment

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

Optional: add jsdoc style comments to our props describing what they do

height: number;
hideFill?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

hideFill seems fine to me. We could do something like this to potentially be more extendable / descriptive but it would accomplish the same thing.

Suggested change
hideFill?: boolean;
/**
* Makes the chart appear as a line or area chart
* @default area
*/
variant?: 'area' | 'line';

Copy link
Contributor

Choose a reason for hiding this comment

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

@nikhagra-akamai Yea let's do this, I have a feeling we'll want this.

legendRows?: Omit<MetricsDisplayRow[], 'handleLegendClick'>;
showLegend?: boolean;
timezone: string;
Expand All @@ -54,7 +57,9 @@ export const AreaChart = (props: AreaChartProps) => {
areas,
ariaLabel,
data,
fillOpacity,
height,
hideFill,
legendRows,
showLegend,
timezone,
Expand Down Expand Up @@ -190,6 +195,7 @@ export const AreaChart = (props: AreaChartProps) => {
<Area
dataKey={dataKey}
fill={color}
fillOpacity={hideFill ? 0 : fillOpacity ?? 1}
hide={activeSeries.includes(dataKey)}
isAnimationActive={false}
key={dataKey}
Expand Down