react echars 圆形日历图参考

import ReactEchartsCore from 'echarts-for-react/lib/core';
import 'echarts/lib/chart/bar';
import 'echarts/lib/chart/heatmap';
import 'echarts/lib/chart/line';
import 'echarts/lib/component/dataZoom';
import 'echarts/lib/component/graphic';
import 'echarts/lib/component/grid';
import 'echarts/lib/component/title';
import 'echarts/lib/component/tooltip';
import 'echarts/lib/component/visualMap';
import 'echarts/extension/bmap/bmap';
import echarts from 'echarts/lib/echarts';
import { HEATMAP_CHARTS_COLORS_MANY } from '@/src/common/constants';
import React, { useRef } from 'react';

import { Box } from '../Box';
import { ChartTitle } from './ChartTitle';

const CalendarHeatmap: React.FC<any> = ({
  title,
  chartData,
  height,
  loading = false,
  range,
  max,
  t
}) => {
  const monthCounter = useRef(0);

  const lineOption = {
    title: {
      top: 30,
      left: 'center'
    },
    visualMap: {
      min: 0,
      max: max,
      type: 'piecewise',
      orient: 'horizontal',
      top: 65,
      right: 'right',
      text: ['多', '少'],
      padding: -10,
      itemSymbol: 'circle',
      selectedMode:false,
      inRange: {
        color: HEATMAP_CHARTS_COLORS_MANY,
        symbol: 'circle',
      },

      splitNumber: 11,
      showLabel: false,
    },
    calendar: {
      top: 130,
      left: 40,
      right: 10,
      cellSize: [18, 18],
      splitLine: true,
      range: range,
      itemStyle: {
        borderWidth: 2,
        borderColor: 'transparent'
      },
      dayLabel: {
        nameMap: [t('Su'), '', '', t('We'), '', '', t('Sa')]
      },
      yearLabel: { show: false },
      monthLabel: {
        show: true,
        backgroundColor: '#EAF0F7',
        borderRadius: 14,
        shadowColor: 'green',
        padding: [5, 10]
      }
    },
    series: {
      coordinateSystem: 'calendar',
      data: chartData,
      type: 'graph',
      edgeSymbol: ['none'],
      symbolSize: 15,
      calendarIndex: 0,
      itemStyle: {
        boder: 'none'
      }
    },
    tooltip: [
      {
        trigger: 'item',
        show: true,
        formatter: (value) => {
          return value.data.join(' : ');
        }
      }
    ],
  };
  return (
    <div className="chart-container">
      {title && <ChartTitle title={title} />}
      {loading ? (
        <Box loading={loading} height={height} />
      ) : (<ReactEchartsCore echarts={echarts}   option={lineOption} />
      )}
    </div>
  );
};

export { CalendarHeatmap };

需要注意的是这个是在echars4.9.0版本下实现的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值