{
+ if (direction === 'vertical') {
+ return data.slice(0, MAX_VERTICAL_LEGEND_ITEMS);
+ } else {
+ let cutOffIndex = data.length;
+ const containerWidth =
+ width - leftMargin - horizontalMargin - MORE_TEXT_WIDTH;
+
+ cardDimensions.current.reduce((totalWidth, card, index) => {
+ if (totalWidth + card.width + index * LEGEND_GAP > containerWidth) {
+ cutOffIndex = index;
+ } else {
+ return totalWidth + card.width;
+ }
+ }, cutOffIndex);
+
+ return data.slice(0, cutOffIndex);
+ }
+ }, [
+ cardDimensions.current,
+ direction,
+ data,
+ width,
+ leftMargin,
+ horizontalMargin,
+ ]);
+
+ const shouldTruncateLegend =
+ truncatedLegend.length < data.length && data.length > 2;
+
const styleMap: {[key: string]: CSSProperties} = {
horizontal: {
justifyContent: 'flex-end',
@@ -64,6 +103,7 @@ export function LegendContainer({
? `0 ${horizontalMargin}px ${LEGENDS_BOTTOM_MARGIN}px ${leftMargin}px`
: `${LEGENDS_TOP_MARGIN}px ${horizontalMargin}px 0 ${leftMargin}px`,
flexDirection: 'row',
+ flexWrap: shouldTruncateLegend ? 'nowrap' : 'wrap',
},
vertical: {
alignItems: 'flex-start',
@@ -125,12 +165,20 @@ export function LegendContainer({
style={{...styleMap[direction], ...shouldCenterTiles(position)}}
>
{renderLegendContent?.(colorVisionInteractionMethods) ?? (
-
+ <>
+
+ {shouldTruncateLegend && (
+
+ {`+${data.length - truncatedLegend.length} more`}
+
+ )}
+ >
)}
);
diff --git a/packages/polaris-viz/src/components/LineChart/Chart.tsx b/packages/polaris-viz/src/components/LineChart/Chart.tsx
index 2b2e6dd2ff..738593c859 100644
--- a/packages/polaris-viz/src/components/LineChart/Chart.tsx
+++ b/packages/polaris-viz/src/components/LineChart/Chart.tsx
@@ -424,6 +424,7 @@ export function Chart({
data={legend}
onDimensionChange={setLegendDimensions}
renderLegendContent={renderLegendContent}
+ width={width}
/>
)}
diff --git a/packages/polaris-viz/src/components/LineChart/stories/data.tsx b/packages/polaris-viz/src/components/LineChart/stories/data.tsx
index 1dec5b1970..04631ce947 100644
--- a/packages/polaris-viz/src/components/LineChart/stories/data.tsx
+++ b/packages/polaris-viz/src/components/LineChart/stories/data.tsx
@@ -51,7 +51,7 @@ export const DEFAULT_PROPS: Partial = {
export const DEFAULT_DATA = [
{
- name: 'Apr 1 – Apr 14, 2020',
+ name: '1 a very very very very very very very long name',
data: [
{value: 333, key: '2020-04-01T12:00:00'},
{value: 797, key: '2020-04-02T12:00:00'},
@@ -70,7 +70,207 @@ export const DEFAULT_DATA = [
],
},
{
- name: 'Previous month',
+ name: '2 a very very very very very very very long name',
+ data: [
+ {value: 709, key: '2020-03-02T12:00:00'},
+ {value: 238, key: '2020-03-01T12:00:00'},
+ {value: 190, key: '2020-03-03T12:00:00'},
+ {value: 90, key: '2020-03-04T12:00:00'},
+ {value: 237, key: '2020-03-05T12:00:00'},
+ {value: 580, key: '2020-03-07T12:00:00'},
+ {value: 172, key: '2020-03-06T12:00:00'},
+ {value: 12, key: '2020-03-08T12:00:00'},
+ {value: 390, key: '2020-03-09T12:00:00'},
+ {value: 43, key: '2020-03-10T12:00:00'},
+ {value: 710, key: '2020-03-11T12:00:00'},
+ {value: 791, key: '2020-03-12T12:00:00'},
+ {value: 623, key: '2020-03-13T12:00:00'},
+ {value: 21, key: '2020-03-14T12:00:00'},
+ ],
+ color: 'red',
+ isComparison: true,
+ },
+ {
+ name: '3',
+ data: [
+ {value: 333, key: '2020-04-01T12:00:00'},
+ {value: 797, key: '2020-04-02T12:00:00'},
+ {value: 234, key: '2020-04-03T12:00:00'},
+ {value: 534, key: '2020-04-04T12:00:00'},
+ {value: 132, key: '2020-04-05T12:00:00'},
+ {value: 159, key: '2020-04-06T12:00:00'},
+ {value: 239, key: '2020-04-07T12:00:00'},
+ {value: 708, key: '2020-04-08T12:00:00'},
+ {value: 234, key: '2020-04-09T12:00:00'},
+ {value: 645, key: '2020-04-10T12:00:00'},
+ {value: 543, key: '2020-04-11T12:00:00'},
+ {value: 89, key: '2020-04-12T12:00:00'},
+ {value: 849, key: '2020-04-13T12:00:00'},
+ {value: 129, key: '2020-04-14T12:00:00'},
+ ],
+ },
+ {
+ name: '4',
+ data: [
+ {value: 709, key: '2020-03-02T12:00:00'},
+ {value: 238, key: '2020-03-01T12:00:00'},
+ {value: 190, key: '2020-03-03T12:00:00'},
+ {value: 90, key: '2020-03-04T12:00:00'},
+ {value: 237, key: '2020-03-05T12:00:00'},
+ {value: 580, key: '2020-03-07T12:00:00'},
+ {value: 172, key: '2020-03-06T12:00:00'},
+ {value: 12, key: '2020-03-08T12:00:00'},
+ {value: 390, key: '2020-03-09T12:00:00'},
+ {value: 43, key: '2020-03-10T12:00:00'},
+ {value: 710, key: '2020-03-11T12:00:00'},
+ {value: 791, key: '2020-03-12T12:00:00'},
+ {value: 623, key: '2020-03-13T12:00:00'},
+ {value: 21, key: '2020-03-14T12:00:00'},
+ ],
+ color: 'red',
+ isComparison: true,
+ },
+ {
+ name: '5',
+ data: [
+ {value: 333, key: '2020-04-01T12:00:00'},
+ {value: 797, key: '2020-04-02T12:00:00'},
+ {value: 234, key: '2020-04-03T12:00:00'},
+ {value: 534, key: '2020-04-04T12:00:00'},
+ {value: 132, key: '2020-04-05T12:00:00'},
+ {value: 159, key: '2020-04-06T12:00:00'},
+ {value: 239, key: '2020-04-07T12:00:00'},
+ {value: 708, key: '2020-04-08T12:00:00'},
+ {value: 234, key: '2020-04-09T12:00:00'},
+ {value: 645, key: '2020-04-10T12:00:00'},
+ {value: 543, key: '2020-04-11T12:00:00'},
+ {value: 89, key: '2020-04-12T12:00:00'},
+ {value: 849, key: '2020-04-13T12:00:00'},
+ {value: 129, key: '2020-04-14T12:00:00'},
+ ],
+ },
+ {
+ name: '6',
+ data: [
+ {value: 709, key: '2020-03-02T12:00:00'},
+ {value: 238, key: '2020-03-01T12:00:00'},
+ {value: 190, key: '2020-03-03T12:00:00'},
+ {value: 90, key: '2020-03-04T12:00:00'},
+ {value: 237, key: '2020-03-05T12:00:00'},
+ {value: 580, key: '2020-03-07T12:00:00'},
+ {value: 172, key: '2020-03-06T12:00:00'},
+ {value: 12, key: '2020-03-08T12:00:00'},
+ {value: 390, key: '2020-03-09T12:00:00'},
+ {value: 43, key: '2020-03-10T12:00:00'},
+ {value: 710, key: '2020-03-11T12:00:00'},
+ {value: 791, key: '2020-03-12T12:00:00'},
+ {value: 623, key: '2020-03-13T12:00:00'},
+ {value: 21, key: '2020-03-14T12:00:00'},
+ ],
+ color: 'red',
+ isComparison: true,
+ },
+ {
+ name: '7',
+ data: [
+ {value: 333, key: '2020-04-01T12:00:00'},
+ {value: 797, key: '2020-04-02T12:00:00'},
+ {value: 234, key: '2020-04-03T12:00:00'},
+ {value: 534, key: '2020-04-04T12:00:00'},
+ {value: 132, key: '2020-04-05T12:00:00'},
+ {value: 159, key: '2020-04-06T12:00:00'},
+ {value: 239, key: '2020-04-07T12:00:00'},
+ {value: 708, key: '2020-04-08T12:00:00'},
+ {value: 234, key: '2020-04-09T12:00:00'},
+ {value: 645, key: '2020-04-10T12:00:00'},
+ {value: 543, key: '2020-04-11T12:00:00'},
+ {value: 89, key: '2020-04-12T12:00:00'},
+ {value: 849, key: '2020-04-13T12:00:00'},
+ {value: 129, key: '2020-04-14T12:00:00'},
+ ],
+ },
+ {
+ name: '8',
+ data: [
+ {value: 709, key: '2020-03-02T12:00:00'},
+ {value: 238, key: '2020-03-01T12:00:00'},
+ {value: 190, key: '2020-03-03T12:00:00'},
+ {value: 90, key: '2020-03-04T12:00:00'},
+ {value: 237, key: '2020-03-05T12:00:00'},
+ {value: 580, key: '2020-03-07T12:00:00'},
+ {value: 172, key: '2020-03-06T12:00:00'},
+ {value: 12, key: '2020-03-08T12:00:00'},
+ {value: 390, key: '2020-03-09T12:00:00'},
+ {value: 43, key: '2020-03-10T12:00:00'},
+ {value: 710, key: '2020-03-11T12:00:00'},
+ {value: 791, key: '2020-03-12T12:00:00'},
+ {value: 623, key: '2020-03-13T12:00:00'},
+ {value: 21, key: '2020-03-14T12:00:00'},
+ ],
+ color: 'red',
+ isComparison: true,
+ },
+ {
+ name: '9',
+ data: [
+ {value: 333, key: '2020-04-01T12:00:00'},
+ {value: 797, key: '2020-04-02T12:00:00'},
+ {value: 234, key: '2020-04-03T12:00:00'},
+ {value: 534, key: '2020-04-04T12:00:00'},
+ {value: 132, key: '2020-04-05T12:00:00'},
+ {value: 159, key: '2020-04-06T12:00:00'},
+ {value: 239, key: '2020-04-07T12:00:00'},
+ {value: 708, key: '2020-04-08T12:00:00'},
+ {value: 234, key: '2020-04-09T12:00:00'},
+ {value: 645, key: '2020-04-10T12:00:00'},
+ {value: 543, key: '2020-04-11T12:00:00'},
+ {value: 89, key: '2020-04-12T12:00:00'},
+ {value: 849, key: '2020-04-13T12:00:00'},
+ {value: 129, key: '2020-04-14T12:00:00'},
+ ],
+ },
+ {
+ name: '10',
+ data: [
+ {value: 709, key: '2020-03-02T12:00:00'},
+ {value: 238, key: '2020-03-01T12:00:00'},
+ {value: 190, key: '2020-03-03T12:00:00'},
+ {value: 90, key: '2020-03-04T12:00:00'},
+ {value: 237, key: '2020-03-05T12:00:00'},
+ {value: 580, key: '2020-03-07T12:00:00'},
+ {value: 172, key: '2020-03-06T12:00:00'},
+ {value: 12, key: '2020-03-08T12:00:00'},
+ {value: 390, key: '2020-03-09T12:00:00'},
+ {value: 43, key: '2020-03-10T12:00:00'},
+ {value: 710, key: '2020-03-11T12:00:00'},
+ {value: 791, key: '2020-03-12T12:00:00'},
+ {value: 623, key: '2020-03-13T12:00:00'},
+ {value: 21, key: '2020-03-14T12:00:00'},
+ ],
+ color: 'red',
+ isComparison: true,
+ },
+ {
+ name: '11',
+ data: [
+ {value: 333, key: '2020-04-01T12:00:00'},
+ {value: 797, key: '2020-04-02T12:00:00'},
+ {value: 234, key: '2020-04-03T12:00:00'},
+ {value: 534, key: '2020-04-04T12:00:00'},
+ {value: 132, key: '2020-04-05T12:00:00'},
+ {value: 159, key: '2020-04-06T12:00:00'},
+ {value: 239, key: '2020-04-07T12:00:00'},
+ {value: 708, key: '2020-04-08T12:00:00'},
+ {value: 234, key: '2020-04-09T12:00:00'},
+ {value: 645, key: '2020-04-10T12:00:00'},
+ {value: 543, key: '2020-04-11T12:00:00'},
+ {value: 89, key: '2020-04-12T12:00:00'},
+ {value: 849, key: '2020-04-13T12:00:00'},
+ {value: 129, key: '2020-04-14T12:00:00'},
+ ],
+ },
+ {
+ name: '12',
data: [
{value: 709, key: '2020-03-02T12:00:00'},
{value: 238, key: '2020-03-01T12:00:00'},
diff --git a/packages/polaris-viz/src/components/LineChartPredictive/components/CustomLegend/CustomLegend.tsx b/packages/polaris-viz/src/components/LineChartPredictive/components/CustomLegend/CustomLegend.tsx
index b962237da6..cca25dfbb1 100644
--- a/packages/polaris-viz/src/components/LineChartPredictive/components/CustomLegend/CustomLegend.tsx
+++ b/packages/polaris-viz/src/components/LineChartPredictive/components/CustomLegend/CustomLegend.tsx
@@ -49,6 +49,7 @@ export function CustomLegend({
name={name!}
shape="Line"
theme={theme}
+ onDimensionChange={() => {}}
/>
);
diff --git a/packages/polaris-viz/src/components/LineChartPredictive/stories/data.tsx b/packages/polaris-viz/src/components/LineChartPredictive/stories/data.tsx
index 6e73af18e4..94d20af75e 100644
--- a/packages/polaris-viz/src/components/LineChartPredictive/stories/data.tsx
+++ b/packages/polaris-viz/src/components/LineChartPredictive/stories/data.tsx
@@ -144,4 +144,496 @@ export const DEFAULT_DATA: LineChartPredictiveDataSeries[] = [
},
},
},
+ {
+ name: 'One',
+ data: [
+ {value: 88, key: '2020-03-01T12:00:00'},
+ {value: 559, key: '2020-03-02T12:00:00'},
+ {value: 40, key: '2020-03-03T12:00:00'},
+ {value: 0, key: '2020-03-04T12:00:00'},
+ {value: 87, key: '2020-03-05T12:00:00'},
+ {value: 22, key: '2020-03-06T12:00:00'},
+ {value: null, key: '2020-03-07T12:00:00'},
+ {value: null, key: '2020-03-08T12:00:00'},
+ {value: null, key: '2020-03-09T12:00:00'},
+ {value: null, key: '2020-03-10T12:00:00'},
+ {value: null, key: '2020-03-11T12:00:00'},
+ {value: null, key: '2020-03-12T12:00:00'},
+ ],
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Predictive',
+ data: [
+ {value: null, key: '2020-03-01T12:00:00'},
+ {value: null, key: '2020-03-02T12:00:00'},
+ {value: null, key: '2020-03-03T12:00:00'},
+ {value: null, key: '2020-03-04T12:00:00'},
+ {value: null, key: '2020-03-05T12:00:00'},
+ {value: 22, key: '2020-03-06T12:00:00'},
+ {value: 430, key: '2020-03-07T12:00:00'},
+ {value: 0, key: '2020-03-08T12:00:00'},
+ {value: 240, key: '2020-03-09T12:00:00'},
+ {value: 0, key: '2020-03-10T12:00:00'},
+ {value: 540, key: '2020-03-11T12:00:00'},
+ {value: 641, key: '2020-03-12T12:00:00'},
+ ],
+ metadata: {
+ relatedIndex: 0,
+ isPredictive: true,
+ startKey: '2020-03-06T12:00:00',
+ },
+ styleOverride: {
+ line: {
+ strokeDasharray: '1 10 1',
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Two',
+ data: [
+ {value: 23, key: '2020-03-01T12:00:00'},
+ {value: 12, key: '2020-03-02T12:00:00'},
+ {value: 234, key: '2020-03-03T12:00:00'},
+ {value: 29, key: '2020-03-04T12:00:00'},
+ {value: null, key: '2020-03-05T12:00:00'},
+ {value: null, key: '2020-03-06T12:00:00'},
+ {value: null, key: '2020-03-07T12:00:00'},
+ {value: null, key: '2020-03-08T12:00:00'},
+ {value: null, key: '2020-03-09T12:00:00'},
+ {value: null, key: '2020-03-10T12:00:00'},
+ {value: null, key: '2020-03-11T12:00:00'},
+ {value: null, key: '2020-03-12T12:00:00'},
+ ],
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Two Predictive',
+ data: [
+ {value: null, key: '2020-03-01T12:00:00'},
+ {value: null, key: '2020-03-02T12:00:00'},
+ {value: null, key: '2020-03-03T12:00:00'},
+ {value: 29, key: '2020-03-04T12:00:00'},
+ {value: 23, key: '2020-03-05T12:00:00'},
+ {value: 57, key: '2020-03-06T12:00:00'},
+ {value: 43, key: '2020-03-07T12:00:00'},
+ {value: 12, key: '2020-03-08T12:00:00'},
+ {value: 23, key: '2020-03-09T12:00:00'},
+ {value: 152, key: '2020-03-10T12:00:00'},
+ {value: 300, key: '2020-03-11T12:00:00'},
+ {value: 500, key: '2020-03-12T12:00:00'},
+ ],
+ metadata: {
+ relatedIndex: 2,
+ isPredictive: true,
+ startKey: '2020-03-04T12:00:00',
+ },
+ styleOverride: {
+ line: {
+ strokeDasharray: '1 10 1',
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Comparison',
+ data: [
+ {value: 458, key: '2020-03-01T12:00:00'},
+ {value: 311, key: '2020-03-02T12:00:00'},
+ {value: 245, key: '2020-03-03T12:00:00'},
+ {value: 74, key: '2020-03-04T12:00:00'},
+ {value: 228, key: '2020-03-05T12:00:00'},
+ {value: 497, key: '2020-03-06T12:00:00'},
+ {value: 46, key: '2020-03-07T12:00:00'},
+ {value: 165, key: '2020-03-08T12:00:00'},
+ {value: 200, key: '2020-03-09T12:00:00'},
+ {value: 483, key: '2020-03-10T12:00:00'},
+ {value: 255, key: '2020-03-11T12:00:00'},
+ {value: 395, key: '2020-03-12T12:00:00'},
+ ],
+ isComparison: true,
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'One',
+ data: [
+ {value: 88, key: '2020-03-01T12:00:00'},
+ {value: 559, key: '2020-03-02T12:00:00'},
+ {value: 40, key: '2020-03-03T12:00:00'},
+ {value: 0, key: '2020-03-04T12:00:00'},
+ {value: 87, key: '2020-03-05T12:00:00'},
+ {value: 22, key: '2020-03-06T12:00:00'},
+ {value: null, key: '2020-03-07T12:00:00'},
+ {value: null, key: '2020-03-08T12:00:00'},
+ {value: null, key: '2020-03-09T12:00:00'},
+ {value: null, key: '2020-03-10T12:00:00'},
+ {value: null, key: '2020-03-11T12:00:00'},
+ {value: null, key: '2020-03-12T12:00:00'},
+ ],
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Predictive',
+ data: [
+ {value: null, key: '2020-03-01T12:00:00'},
+ {value: null, key: '2020-03-02T12:00:00'},
+ {value: null, key: '2020-03-03T12:00:00'},
+ {value: null, key: '2020-03-04T12:00:00'},
+ {value: null, key: '2020-03-05T12:00:00'},
+ {value: 22, key: '2020-03-06T12:00:00'},
+ {value: 430, key: '2020-03-07T12:00:00'},
+ {value: 0, key: '2020-03-08T12:00:00'},
+ {value: 240, key: '2020-03-09T12:00:00'},
+ {value: 0, key: '2020-03-10T12:00:00'},
+ {value: 540, key: '2020-03-11T12:00:00'},
+ {value: 641, key: '2020-03-12T12:00:00'},
+ ],
+ metadata: {
+ relatedIndex: 0,
+ isPredictive: true,
+ startKey: '2020-03-06T12:00:00',
+ },
+ styleOverride: {
+ line: {
+ strokeDasharray: '1 10 1',
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Two',
+ data: [
+ {value: 23, key: '2020-03-01T12:00:00'},
+ {value: 12, key: '2020-03-02T12:00:00'},
+ {value: 234, key: '2020-03-03T12:00:00'},
+ {value: 29, key: '2020-03-04T12:00:00'},
+ {value: null, key: '2020-03-05T12:00:00'},
+ {value: null, key: '2020-03-06T12:00:00'},
+ {value: null, key: '2020-03-07T12:00:00'},
+ {value: null, key: '2020-03-08T12:00:00'},
+ {value: null, key: '2020-03-09T12:00:00'},
+ {value: null, key: '2020-03-10T12:00:00'},
+ {value: null, key: '2020-03-11T12:00:00'},
+ {value: null, key: '2020-03-12T12:00:00'},
+ ],
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Two Predictive',
+ data: [
+ {value: null, key: '2020-03-01T12:00:00'},
+ {value: null, key: '2020-03-02T12:00:00'},
+ {value: null, key: '2020-03-03T12:00:00'},
+ {value: 29, key: '2020-03-04T12:00:00'},
+ {value: 23, key: '2020-03-05T12:00:00'},
+ {value: 57, key: '2020-03-06T12:00:00'},
+ {value: 43, key: '2020-03-07T12:00:00'},
+ {value: 12, key: '2020-03-08T12:00:00'},
+ {value: 23, key: '2020-03-09T12:00:00'},
+ {value: 152, key: '2020-03-10T12:00:00'},
+ {value: 300, key: '2020-03-11T12:00:00'},
+ {value: 500, key: '2020-03-12T12:00:00'},
+ ],
+ metadata: {
+ relatedIndex: 2,
+ isPredictive: true,
+ startKey: '2020-03-04T12:00:00',
+ },
+ styleOverride: {
+ line: {
+ strokeDasharray: '1 10 1',
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Comparison',
+ data: [
+ {value: 458, key: '2020-03-01T12:00:00'},
+ {value: 311, key: '2020-03-02T12:00:00'},
+ {value: 245, key: '2020-03-03T12:00:00'},
+ {value: 74, key: '2020-03-04T12:00:00'},
+ {value: 228, key: '2020-03-05T12:00:00'},
+ {value: 497, key: '2020-03-06T12:00:00'},
+ {value: 46, key: '2020-03-07T12:00:00'},
+ {value: 165, key: '2020-03-08T12:00:00'},
+ {value: 200, key: '2020-03-09T12:00:00'},
+ {value: 483, key: '2020-03-10T12:00:00'},
+ {value: 255, key: '2020-03-11T12:00:00'},
+ {value: 395, key: '2020-03-12T12:00:00'},
+ ],
+ isComparison: true,
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'One',
+ data: [
+ {value: 88, key: '2020-03-01T12:00:00'},
+ {value: 559, key: '2020-03-02T12:00:00'},
+ {value: 40, key: '2020-03-03T12:00:00'},
+ {value: 0, key: '2020-03-04T12:00:00'},
+ {value: 87, key: '2020-03-05T12:00:00'},
+ {value: 22, key: '2020-03-06T12:00:00'},
+ {value: null, key: '2020-03-07T12:00:00'},
+ {value: null, key: '2020-03-08T12:00:00'},
+ {value: null, key: '2020-03-09T12:00:00'},
+ {value: null, key: '2020-03-10T12:00:00'},
+ {value: null, key: '2020-03-11T12:00:00'},
+ {value: null, key: '2020-03-12T12:00:00'},
+ ],
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Predictive',
+ data: [
+ {value: null, key: '2020-03-01T12:00:00'},
+ {value: null, key: '2020-03-02T12:00:00'},
+ {value: null, key: '2020-03-03T12:00:00'},
+ {value: null, key: '2020-03-04T12:00:00'},
+ {value: null, key: '2020-03-05T12:00:00'},
+ {value: 22, key: '2020-03-06T12:00:00'},
+ {value: 430, key: '2020-03-07T12:00:00'},
+ {value: 0, key: '2020-03-08T12:00:00'},
+ {value: 240, key: '2020-03-09T12:00:00'},
+ {value: 0, key: '2020-03-10T12:00:00'},
+ {value: 540, key: '2020-03-11T12:00:00'},
+ {value: 641, key: '2020-03-12T12:00:00'},
+ ],
+ metadata: {
+ relatedIndex: 0,
+ isPredictive: true,
+ startKey: '2020-03-06T12:00:00',
+ },
+ styleOverride: {
+ line: {
+ strokeDasharray: '1 10 1',
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Two',
+ data: [
+ {value: 23, key: '2020-03-01T12:00:00'},
+ {value: 12, key: '2020-03-02T12:00:00'},
+ {value: 234, key: '2020-03-03T12:00:00'},
+ {value: 29, key: '2020-03-04T12:00:00'},
+ {value: null, key: '2020-03-05T12:00:00'},
+ {value: null, key: '2020-03-06T12:00:00'},
+ {value: null, key: '2020-03-07T12:00:00'},
+ {value: null, key: '2020-03-08T12:00:00'},
+ {value: null, key: '2020-03-09T12:00:00'},
+ {value: null, key: '2020-03-10T12:00:00'},
+ {value: null, key: '2020-03-11T12:00:00'},
+ {value: null, key: '2020-03-12T12:00:00'},
+ ],
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Two Predictive',
+ data: [
+ {value: null, key: '2020-03-01T12:00:00'},
+ {value: null, key: '2020-03-02T12:00:00'},
+ {value: null, key: '2020-03-03T12:00:00'},
+ {value: 29, key: '2020-03-04T12:00:00'},
+ {value: 23, key: '2020-03-05T12:00:00'},
+ {value: 57, key: '2020-03-06T12:00:00'},
+ {value: 43, key: '2020-03-07T12:00:00'},
+ {value: 12, key: '2020-03-08T12:00:00'},
+ {value: 23, key: '2020-03-09T12:00:00'},
+ {value: 152, key: '2020-03-10T12:00:00'},
+ {value: 300, key: '2020-03-11T12:00:00'},
+ {value: 500, key: '2020-03-12T12:00:00'},
+ ],
+ metadata: {
+ relatedIndex: 2,
+ isPredictive: true,
+ startKey: '2020-03-04T12:00:00',
+ },
+ styleOverride: {
+ line: {
+ strokeDasharray: '1 10 1',
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Comparison',
+ data: [
+ {value: 458, key: '2020-03-01T12:00:00'},
+ {value: 311, key: '2020-03-02T12:00:00'},
+ {value: 245, key: '2020-03-03T12:00:00'},
+ {value: 74, key: '2020-03-04T12:00:00'},
+ {value: 228, key: '2020-03-05T12:00:00'},
+ {value: 497, key: '2020-03-06T12:00:00'},
+ {value: 46, key: '2020-03-07T12:00:00'},
+ {value: 165, key: '2020-03-08T12:00:00'},
+ {value: 200, key: '2020-03-09T12:00:00'},
+ {value: 483, key: '2020-03-10T12:00:00'},
+ {value: 255, key: '2020-03-11T12:00:00'},
+ {value: 395, key: '2020-03-12T12:00:00'},
+ ],
+ isComparison: true,
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'One',
+ data: [
+ {value: 88, key: '2020-03-01T12:00:00'},
+ {value: 559, key: '2020-03-02T12:00:00'},
+ {value: 40, key: '2020-03-03T12:00:00'},
+ {value: 0, key: '2020-03-04T12:00:00'},
+ {value: 87, key: '2020-03-05T12:00:00'},
+ {value: 22, key: '2020-03-06T12:00:00'},
+ {value: null, key: '2020-03-07T12:00:00'},
+ {value: null, key: '2020-03-08T12:00:00'},
+ {value: null, key: '2020-03-09T12:00:00'},
+ {value: null, key: '2020-03-10T12:00:00'},
+ {value: null, key: '2020-03-11T12:00:00'},
+ {value: null, key: '2020-03-12T12:00:00'},
+ ],
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Predictive',
+ data: [
+ {value: null, key: '2020-03-01T12:00:00'},
+ {value: null, key: '2020-03-02T12:00:00'},
+ {value: null, key: '2020-03-03T12:00:00'},
+ {value: null, key: '2020-03-04T12:00:00'},
+ {value: null, key: '2020-03-05T12:00:00'},
+ {value: 22, key: '2020-03-06T12:00:00'},
+ {value: 430, key: '2020-03-07T12:00:00'},
+ {value: 0, key: '2020-03-08T12:00:00'},
+ {value: 240, key: '2020-03-09T12:00:00'},
+ {value: 0, key: '2020-03-10T12:00:00'},
+ {value: 540, key: '2020-03-11T12:00:00'},
+ {value: 641, key: '2020-03-12T12:00:00'},
+ ],
+ metadata: {
+ relatedIndex: 0,
+ isPredictive: true,
+ startKey: '2020-03-06T12:00:00',
+ },
+ styleOverride: {
+ line: {
+ strokeDasharray: '1 10 1',
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Two',
+ data: [
+ {value: 23, key: '2020-03-01T12:00:00'},
+ {value: 12, key: '2020-03-02T12:00:00'},
+ {value: 234, key: '2020-03-03T12:00:00'},
+ {value: 29, key: '2020-03-04T12:00:00'},
+ {value: null, key: '2020-03-05T12:00:00'},
+ {value: null, key: '2020-03-06T12:00:00'},
+ {value: null, key: '2020-03-07T12:00:00'},
+ {value: null, key: '2020-03-08T12:00:00'},
+ {value: null, key: '2020-03-09T12:00:00'},
+ {value: null, key: '2020-03-10T12:00:00'},
+ {value: null, key: '2020-03-11T12:00:00'},
+ {value: null, key: '2020-03-12T12:00:00'},
+ ],
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Two Predictive',
+ data: [
+ {value: null, key: '2020-03-01T12:00:00'},
+ {value: null, key: '2020-03-02T12:00:00'},
+ {value: null, key: '2020-03-03T12:00:00'},
+ {value: 29, key: '2020-03-04T12:00:00'},
+ {value: 23, key: '2020-03-05T12:00:00'},
+ {value: 57, key: '2020-03-06T12:00:00'},
+ {value: 43, key: '2020-03-07T12:00:00'},
+ {value: 12, key: '2020-03-08T12:00:00'},
+ {value: 23, key: '2020-03-09T12:00:00'},
+ {value: 152, key: '2020-03-10T12:00:00'},
+ {value: 300, key: '2020-03-11T12:00:00'},
+ {value: 500, key: '2020-03-12T12:00:00'},
+ ],
+ metadata: {
+ relatedIndex: 2,
+ isPredictive: true,
+ startKey: '2020-03-04T12:00:00',
+ },
+ styleOverride: {
+ line: {
+ strokeDasharray: '1 10 1',
+ hasArea: false,
+ },
+ },
+ },
+ {
+ name: 'Comparison',
+ data: [
+ {value: 458, key: '2020-03-01T12:00:00'},
+ {value: 311, key: '2020-03-02T12:00:00'},
+ {value: 245, key: '2020-03-03T12:00:00'},
+ {value: 74, key: '2020-03-04T12:00:00'},
+ {value: 228, key: '2020-03-05T12:00:00'},
+ {value: 497, key: '2020-03-06T12:00:00'},
+ {value: 46, key: '2020-03-07T12:00:00'},
+ {value: 165, key: '2020-03-08T12:00:00'},
+ {value: 200, key: '2020-03-09T12:00:00'},
+ {value: 483, key: '2020-03-10T12:00:00'},
+ {value: 255, key: '2020-03-11T12:00:00'},
+ {value: 395, key: '2020-03-12T12:00:00'},
+ ],
+ isComparison: true,
+ styleOverride: {
+ line: {
+ hasArea: false,
+ },
+ },
+ },
];
diff --git a/packages/polaris-viz/src/components/SimpleBarChart/Chart.tsx b/packages/polaris-viz/src/components/SimpleBarChart/Chart.tsx
index a1442a509c..e8f3da9e12 100644
--- a/packages/polaris-viz/src/components/SimpleBarChart/Chart.tsx
+++ b/packages/polaris-viz/src/components/SimpleBarChart/Chart.tsx
@@ -190,6 +190,7 @@ export function Chart({
onDimensionChange={setLegendDimensions}
renderLegendContent={renderLegendContent}
position={legendPosition}
+ width={width}
/>
)}
diff --git a/packages/polaris-viz/src/components/StackedAreaChart/Chart.tsx b/packages/polaris-viz/src/components/StackedAreaChart/Chart.tsx
index d40e801dd5..980615d587 100644
--- a/packages/polaris-viz/src/components/StackedAreaChart/Chart.tsx
+++ b/packages/polaris-viz/src/components/StackedAreaChart/Chart.tsx
@@ -397,6 +397,7 @@ export function Chart({
data={legend}
onDimensionChange={setLegendDimensions}
renderLegendContent={renderLegendContent}
+ width={width}
/>
)}
diff --git a/packages/polaris-viz/src/components/VerticalBarChart/Chart.tsx b/packages/polaris-viz/src/components/VerticalBarChart/Chart.tsx
index fdf249250c..9d522908b5 100644
--- a/packages/polaris-viz/src/components/VerticalBarChart/Chart.tsx
+++ b/packages/polaris-viz/src/components/VerticalBarChart/Chart.tsx
@@ -328,6 +328,7 @@ export function Chart({
data={legend}
onDimensionChange={setLegendDimensions}
renderLegendContent={renderLegendContent}
+ width={width}
/>
)}