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

fix(ChartCards): translate group and total tooltip labels #1913

Merged
merged 10 commits into from
Jan 8, 2021
4 changes: 4 additions & 0 deletions src/components/BarChartCard/BarChartCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ const BarChartCard = ({
showTimeInGMT,
tooltipDateFormatPattern
),
groupLabel: i18n.tooltipGroupLabel,
totalLabel: i18n.tooltipTotalLabel,
},
// zoomBar should only be enabled for time-based charts
...(zoomBar?.enabled &&
Expand Down Expand Up @@ -353,6 +355,8 @@ BarChartCard.defaultProps = {
size: CARD_SIZES.MEDIUMWIDE,
i18n: {
noDataLabel: 'No data',
tooltipGroupLabel: 'Group',
tooltipTotalLabel: 'Total',
},
domainRange: null,
content: {
Expand Down
1 change: 0 additions & 1 deletion src/components/BarChartCard/BarChartCard.story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const acceptableSizes = Object.keys(CARD_SIZES).filter(

export default {
title: 'Watson IoT/BarChartCard',

parameters: {
component: BarChartCard,
},
Expand Down
1 change: 0 additions & 1 deletion src/components/BarChartCard/barChartUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ export const formatColors = (

/**
* Extends default tooltip with additional date information if the graph is time-based
* and adds color of dataset if defined
*
* This function is a bit more hacky than TimeSeriesCard because carbon charts formats it differently
* TODO: remove the hackiness once this issue is solved: https://github.com/carbon-design-system/carbon-charts/issues/657
Expand Down
3 changes: 3 additions & 0 deletions src/components/TimeSeriesCard/TimeSeriesCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const TimeSeriesCardPropTypes = {
i18n: PropTypes.shape({
alertDetected: PropTypes.string,
noData: PropTypes.string,
tooltipGroupLabel: PropTypes.string,
}),
/** array of data from the backend for instance [{timestamp: Date object || ms timestamp, temperature: 35, humidity: 10}, ...] */
values: PropTypes.arrayOf(
Expand Down Expand Up @@ -599,6 +600,7 @@ const TimeSeriesCard = ({
showTimeInGMT,
tooltipDateFormatPattern
),
groupLabel: i18n.tooltipGroupLabel,
},
getStrokeColor: handleStrokeColor,
getFillColor: handleFillColor,
Expand Down Expand Up @@ -680,6 +682,7 @@ TimeSeriesCard.defaultProps = {
i18n: {
alertDetected: 'Alert detected:',
noDataLabel: 'No data is available for this time range.',
tooltipGroupLabel: 'Group',
},
chartType: TIME_SERIES_TYPES.LINE,
locale: 'en',
Expand Down
4 changes: 3 additions & 1 deletion src/components/TimeSeriesCard/TimeSeriesCard.story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const commonProps = {

export default {
title: 'Watson IoT/TimeSeriesCard',

parameters: {
component: TimeSeriesCard,
},
Expand Down Expand Up @@ -1331,6 +1330,9 @@ export const Locale = () => {
showTimeInGMT={boolean('showTimeInGMT', false)}
size={size}
onCardAction={action('onCardAction')}
i18n={{
tooltipGroupLabel: 'Translated Group',
}}
/>
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions src/constants/CardPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ export const BarChartCardPropTypes = {
/** internationalization */
i18n: PropTypes.shape({
alertDetected: PropTypes.string,
tooltipGroupLabel: PropTypes.string,
tooltipTotalLabel: PropTypes.string,
}),
/** optional domain to graph from. First value is the beginning of the range. Second value is the end of the range
* can be date instance or timestamp */
Expand Down
12 changes: 12 additions & 0 deletions src/utils/__tests__/__snapshots__/publicAPI.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4510,6 +4510,8 @@ Map {
"domainRange": null,
"i18n": Object {
"noDataLabel": "No data",
"tooltipGroupLabel": "Group",
"tooltipTotalLabel": "Total",
},
"locale": "en",
"showTimeInGMT": false,
Expand Down Expand Up @@ -5158,6 +5160,12 @@ Map {
"alertDetected": Object {
"type": "string",
},
"tooltipGroupLabel": Object {
"type": "string",
},
"tooltipTotalLabel": Object {
"type": "string",
},
},
],
"type": "shape",
Expand Down Expand Up @@ -12191,6 +12199,7 @@ Map {
"i18n": Object {
"alertDetected": "Alert detected:",
"noDataLabel": "No data is available for this time range.",
"tooltipGroupLabel": "Group",
},
"locale": "en",
"showTimeInGMT": false,
Expand Down Expand Up @@ -12889,6 +12898,9 @@ Map {
"noData": Object {
"type": "string",
},
"tooltipGroupLabel": Object {
"type": "string",
},
},
],
"type": "shape",
Expand Down