From 21e70b9dfbf845b43d255645ff577287b90d2253 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 27 Oct 2023 15:20:04 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E9=A6=96=E9=A1=B5:=20TOP=E6=9D=A1?= =?UTF-8?q?=E5=BD=A2=E5=9B=BE:=20=E8=B4=9F=E6=95=B0=E7=BA=A2=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BulletWithSort.jsx | 25 ++++++++++++++++++++----- src/components/MapCountry.jsx | 2 +- src/views/Home.jsx | 18 +++++------------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/components/BulletWithSort.jsx b/src/components/BulletWithSort.jsx index b106e3a..883cdac 100644 --- a/src/components/BulletWithSort.jsx +++ b/src/components/BulletWithSort.jsx @@ -13,32 +13,47 @@ export default observer((props) => { const maxKPI = Math.max(...(origin || []).map((ele) => (ele?.[targetField] || 0))); const maxValue = Math.max(...(origin || []).map((ele) => ele[measureField])); const _max = Math.max(maxKPI, maxValue); + const minValue = Math.min(...(origin || []).map((ele) => ele[measureField])); + const _min = Math.ceil(Math.min(0, minValue)); const sortData = origin.sort(sortBy(measureField)).slice(-itemLength); // 顶格的值定在更远 const _parseData = sortData?.map((ele) => ({ ...ele, - [rangeField]: [0, Math.ceil(_max / 0.9)], + [rangeField]: [_min, Math.ceil(_max / 0.9)], // [measureField]: [ele[measureField]], [measureField]: ele[measureFieldArrKey] || [ele[measureField]], [targetField]: (ele?.[targetField] || 0) })); - return _parseData; + return { _parseData, _max, _min }; }; const dataMapped = dataSource.reduce((r, v) => ({...r, [v.groupsLabel]: v}), {}); const ifMergeTB = isEmpty(dataSource) ? false : !isEmpty(dataSource[0]?.[`${extProps.measureField}_arr`]); const [parseData, setParseData] = useState([]); + const [maxV, setMaxV] = useState(0); + const [minV, setMinV] = useState(0); useEffect(() => { - setParseData(dataParser(dataSource)); + const _pdata = dataParser(dataSource); + setParseData(_pdata._parseData); + setMaxV(_pdata._max); + setMinV(_pdata._min); return () => {}; }, [extProps.measureField, dataSource]); const config = merge({ color: { - range: [ '#FFF3E1', '#FFF3E1'], - // range: [ '#FFF3E1', '#FFF3E1', '#FFe0b0', '#bfeec8'], // '#FFbcb8', '#FFe0b0', + range: [].concat((minV < 0 ? ['#ffe4e4'] : []), [ '#FFF3E1', '#FFF3E1']), measure: ['#5B8FF9', '#61ddaa'], target: '#FF9845', }, + bulletStyle: { + measure: (item, ...r) => { + if (item[extProps.measureField] < 0) { + return { + fill: '#F4664A', + }; + } + }, + }, label: { target: false, measure: { diff --git a/src/components/MapCountry.jsx b/src/components/MapCountry.jsx index e7fdce9..9e6a444 100644 --- a/src/components/MapCountry.jsx +++ b/src/components/MapCountry.jsx @@ -26,7 +26,7 @@ export default observer((props) => { type: 'mapbox', // style: 'blank', center: [120.19382669582967, 30.258134], - zoom: 3, + zoom: 2, pitch: 0, // scrollZoom: false, // dragPan: false, diff --git a/src/views/Home.jsx b/src/views/Home.jsx index 1cce101..fbf37bc 100644 --- a/src/views/Home.jsx +++ b/src/views/Home.jsx @@ -19,9 +19,9 @@ import './home.css'; const topSeries = [ { key: 'dept', label: '小组', graphVisible: true }, { key: 'operator', label: '顾问', graphVisible: true }, - { key: 'country', label: '国籍', graphVisible: false }, - { key: 'GuestGroupType', label: '客群类别', graphVisible: false }, { key: 'destination', label: '目的地', graphVisible: true }, + { key: 'GuestGroupType', label: '客群类别', graphVisible: false }, + { key: 'country', label: '国籍', graphVisible: true }, ]; // const iconSets = [CheckCircleTwoTone, , , , ,,]; @@ -264,22 +264,14 @@ export default observer(() => { ) : null )} - - -
- - - -

国籍

- - - + +
+
-
);