123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import React, { useState } from 'react';
- import { Card } from 'antd';
- import * as echarts from 'echarts/core';
- import Chart from '@/components/chart';
- import { getStatProblem } from "@/service/stat";
-
- export default (props) => {
- const [option, setOption] = useState({});
-
- React.useEffect(() => {
- getStatProblem().then((res) => {
- setOption({
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'cross',
- label: {
- backgroundColor: '#FB9900'
- }
- }
- },
- grid: {
- left: '3%',
- bottom: '3%',
- height: '90%',
- width: '90%',
- containLabel: true
- },
- xAxis: [
- {
- type: 'category',
- data: res.map(x => x.name),
-
- axisTick: {
- alignWithLabel: true,
- },
- axisLabel: {
- interval: 0,
- }
- }
- ],
- yAxis: [
- {
- type: 'value',
- minInterval: 1
- }
- ],
- series: [
- {
- type: 'bar',
- barWidth: '20%',
- itemStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: '#FB9900' },
- { offset: 1, color: '#FFD38F' }
- ]),
-
- },
- data: res.map(x => x.value),
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]
- });
- }).catch(console.error);
- }, []);
-
- return (
- <Card title="问题分类">
- <Chart option={option} style={props.style}></Chart>
- </Card>
- )
- }
|