From 4d03f9c36dc5e20dd2f2d842e93f7d9d8eccf198 Mon Sep 17 00:00:00 2001 From: nikogu <644506165@qq.com> Date: Mon, 29 Jan 2018 14:10:28 +0800 Subject: [PATCH] fix Pie lengendData can not update. fixed: #819 --- src/components/Charts/Pie/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/Charts/Pie/index.js b/src/components/Charts/Pie/index.js index ac5703ce..528b2519 100644 --- a/src/components/Charts/Pie/index.js +++ b/src/components/Charts/Pie/index.js @@ -26,7 +26,16 @@ export default class Pie extends Component { componentWillReceiveProps(nextProps) { if (this.props.data !== nextProps.data) { - this.getLengendData(); + // because of charts data create when rendered + // so there is a trick for get rendered time + this.setState( + { + legendData: [...this.state.legendData], + }, + () => { + this.getLengendData(); + } + ); } } -- GitLab