UI: Updated Tier label in data insight chart (#9417)

This commit is contained in:
Shailesh Parmar 2022-12-20 15:20:25 +05:30 committed by GitHub
parent 2bf5eb9051
commit 11e0043bbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 8 deletions

View File

@ -37,6 +37,7 @@ import {
BAR_CHART_MARGIN, BAR_CHART_MARGIN,
DI_STRUCTURE, DI_STRUCTURE,
TIER_BAR_COLOR_MAP, TIER_BAR_COLOR_MAP,
TIER_DATA,
} from '../../constants/DataInsight.constants'; } from '../../constants/DataInsight.constants';
import { DataReportIndex } from '../../generated/dataInsight/dataInsightChart'; import { DataReportIndex } from '../../generated/dataInsight/dataInsightChart';
import { import {
@ -140,11 +141,11 @@ const TierInsight: FC<Props> = ({ chartFilter, selectedDays }) => {
<YAxis <YAxis
tickFormatter={(value) => axisTickFormatter(value, '%')} tickFormatter={(value) => axisTickFormatter(value, '%')}
/> />
<Tooltip content={<CustomTooltip isPercentage />} /> <Tooltip content={<CustomTooltip isPercentage isTier />} />
<Legend <Legend
align="left" align="left"
content={(props) => content={(props) =>
renderLegend(props as LegendProps, activeKeys) renderLegend(props as LegendProps, activeKeys, true)
} }
layout="horizontal" layout="horizontal"
verticalAlign="top" verticalAlign="top"
@ -202,7 +203,7 @@ const TierInsight: FC<Props> = ({ chartFilter, selectedDays }) => {
progress={latestData[tiers]} progress={latestData[tiers]}
showLabel={false} showLabel={false}
startValue={Number(latestData[tiers]).toFixed(2)} startValue={Number(latestData[tiers]).toFixed(2)}
successValue={tiers} successValue={TIER_DATA[tiers as keyof typeof TIER_DATA]}
/> />
</Col> </Col>
); );

View File

@ -103,6 +103,15 @@ export const TIER_FILTER = {
[i18n.t('label.tier-number', { tier: 5 })]: 'Tier.Tier5', [i18n.t('label.tier-number', { tier: 5 })]: 'Tier.Tier5',
}; };
export const TIER_DATA = {
'Tier.Tier1': i18n.t('label.tier-number', { tier: 1 }),
'Tier.Tier2': i18n.t('label.tier-number', { tier: 2 }),
'Tier.Tier3': i18n.t('label.tier-number', { tier: 3 }),
'Tier.Tier4': i18n.t('label.tier-number', { tier: 4 }),
'Tier.Tier5': i18n.t('label.tier-number', { tier: 5 }),
NoTier: i18n.t('label.no-tier'),
};
export const INITIAL_CHART_FILTER: ChartFilter = { export const INITIAL_CHART_FILTER: ChartFilter = {
startTs: getPastDaysDateTimeMillis(DEFAULT_DAYS), startTs: getPastDaysDateTimeMillis(DEFAULT_DAYS),
endTs: getCurrentDateTimeMillis(), endTs: getCurrentDateTimeMillis(),

View File

@ -34,6 +34,7 @@ export interface ChartFilter {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface DataInsightChartTooltipProps extends TooltipProps<any, any> { export interface DataInsightChartTooltipProps extends TooltipProps<any, any> {
isPercentage?: boolean; isPercentage?: boolean;
isTier?: boolean;
kpiTooltipRecord?: Record<string, KpiTargetType>; kpiTooltipRecord?: Record<string, KpiTargetType>;
} }

View File

@ -597,7 +597,8 @@
"admin-plural": "Admins", "admin-plural": "Admins",
"owner-plural": "Owners", "owner-plural": "Owners",
"follower-plural": "Followers", "follower-plural": "Followers",
"email-plural": "Emails" "email-plural": "Emails",
"no-tier": "No Tier"
}, },
"message": { "message": {
"service-email-required": "Service account Email is required", "service-email-required": "Service account Email is required",

View File

@ -38,6 +38,7 @@ import {
import { import {
ENTITIES_SUMMARY_LIST, ENTITIES_SUMMARY_LIST,
KPI_DATE_PICKER_FORMAT, KPI_DATE_PICKER_FORMAT,
TIER_DATA,
WEB_SUMMARY_LIST, WEB_SUMMARY_LIST,
} from '../constants/DataInsight.constants'; } from '../constants/DataInsight.constants';
import { KpiTargetType } from '../generated/api/dataInsight/kpi/createKpiRequest'; import { KpiTargetType } from '../generated/api/dataInsight/kpi/createKpiRequest';
@ -67,7 +68,8 @@ const checkIsPercentageGraph = (dataInsightChartType: DataInsightChartType) =>
export const renderLegend = ( export const renderLegend = (
legendData: LegendProps, legendData: LegendProps,
activeKeys = [] as string[] activeKeys = [] as string[],
isTier = false
) => { ) => {
const { payload = [] } = legendData; const { payload = [] } = legendData;
@ -101,7 +103,9 @@ export const renderLegend = (
/> />
</Surface> </Surface>
<span style={{ color: isActive ? 'inherit' : GRAYED_OUT_COLOR }}> <span style={{ color: isActive ? 'inherit' : GRAYED_OUT_COLOR }}>
{entry.value} {isTier
? TIER_DATA[entry.value as keyof typeof TIER_DATA]
: entry.value}
</span> </span>
</li> </li>
); );
@ -146,7 +150,13 @@ const getEntryFormattedValue = (
}; };
export const CustomTooltip = (props: DataInsightChartTooltipProps) => { export const CustomTooltip = (props: DataInsightChartTooltipProps) => {
const { active, payload = [], isPercentage, kpiTooltipRecord } = props; const {
active,
payload = [],
isPercentage,
kpiTooltipRecord,
isTier,
} = props;
if (active && payload && payload.length) { if (active && payload && payload.length) {
const timestamp = getDateByTimeStamp( const timestamp = getDateByTimeStamp(
@ -166,7 +176,9 @@ export const CustomTooltip = (props: DataInsightChartTooltipProps) => {
<Surface className="mr-2" height={12} version="1.1" width={12}> <Surface className="mr-2" height={12} version="1.1" width={12}>
<rect fill={entry.color} height="14" rx="2" width="14" /> <rect fill={entry.color} height="14" rx="2" width="14" />
</Surface> </Surface>
{entry.dataKey} {isTier
? TIER_DATA[entry.dataKey as keyof typeof TIER_DATA]
: entry.dataKey}
</span> </span>
<span className="font-medium"> <span className="font-medium">
{getEntryFormattedValue( {getEntryFormattedValue(