import React,{ Component } from "react"; import {Pagination} from 'antd'; import axios from 'axios'; const $ = window.$; const echarts = require('echarts'); function InitChapterUsageSituation(_data){ var myChart = echarts.init(document.getElementById('chapterUsageSituation')); myChart.showLoading({ text: "数据获取中", effect: 'whirling' }) var Color = ['#49A9EE', '#FFD86E', '#98D87D', '#8996E6','#F3857B', '#B97BF3','#4DE8B4','#f76d0c','#510cf7','#def70c','#3bf70c','#0cf7e1']; var option = { title: { show:false }, tooltip : { trigger: 'item', formatter: "{d}%" }, legend: { //orient: 'vertical', // top: 'middle', bottom: 30, //left: 20, data:["第1章", "第2章", "第3章", "第4章", "第5章"], selectedMode:false }, series : [{ name: '使用情况', type: 'pie', radius : '50%', center: ['50%', '40%'], selectedMode: 'single', label: { normal: { // {abg|} // {a|{a}}\n formatter: ' {b|{b}} ', backgroundColor: '#eee', borderColor: '#aaa', borderWidth: 1, borderRadius: 4, rich: { a: { color: '#999', lineHeight: 22, align: 'center' }, hr: { borderColor: '#aaa', width: '100%', borderWidth: 0.5, height: 0 }, b: { fontSize: 16, lineHeight: 33 }, per: { color: '#eee', backgroundColor: '#334455', padding: [2, 4], borderRadius: 2 } } }, }, data: _data, // [{"value":19,"name":"\u7b2c1\u7ae0"},{"value":45,"name":"\u7b2c2\u7ae0"},{"value":16,"name":"\u7b2c3\u7ae0"},{"value":10,"name":"\u7b2c4\u7ae0"},{"value":10,"name":"\u7b2c5\u7ae0"}], itemStyle: { emphasis: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' }, normal:{ show: true, color: function(params) { return Color[params.dataIndex] } } } }] }; setTimeout(() => { myChart.setOption(option); myChart.hideLoading(); }, 1000) } class FirstTab extends Component{ constructor(props){ super(props); this.state = { page:1, total:undefined } } onChange=(pageNumber)=>{ this.setState({ page:pageNumber }) this.getData(pageNumber); } getData=(page)=>{ var pathId = this.props.match.params.pathId; const url = `/paths/${pathId}/statistics.json?page=`+page; axios.get(url, { }) .then((response) => { // TODO 没用,404返回的error if (response.data.status == 404) { this.props.showSnackbar('未找到对应数据,请查看地址是否正确。') return } this.setState({ ...response.data }) const _data = response.data.stage_info.map( (item, index) => { return { value: item.value, name: item.stage_no } }) InitChapterUsageSituation(_data); const { course_count, learn_count, school_total_count, subject_name, subject_id } = response.data this.props.initBannerData({ course_count, learn_count, school_total_count, subject_name, subject_id }) this.setState({ total:response.data.school_total_count }) }) .catch(function (error) { console.log(error); }); } componentDidMount(){ let {page}=this.state; this.getData(page); } render(){ const { schools, stage_info,page,total } = this.state; return(
课堂使用概况共{total}条记录
序号 | 所属院校 | 课堂 | 学生 | 选用实训 |
---|---|---|---|---|
{ index + 1 } | {school.name} | {school.course_count} | {school.student_count} | {school.homework_count}次 |
章节使用情况