Browse Source

feat: Optimize the display of toolTips

pull/3842/head
chen shuai 8 years ago
parent
commit
81ff030b63
  1. 42
      src/components/Charts/MiniProgress/index.js
  2. 2
      src/components/Charts/MiniProgress/index.less
  3. 12
      src/pages/Dashboard/IntroduceRow.js

42
src/components/Charts/MiniProgress/index.js

@ -1,6 +1,5 @@
import React from 'react'; import React from 'react';
import { Tooltip } from 'antd'; import { Tooltip } from 'antd';
import { formatMessage } from 'umi/locale';
import styles from './index.less'; import styles from './index.less';
@ -10,28 +9,27 @@ const MiniProgress = ({
color = 'rgb(19, 194, 194)', color = 'rgb(19, 194, 194)',
strokeWidth, strokeWidth,
percent, percent,
}) => ( }) => {
<div className={styles.miniProgress}> return (
<Tooltip <div className={styles.miniProgress}>
title={`${targetLabel || <Tooltip title={targetLabel}>
formatMessage({ id: 'component.miniProgress.tooltipDefault' }).concat(': ')} ${target}%`} <div className={styles.target} style={{ left: target ? `${target}%` : null }}>
> <span style={{ backgroundColor: color || null }} />
<div className={styles.target} style={{ left: target ? `${target}%` : null }}> <span style={{ backgroundColor: color || null }} />
<span style={{ backgroundColor: color || null }} /> </div>
<span style={{ backgroundColor: color || null }} /> </Tooltip>
<div className={styles.progressWrap}>
<div
className={styles.progress}
style={{
backgroundColor: color || null,
width: percent ? `${percent}%` : null,
height: strokeWidth || null,
}}
/>
</div> </div>
</Tooltip>
<div className={styles.progressWrap}>
<div
className={styles.progress}
style={{
backgroundColor: color || null,
width: percent ? `${percent}%` : null,
height: strokeWidth || null,
}}
/>
</div> </div>
</div> );
); };
export default MiniProgress; export default MiniProgress;

2
src/components/Charts/MiniProgress/index.less

@ -19,6 +19,8 @@
position: absolute; position: absolute;
top: 0; top: 0;
bottom: 0; bottom: 0;
z-index: 9;
width: 20px;
span { span {
position: absolute; position: absolute;
top: 0; top: 0;

12
src/pages/Dashboard/IntroduceRow.js

@ -1,6 +1,6 @@
import React, { memo } from 'react'; import React, { memo } from 'react';
import { Row, Col, Icon, Tooltip } from 'antd'; import { Row, Col, Icon, Tooltip } from 'antd';
import { FormattedMessage } from 'umi/locale'; import { FormattedMessage, formatMessage } from 'umi/locale';
import styles from './Analysis.less'; import styles from './Analysis.less';
import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from '@/components/Charts'; import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from '@/components/Charts';
import Trend from '@/components/Trend'; import Trend from '@/components/Trend';
@ -135,7 +135,15 @@ const IntroduceRow = memo(({ loading, visitData }) => (
} }
contentHeight={46} contentHeight={46}
> >
<MiniProgress percent={78} strokeWidth={8} target={80} color="#13C2C2" /> <MiniProgress
percent={78}
strokeWidth={8}
target={80}
targetLabel={`${formatMessage({ id: 'component.miniProgress.tooltipDefault' }).concat(
': '
)}80%`}
color="#13C2C2"
/>
</ChartCard> </ChartCard>
</Col> </Col>
</Row> </Row>

Loading…
Cancel
Save