Skip to content

Commit

Permalink
Merge branch 'trunk' into social/unified-connections-management
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed Jan 17, 2025
2 parents 1ce1b4c + ca7e9cd commit 13ac87f
Show file tree
Hide file tree
Showing 75 changed files with 1,987 additions and 199 deletions.
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Team assignments: update VideoPress team assignment.


Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export const automatticAssignments = {
board_id: 'https://github.com/orgs/Automattic/projects/908/views/1',
},
VideoPress: {
team: 'Agora',
team: 'Nexus',
labels: [ '[Package] VideoPress', '[Feature] VideoPress', '[Plugin] VideoPress' ],
slack_id: 'C02TQF5VAJD',
board_id: 'https://github.com/orgs/Automattic/projects/460',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add gradient fill for line chart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Added passing through options for X, Y axis
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Charts: add responsive chart stories
1 change: 1 addition & 0 deletions projects/js-packages/charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@react-spring/web": "9.7.3",
"@visx/axis": "^3.12.0",
"@visx/event": "^3.8.0",
"@visx/gradient": "3.12.0",
"@visx/grid": "^3.12.0",
"@visx/group": "^3.12.0",
"@visx/legend": "^3.12.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const meta: Meta< typeof BarChart > = {
overflow: 'auto',
padding: '2rem',
width: '800px',
minWidth: '400px',
maxWidth: '1200px',
border: '1px dashed #ccc',
display: 'inline-block',
} }
>
<Story />
Expand Down Expand Up @@ -61,8 +61,6 @@ export const SingleSeries: Story = {
export const ManyDataSeries: Story = {
args: {
...Default.args,
width: 1200,
height: 700,
data,
},
parameters: {
Expand Down Expand Up @@ -92,3 +90,19 @@ export const WithVerticalLegend = {
legendOrientation: 'vertical',
},
};

export const FixedDimensions: Story = {
args: {
...Default.args,
width: 800,
height: 400,
data: [ data[ 0 ], data[ 1 ], data[ 2 ] ],
},
parameters: {
docs: {
description: {
story: 'Bar chart with fixed dimensions that override the responsive behavior.',
},
},
},
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { LinearGradient } from '@visx/gradient';
import {
XYChart,
AnimatedLineSeries,
AnimatedAreaSeries,
AnimatedAxis,
AnimatedGrid,
Tooltip,
Expand All @@ -14,10 +16,9 @@ import { withResponsive } from '../shared/with-responsive';
import styles from './line-chart.module.scss';
import type { BaseChartProps, DataPointDate, SeriesData } from '../../types';

// TODO: revisit grid and axis options - accept as props for frid lines, axis, values: x, y, all, none

interface LineChartProps extends BaseChartProps< SeriesData[] > {
margin?: { top: number; right: number; bottom: number; left: number };
withGradientFill: boolean;
}

type TooltipData = {
Expand Down Expand Up @@ -83,6 +84,8 @@ const LineChart: FC< LineChartProps > = ( {
withTooltips = true,
showLegend = false,
legendOrientation = 'horizontal',
withGradientFill = false,
options = {},
} ) => {
const providerTheme = useChartTheme();

Expand Down Expand Up @@ -124,19 +127,51 @@ const LineChart: FC< LineChartProps > = ( {
yScale={ { type: 'linear', nice: true } }
>
<AnimatedGrid columns={ false } numTicks={ 4 } />
<AnimatedAxis orientation="bottom" numTicks={ 5 } tickFormat={ formatDateTick } />
<AnimatedAxis orientation="left" numTicks={ 4 } />

{ data.map( ( seriesData, index ) => (
<AnimatedLineSeries
key={ seriesData?.label }
dataKey={ seriesData?.label }
data={ seriesData.data as DataPointDate[] } // TODO: this needs fixing or a more specific type for each chart
{ ...accessors }
stroke={ theme.colors[ index % theme.colors.length ] }
strokeWidth={ 2 }
/>
) ) }
<AnimatedAxis
orientation="bottom"
numTicks={ 5 }
tickFormat={ formatDateTick }
{ ...options?.axis?.x }
/>
<AnimatedAxis orientation="left" numTicks={ 4 } { ...options?.axis?.y } />

{ data.map( ( seriesData, index ) => {
const stroke = seriesData.options?.stroke ?? theme.colors[ index % theme.colors.length ];

return (
<>
<LinearGradient
id={ `area-gradient-${ index + 1 }` }
from={ stroke }
to="white"
toOpacity={ 0.1 }
{ ...seriesData.options?.gradient }
/>
<AnimatedLineSeries
key={ seriesData?.label }
dataKey={ seriesData?.label }
data={ seriesData.data as DataPointDate[] } // TODO: this needs fixing or a more specific type for each chart
{ ...accessors }
stroke={ stroke }
strokeWidth={ 2 }
/>
{ /** Theoretically the area series should work without the line series; however it outlines the area with borders, which isn't ideal. */ }
{ /** TODO: Investigate whehter we could leverage area series alone. */ }
{ withGradientFill && (
<AnimatedAreaSeries
key={ seriesData?.label }
dataKey={ seriesData?.label }
data={ seriesData.data as DataPointDate[] } // TODO: this needs fixing or a more specific type for each chart
{ ...accessors }
stroke={ stroke }
strokeWidth={ 0 }
fill={ `url(#area-gradient-${ index + 1 })` }
renderLine={ false }
/>
) }
</>
);
} ) }

{ withTooltips && (
<Tooltip
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import LineChart from '../line-chart';
import sampleData from './sample-data';
import webTrafficData from './site-traffic-sample';
import type { Meta, StoryFn, StoryObj } from '@storybook/react';

const meta: Meta< typeof LineChart > = {
Expand All @@ -10,7 +11,17 @@ const meta: Meta< typeof LineChart > = {
},
decorators: [
Story => (
<div style={ { padding: '2rem' } }>
<div
style={ {
resize: 'both',
overflow: 'auto',
padding: '2rem',
width: '800px',
maxWidth: '1200px',
border: '1px dashed #ccc',
display: 'inline-block',
} }
>
<Story />
</div>
),
Expand All @@ -27,13 +38,22 @@ Default.args = {
data: sampleData,
showLegend: false,
legendOrientation: 'horizontal',
withGradientFill: false,
options: {
axis: {
x: {
orientation: 'bottom',
},
y: {
orientation: 'left',
},
},
},
};

// Story with single data series
export const SingleSeries: StoryObj< typeof LineChart > = Template.bind( {} );
SingleSeries.args = {
width: 500,
height: 300,
data: [ sampleData[ 0 ] ], // Only London temperature data
};

Expand Down Expand Up @@ -66,3 +86,31 @@ WithVerticalLegend.args = {
showLegend: true,
legendOrientation: 'vertical',
};

// Add after existing stories
export const FixedDimensions: StoryObj< typeof LineChart > = Template.bind( {} );
FixedDimensions.args = {
width: 800,
height: 400,
data: sampleData,
withTooltips: true,
};

FixedDimensions.parameters = {
docs: {
description: {
story: 'Line chart with fixed dimensions that override the responsive behavior.',
},
},
};

// Story with gradient filled line chart
export const GridientFilled: StoryObj< typeof LineChart > = Template.bind( {} );
GridientFilled.args = {
...Default.args,
data: webTrafficData,
withGradientFill: true,
options: {
axis: { x: { numTicks: 10 }, y: { orientation: 'right' } },
},
};
Loading

0 comments on commit 13ac87f

Please sign in to comment.