import { useState, useEffect, useRef } from 'react'
import useEcharts from '../../../../../hooks/useEcharts';
import CdzyApi from '../../../../../../utils/apis/CdzyApi';
import { getOption } from './echartsOptions';
import LittleTitle from '../../../../../common/LittleTitle';
import YhswApi from '../../../../../../utils/apis/YhswApi';
import StxhApi from '../../../../../../utils/apis/StxhApi';

export default function Tzjetj(props) {
    const [data, setData] = useState();
    const ref = useRef();
    const chart = useEcharts(ref.current);
    useEffect(() => {
        StxhApi.moneyCount().then(resp => {
            setData(resp.data);
        })
    }, []);
    useEffect(() => {
        if (chart && data) {
            const options = getOption(data);
            chart.setOption(options);
        }
    }, [chart, data]);
    return <div className='fill h0 layout-v'>
        <LittleTitle>投资金额统计</LittleTitle>
        <div ref={ref} className="h0 fill"></div>
    </div>
}