Skip to content

Commit

Permalink
Merge pull request #1833 from carbon-design-system/fix-cardeditor-sho…
Browse files Browse the repository at this point in the history
…wlegend

fix(cardEditor): the showLegend was in the incorrect place for TimeSeriesCards
  • Loading branch information
kodiakhq[bot] authored Nov 30, 2020
2 parents 1a86b6c + fadb0ba commit eb2944d
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ const propTypes = {
includeZeroOnXaxis: PropTypes.bool,
includeZeroOnYaxis: PropTypes.bool,
timeDataSourceId: PropTypes.string,
showLegend: PropTypes.bool,
}),
PropTypes.shape({
id: PropTypes.string,
src: PropTypes.string,
zoomMax: PropTypes.number,
}),
]),
showLegend: PropTypes.bool,
}),
/** Callback function when form data changes */
onChange: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ const propTypes = {
includeZeroOnXaxis: PropTypes.bool,
includeZeroOnYaxis: PropTypes.bool,
timeDataSourceId: PropTypes.string,
showLegend: PropTypes.bool,
}),
interval: PropTypes.string,
showLegend: PropTypes.bool,
}),
/* callback when image input value changes (File object) */
onChange: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const propTypes = {
includeZeroOnXaxis: PropTypes.bool,
includeZeroOnYaxis: PropTypes.bool,
timeDataSourceId: PropTypes.string,
showLegend: PropTypes.bool,
}),
interval: PropTypes.string,
showLegend: PropTypes.bool,
}),
/** Callback function when form data changes */
onChange: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const propTypes = {
zoomMax: PropTypes.number,
}),
interval: PropTypes.string,
showLegend: PropTypes.bool,
}),
/* callback when image input value changes (File object) */
// onChange: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const propTypes = {
background: PropTypes.string,
}),
interval: PropTypes.string,
showLegend: PropTypes.bool,
}),
/** Callback function when form data changes */
onChange: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const propTypes = {
includeZeroOnXaxis: PropTypes.bool,
includeZeroOnYaxis: PropTypes.bool,
timeDataSourceId: PropTypes.string,
showLegend: PropTypes.bool,
}),
interval: PropTypes.string,
showLegend: PropTypes.bool,
}),
/** Callback function when form data changes */
onChange: PropTypes.func.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion src/components/CardEditor/CardEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const propTypes = {
includeZeroOnXaxis: PropTypes.bool,
includeZeroOnYaxis: PropTypes.bool,
timeDataSourceId: PropTypes.string,
showLegend: PropTypes.bool,
}),
interval: PropTypes.string,
showLegend: PropTypes.bool,
}),
/** Callback function when user clicks Show Gallery */
onShowGallery: PropTypes.func.isRequired,
Expand Down
3 changes: 1 addition & 2 deletions src/components/DashboardEditor/editorUtils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export const getDefaultCard = (type, i18n) => {
includeZeroOnXaxis: true,
includeZeroOnYaxis: true,
timeDataSourceId: 'timestamp',
showLegend: true,
},
interval: 'day',
showLegend: true,
};
case DASHBOARD_EDITOR_CARD_TYPES.SIMPLE_BAR:
return {
Expand Down Expand Up @@ -280,7 +280,6 @@ const renderTimeSeriesCard = (cardConfig, commonProps) => (
<TimeSeriesCard
isEditable
values={[]}
showLegend
timeRange={cardConfig?.dataSource?.range}
{...cardConfig}
{...commonProps}
Expand Down
13 changes: 7 additions & 6 deletions src/components/TimeSeriesCard/TimeSeriesCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ const TimeSeriesCardPropTypes = {
zoomBar: ZoomBarPropTypes,
/** Number of grid-line spaces to the left and right of the chart to add white space to. Defaults to 1 */
addSpaceOnEdges: PropTypes.number,
/** whether or not to show a legend at the bottom of the card
* if not explicitly stated, the card will show based on the length of the series
*/
showLegend: PropTypes.bool,
}).isRequired,
i18n: PropTypes.shape({
alertDetected: PropTypes.string,
Expand Down Expand Up @@ -127,10 +131,6 @@ const TimeSeriesCardPropTypes = {
showTimeInGMT: PropTypes.bool,
/** tooltip format pattern that follows the moment formatting patterns */
tooltipDateFormatPattern: PropTypes.string,
/** whether or not to show a legend at the bottom of the card
* if not explicitly stated, the card will show based on the length of the series
*/
showLegend: PropTypes.bool,
};

/**
Expand Down Expand Up @@ -291,7 +291,7 @@ const TimeSeriesCard = ({
isLazyLoading,
isLoading,
domainRange,
showLegend,

...others
}) => {
const {
Expand All @@ -308,6 +308,7 @@ const TimeSeriesCard = ({
chartType,
zoomBar,
showTimeInGMT,
showLegend,
tooltipDateFormatPattern,
addSpaceOnEdges,
},
Expand Down Expand Up @@ -658,11 +659,11 @@ TimeSeriesCard.defaultProps = {
content: {
includeZeroOnXaxis: false,
includeZeroOnYaxis: false,
showLegend: true,
},
showTimeInGMT: false,
domainRange: null,
tooltipDateFormatPattern: 'L HH:mm:ss',
showLegend: null,
};

export default TimeSeriesCard;
1 change: 1 addition & 0 deletions src/components/TimeSeriesCard/TimeSeriesCard.story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const SinglePoint = () => {
includeZeroOnYaxis: true,
timeDataSourceId: 'timestamp',
addSpaceOnEdges: 1,
showLegend: true,
})}
values={getIntervalChartData(interval, 1, { min: 10, max: 100 }, 100)}
interval={interval}
Expand Down
14 changes: 7 additions & 7 deletions src/utils/__tests__/__snapshots__/publicAPI.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8405,6 +8405,9 @@ Map {
],
"type": "arrayOf",
},
"showLegend": Object {
"type": "bool",
},
"timeDataSourceId": Object {
"type": "string",
},
Expand All @@ -8427,9 +8430,6 @@ Map {
"interval": Object {
"type": "string",
},
"showLegend": Object {
"type": "bool",
},
"size": Object {
"type": "string",
},
Expand Down Expand Up @@ -11441,14 +11441,14 @@ Map {
"content": Object {
"includeZeroOnXaxis": false,
"includeZeroOnYaxis": false,
"showLegend": true,
},
"domainRange": null,
"i18n": Object {
"alertDetected": "Alert detected:",
"noDataLabel": "No data is available for this time range.",
},
"locale": "en",
"showLegend": null,
"showTimeInGMT": false,
"size": "MEDIUM",
"tooltipDateFormatPattern": "L HH:mm:ss",
Expand Down Expand Up @@ -12012,6 +12012,9 @@ Map {
"isRequired": true,
"type": "oneOfType",
},
"showLegend": Object {
"type": "bool",
},
"timeDataSourceId": Object {
"type": "string",
},
Expand Down Expand Up @@ -12249,9 +12252,6 @@ Map {
],
"type": "shape",
},
"showLegend": Object {
"type": "bool",
},
"showOverflow": [Function],
"showTimeInGMT": Object {
"type": "bool",
Expand Down

0 comments on commit eb2944d

Please sign in to comment.