style: 首页: TOP条形图: 负数红色

feature/pivot
Lei OT 2 years ago
parent 34080fce8b
commit 21e70b9dfb

@ -13,32 +13,47 @@ export default observer((props) => {
const maxKPI = Math.max(...(origin || []).map((ele) => (ele?.[targetField] || 0))); const maxKPI = Math.max(...(origin || []).map((ele) => (ele?.[targetField] || 0)));
const maxValue = Math.max(...(origin || []).map((ele) => ele[measureField])); const maxValue = Math.max(...(origin || []).map((ele) => ele[measureField]));
const _max = Math.max(maxKPI, maxValue); 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 sortData = origin.sort(sortBy(measureField)).slice(-itemLength);
// //
const _parseData = sortData?.map((ele) => ({ ...ele, 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[measureField]],
[measureField]: ele[measureFieldArrKey] || [ele[measureField]], [measureField]: ele[measureFieldArrKey] || [ele[measureField]],
[targetField]: (ele?.[targetField] || 0) [targetField]: (ele?.[targetField] || 0)
})); }));
return _parseData; return { _parseData, _max, _min };
}; };
const dataMapped = dataSource.reduce((r, v) => ({...r, [v.groupsLabel]: v}), {}); const dataMapped = dataSource.reduce((r, v) => ({...r, [v.groupsLabel]: v}), {});
const ifMergeTB = isEmpty(dataSource) ? false : !isEmpty(dataSource[0]?.[`${extProps.measureField}_arr`]); const ifMergeTB = isEmpty(dataSource) ? false : !isEmpty(dataSource[0]?.[`${extProps.measureField}_arr`]);
const [parseData, setParseData] = useState([]); const [parseData, setParseData] = useState([]);
const [maxV, setMaxV] = useState(0);
const [minV, setMinV] = useState(0);
useEffect(() => { useEffect(() => {
setParseData(dataParser(dataSource)); const _pdata = dataParser(dataSource);
setParseData(_pdata._parseData);
setMaxV(_pdata._max);
setMinV(_pdata._min);
return () => {}; return () => {};
}, [extProps.measureField, dataSource]); }, [extProps.measureField, dataSource]);
const config = merge({ const config = merge({
color: { color: {
range: [ '#FFF3E1', '#FFF3E1'], range: [].concat((minV < 0 ? ['#ffe4e4'] : []), [ '#FFF3E1', '#FFF3E1']),
// range: [ '#FFF3E1', '#FFF3E1', '#FFe0b0', '#bfeec8'], // '#FFbcb8', '#FFe0b0',
measure: ['#5B8FF9', '#61ddaa'], measure: ['#5B8FF9', '#61ddaa'],
target: '#FF9845', target: '#FF9845',
}, },
bulletStyle: {
measure: (item, ...r) => {
if (item[extProps.measureField] < 0) {
return {
fill: '#F4664A',
};
}
},
},
label: { label: {
target: false, target: false,
measure: { measure: {

@ -26,7 +26,7 @@ export default observer((props) => {
type: 'mapbox', type: 'mapbox',
// style: 'blank', // style: 'blank',
center: [120.19382669582967, 30.258134], center: [120.19382669582967, 30.258134],
zoom: 3, zoom: 2,
pitch: 0, pitch: 0,
// scrollZoom: false, // scrollZoom: false,
// dragPan: false, // dragPan: false,

@ -19,9 +19,9 @@ import './home.css';
const topSeries = [ const topSeries = [
{ key: 'dept', label: '小组', graphVisible: true }, { key: 'dept', label: '小组', graphVisible: true },
{ key: 'operator', label: '顾问', graphVisible: true }, { key: 'operator', label: '顾问', graphVisible: true },
{ key: 'country', label: '国籍', graphVisible: false },
{ key: 'GuestGroupType', label: '客群类别', graphVisible: false },
{ key: 'destination', label: '目的地', graphVisible: true }, { key: 'destination', label: '目的地', graphVisible: true },
{ key: 'GuestGroupType', label: '客群类别', graphVisible: false },
{ key: 'country', label: '国籍', graphVisible: true },
]; ];
// const iconSets = [CheckCircleTwoTone, <MoneyCollectTwoTone />, <FlagTwoTone />, <ClockCircleTwoTone />, <DashboardTwoTone />,<SmileTwoTone />,]; // const iconSets = [CheckCircleTwoTone, <MoneyCollectTwoTone />, <FlagTwoTone />, <ClockCircleTwoTone />, <DashboardTwoTone />,<SmileTwoTone />,];
@ -264,22 +264,14 @@ export default observer(() => {
</Col> </Col>
) : null ) : null
)} )}
</Row> <Col {...layoutProps3} key={'mapG'} lg={{ span: 16 }}>
</section>
<section>
<Spin spinning={topData?.country?.loading || false}> <Spin spinning={topData?.country?.loading || false}>
<Row gutter={layoutProps3.gutter}>
<Col {...layoutProps3} key={'mapD'} lg={{ span: 6 }}>
<h3 style={{ textAlign: 'center' }}>国籍</h3>
<Bullet {...BulletConfig} dataSource={topData?.country?.dataSource || []} itemLength={10} key={`countryD`} />
</Col>
<Col {...layoutProps3} key={'mapG'} lg={{ span: 18 }}>
<div id='topC' style={{height: '700px'}}> <div id='topC' style={{height: '700px'}}>
<MapCountry sourceField={'groupsLabel'} valueField={BUConfig.measureField} dataSource={topData?.country?.dataSource || []} /> <MapCountry sourceField={'groupsLabel'} valueField={BUConfig.measureField} dataSource={topData?.country?.dataSource || []} />
</div> </div>
</Spin>
</Col> </Col>
</Row> </Row>
</Spin>
</section> </section>
</> </>
); );

Loading…
Cancel
Save