-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement design changes to LineChartRelational
- Loading branch information
Showing
13 changed files
with
146 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
6 changes: 6 additions & 0 deletions
6
.../polaris-viz/src/components/LineChartRelational/components/CustomLegend/CustomLegend.scss
This file contains 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,6 @@ | ||
.Container { | ||
display: flex; | ||
gap: 10px; | ||
flex-wrap: wrap; | ||
list-style: none; | ||
} |
76 changes: 76 additions & 0 deletions
76
...s/polaris-viz/src/components/LineChartRelational/components/CustomLegend/CustomLegend.tsx
This file contains 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,76 @@ | ||
import type {DataSeries} from '@shopify/polaris-viz-core'; | ||
|
||
import type {ColorVisionInteractionMethods} from '../../../../types'; | ||
import {LegendItem} from '../../../../components/Legend'; | ||
|
||
import styles from './CustomLegend.scss'; | ||
|
||
interface Props extends ColorVisionInteractionMethods { | ||
data: DataSeries[]; | ||
theme: string; | ||
} | ||
|
||
export function CustomLegend({ | ||
data, | ||
getColorVisionEventAttrs, | ||
getColorVisionStyles, | ||
theme, | ||
}: Props) { | ||
const lineSeries = data.filter( | ||
(series) => series?.metadata?.relatedIndex == null, | ||
); | ||
|
||
const percentileItems = data.filter( | ||
(series) => series?.metadata?.relatedIndex != null, | ||
); | ||
|
||
const percentileIndex = lineSeries.length + 1; | ||
|
||
return ( | ||
<ul className={styles.Container}> | ||
{lineSeries.map(({color, name, isComparison, metadata}) => { | ||
if (metadata?.isPredictive) { | ||
return null; | ||
} | ||
|
||
const index = data.findIndex((series) => series.name === name); | ||
|
||
return ( | ||
<li | ||
key={index} | ||
style={{ | ||
...getColorVisionStyles(index), | ||
}} | ||
{...getColorVisionEventAttrs(index)} | ||
> | ||
<LegendItem | ||
color={color!} | ||
index={index} | ||
isComparison={isComparison} | ||
name={name!} | ||
shape="Line" | ||
theme={theme} | ||
/> | ||
</li> | ||
); | ||
})} | ||
<li | ||
key={percentileIndex} | ||
style={{ | ||
...getColorVisionStyles(percentileIndex), | ||
}} | ||
{...getColorVisionEventAttrs(percentileIndex)} | ||
> | ||
<LegendItem | ||
color={ | ||
percentileItems[0].color ?? percentileItems[0]?.metadata?.areaColor | ||
} | ||
index={percentileIndex} | ||
name={percentileItems[0]?.metadata?.legendLabel} | ||
shape="Bar" | ||
theme={theme} | ||
/> | ||
</li> | ||
</ul> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/polaris-viz/src/components/LineChartRelational/components/CustomLegend/index.ts
This file contains 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 @@ | ||
export {CustomLegend} from './CustomLegend'; |
This file contains 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
1 change: 1 addition & 0 deletions
1
packages/polaris-viz/src/components/LineChartRelational/components/index.ts
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export {Area} from './Area'; | ||
export {MissingDataArea} from './MissingDataArea'; | ||
export {RelatedAreas} from './RelatedAreas'; | ||
export {CustomLegend} from './CustomLegend'; |
This file contains 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 |
---|---|---|
|
@@ -11,4 +11,6 @@ Default.args = { | |
...DEFAULT_PROPS, | ||
data: DEFAULT_DATA, | ||
isAnimated: false, | ||
showLegend: true, | ||
theme: 'Uplift', | ||
}; |
This file contains 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 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