From fbeb545a0fd050e701924cba4b8889398e474525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Sat, 18 May 2019 12:28:35 +0800 Subject: [PATCH] Fix warnings and details (#4209) * remove useless state loading * :up: upgrade bizcharts version to fix forceFit of null close #4107 ref alibaba/BizCharts#819 close #4195 * Fix setState after unmount * use Link over router.push * :bug: Fix duplicated keys in basic profile, close #4195 * use bizcharts@3.5.2-beta.2 * use bizcharts@3.5.3-beta.0 * :chart: Remove unused resize fns in Pie * remove resize function --- Dockerfile.dev | 2 +- config/router.config.js | 1 - package.json | 2 +- src/components/Charts/Bar/index.js | 9 +- src/components/Charts/Pie/index.js | 108 ++++++++---------------- src/components/Charts/TagCloud/index.js | 15 +--- src/pages/Dashboard/Analysis.js | 15 +--- src/pages/Dashboard/Workplace.js | 7 -- src/pages/List/TableList.js | 8 +- 9 files changed, 42 insertions(+), 125 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index f5a50e58..96fddc25 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -3,7 +3,7 @@ FROM node:latest WORKDIR /usr/src/app/ COPY package.json ./ -RUN npm install --silent --no-cache +RUN npm install --silent --no-cache --registry=https://registry.npm.taobao.org COPY ./ ./ diff --git a/config/router.config.js b/config/router.config.js index e954ced9..cdff38e0 100644 --- a/config/router.config.js +++ b/config/router.config.js @@ -155,7 +155,6 @@ export default [ }, { path: '/profile/basic/:id', - name: 'basic', hideInMenu: true, component: './Profile/BasicProfile', }, diff --git a/package.json b/package.json index d31018c2..0704f91a 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "dependencies": { "@antv/data-set": "^0.10.1", "antd": "^3.16.1", - "bizcharts": "3.5.2-beta.1", + "bizcharts": "^3.5.3-beta.0", "bizcharts-plugin-slider": "^2.1.1-beta.1", "classnames": "^2.2.6", "dva": "^2.4.1", diff --git a/src/components/Charts/Bar/index.js b/src/components/Charts/Bar/index.js index f898a122..2f7ee243 100644 --- a/src/components/Charts/Bar/index.js +++ b/src/components/Charts/Bar/index.js @@ -11,14 +11,6 @@ class Bar extends Component { autoHideXLabels: false, }; - componentDidMount() { - window.addEventListener('resize', this.resize, { passive: true }); - } - - componentWillUnmount() { - window.removeEventListener('resize', this.resize); - } - handleRoot = n => { this.root = n; }; @@ -30,6 +22,7 @@ class Bar extends Component { resizeObserver() { const ro = new ResizeObserver(entries => { const { width, height } = entries[0].contentRect; + this.resize(); this.setState(preState => { if (preState.width !== width || preState.height !== height) { return { diff --git a/src/components/Charts/Pie/index.js b/src/components/Charts/Pie/index.js index 5f80d747..ae3201f2 100644 --- a/src/components/Charts/Pie/index.js +++ b/src/components/Charts/Pie/index.js @@ -6,7 +6,6 @@ import classNames from 'classnames'; import ReactFitText from 'react-fittext'; import Debounce from 'lodash-decorators/debounce'; import Bind from 'lodash-decorators/bind'; -import ResizeObserver from 'resize-observer-polyfill'; import styles from './index.less'; /* eslint react/no-danger:0 */ @@ -17,17 +16,6 @@ class Pie extends Component { legendBlock: false, }; - componentDidMount() { - window.addEventListener( - 'resize', - () => { - this.requestRef = requestAnimationFrame(() => this.resize()); - }, - { passive: true } - ); - this.resizeObserver(); - } - componentDidUpdate(preProps) { const { data } = this.props; if (data !== preProps.data) { @@ -37,17 +25,10 @@ class Pie extends Component { } } - componentWillUnmount() { - window.cancelAnimationFrame(this.requestRef); - window.removeEventListener('resize', this.resize); - this.resize.cancel(); - } - getG2Instance = chart => { this.chart = chart; requestAnimationFrame(() => { this.getLegendData(); - this.resize(); }); }; @@ -93,23 +74,6 @@ class Pie extends Component { }); }; - resizeObserver() { - const ro = new ResizeObserver(entries => { - const { height } = entries[0].contentRect; - this.setState(preState => { - if (preState.height !== height) { - return { - height, - }; - } - return null; - }); - }); - if (this.chartDom) { - ro.observe(this.chartDom); - } - } - // for window resize auto responsive legend @Bind() @Debounce(300) @@ -223,45 +187,39 @@ class Pie extends Component { return (
-
{ - this.chartDom = ref; - }} - > - -
- - {!!tooltip && } - - - - - {(subTitle || total) && ( -
- {subTitle &&

{subTitle}

} - {/* eslint-disable-next-line */} - {total && ( -
{typeof total === 'function' ? total() : total}
- )} -
- )} -
-
-
+ +
+ + {!!tooltip && } + + + + + {(subTitle || total) && ( +
+ {subTitle &&

{subTitle}

} + {/* eslint-disable-next-line */} + {total && ( +
{typeof total === 'function' ? total() : total}
+ )} +
+ )} +
+
{hasLegend && (