趋势图-模考次数
This commit is contained in:
parent
8f607c30c1
commit
a958f8892f
|
|
@ -35,4 +35,11 @@ export function getConsumerdis() {
|
||||||
url: '/analyse/consumerdis/',
|
url: '/analyse/consumerdis/',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMonitest() {
|
||||||
|
return request({
|
||||||
|
url: '/analyse/monitest/',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -14,26 +14,32 @@
|
||||||
<china-map :chartData="consumerdis" />
|
<china-map :chartData="consumerdis" />
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-card style="margin-top:6px">
|
||||||
|
<line-chart :chartData="monidata" />
|
||||||
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import BarChart from '../components/BarChart'
|
import BarChart from '../components/BarChart'
|
||||||
import ChinaMap from '../components/ChinaMap'
|
import ChinaMap from '../components/ChinaMap'
|
||||||
import { getAdmindata1, getCompanydis, getConsumerdis } from '@/api/analyse'
|
import LineChart from '../components/LineChart'
|
||||||
|
import { getAdmindata1, getCompanydis, getConsumerdis, getMonitest } from '@/api/analyse'
|
||||||
export default {
|
export default {
|
||||||
components:{BarChart, ChinaMap},
|
components:{BarChart, ChinaMap, LineChart},
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
admindata1:{},
|
admindata1:{},
|
||||||
companydis:{},
|
companydis:{},
|
||||||
consumerdis:{}
|
consumerdis:{},
|
||||||
|
monidata:{}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created(){
|
created(){
|
||||||
this.getadmindata1()
|
this.getadmindata1()
|
||||||
this.getcompanydis()
|
this.getcompanydis()
|
||||||
this.getconsumerdis()
|
this.getconsumerdis()
|
||||||
|
this.getmonitest()
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getadmindata1(){
|
getadmindata1(){
|
||||||
|
|
@ -50,7 +56,13 @@ export default {
|
||||||
getConsumerdis().then(res=>{
|
getConsumerdis().then(res=>{
|
||||||
this.consumerdis = res.data
|
this.consumerdis = res.data
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
getmonitest(){
|
||||||
|
getMonitest().then(res=>{
|
||||||
|
this.monidata = res.data
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
import echarts from 'echarts'
|
import echarts from 'echarts'
|
||||||
// require('echarts/theme/macarons') // echarts theme
|
// require('echarts/theme/macarons') // echarts theme
|
||||||
import resize from './mixins/resize'
|
import resize from './mixins/resize'
|
||||||
|
const animationDuration = 1000;
|
||||||
export default {
|
export default {
|
||||||
mixins: [resize],
|
mixins: [resize],
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -40,7 +40,7 @@ export default {
|
||||||
chartData: {
|
chartData: {
|
||||||
deep: true,
|
deep: true,
|
||||||
handler(val) {
|
handler(val) {
|
||||||
this.setOptions(val)
|
this.initChart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -59,15 +59,24 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
initChart() {
|
initChart() {
|
||||||
this.chart = echarts.init(this.$el, 'macarons')
|
this.chart = echarts.init(this.$el, 'macarons')
|
||||||
this.setOptions(this.chartData)
|
if (!this.chartData.s) {
|
||||||
},
|
return;
|
||||||
setOptions({ expectedData, actualData } = {}) {
|
}
|
||||||
this.chart.setOption({
|
let series = [];
|
||||||
|
for (var i = 0; i < this.chartData.s.length; i++) {
|
||||||
|
series.push({
|
||||||
|
name: this.chartData.s[i].name,
|
||||||
|
type: "line",
|
||||||
|
data: this.chartData.s[i].data,
|
||||||
|
animationDuration,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.chart.setOption({
|
||||||
title:{
|
title:{
|
||||||
text:'趋势分析'
|
text:this.chartData.t
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
data: this.chartData.x.data,
|
||||||
boundaryGap: false,
|
boundaryGap: false,
|
||||||
axisTick: {
|
axisTick: {
|
||||||
show: false
|
show: false
|
||||||
|
|
@ -77,7 +86,7 @@ export default {
|
||||||
left: 10,
|
left: 10,
|
||||||
right: 10,
|
right: 10,
|
||||||
bottom: 20,
|
bottom: 20,
|
||||||
top: 30,
|
top: 40,
|
||||||
containLabel: true
|
containLabel: true
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
|
|
@ -93,46 +102,11 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
data: ['expected', 'actual']
|
data: this.chartData.l
|
||||||
},
|
},
|
||||||
series: [{
|
series: series
|
||||||
name: 'expected', itemStyle: {
|
|
||||||
normal: {
|
|
||||||
color: '#FF005A',
|
|
||||||
lineStyle: {
|
|
||||||
color: '#FF005A',
|
|
||||||
width: 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
smooth: true,
|
|
||||||
type: 'line',
|
|
||||||
data: expectedData,
|
|
||||||
animationDuration: 2800,
|
|
||||||
animationEasing: 'cubicInOut'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'actual',
|
|
||||||
smooth: true,
|
|
||||||
type: 'line',
|
|
||||||
itemStyle: {
|
|
||||||
normal: {
|
|
||||||
color: '#3888fa',
|
|
||||||
lineStyle: {
|
|
||||||
color: '#3888fa',
|
|
||||||
width: 2
|
|
||||||
},
|
|
||||||
areaStyle: {
|
|
||||||
color: '#f3f8ff'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data: actualData,
|
|
||||||
animationDuration: 2800,
|
|
||||||
animationEasing: 'quadraticOut'
|
|
||||||
}]
|
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,16 @@ class Monitest(APIView):
|
||||||
模拟考试数据-时间分布图
|
模拟考试数据-时间分布图
|
||||||
"""
|
"""
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
ret = {'x':{'name':'月份', 'data':[]}, 's':[{'name':'自助模考', 'data':[]}, {'name':'押卷模考', 'data':[]}], 't':'模考次数趋势图'}
|
ret = {'x':{'name':'月份', 'data':[]}, 's':[{'name':'模考数', 'data':[]}], 't':'趋势图', 'l':['模考数']}
|
||||||
|
# ret = {'x':{'name':'月份', 'data':[]}, 's':[{'name':'自助模考', 'data':[]}, {'name':'押卷模考', 'data':[]}], 't':'模考次数趋势图', 'l':['自助模考', '押卷模考']}
|
||||||
tmp = ExamTest.objects.exclude(consumer__create_admin__isnull=True)\
|
tmp = ExamTest.objects.exclude(consumer__create_admin__isnull=True)\
|
||||||
.annotate(create_month=ExtractMonth('create_time'), create_year=ExtractYear('create_time'))\
|
.annotate(create_month=ExtractMonth('create_time'), create_year=ExtractYear('create_time'))\
|
||||||
.values('create_month', 'create_year', 'type').order_by('create_year', 'create_month').annotate(total=Count('create_month'))
|
.values('create_month', 'create_year').order_by('create_year', 'create_month').annotate(total=Count('create_month'))
|
||||||
for i in tmp:
|
for i in tmp:
|
||||||
if str(i['create_year'])+'年'+str(i['create_month'])+'月' not in ret['x']['data']:
|
# if str(i['create_year'])+'年'+str(i['create_month'])+'月' not in ret['x']['data']:
|
||||||
ret['x']['data'].append(str(i['create_year'])+'年'+str(i['create_month'])+'月')
|
ret['x']['data'].append(str(i['create_year'])+'年'+str(i['create_month'])+'月')
|
||||||
|
# if i['type'] == '自助模考':
|
||||||
|
ret['s'][0]['data'].append(i['total'])
|
||||||
return Response(ret)
|
return Response(ret)
|
||||||
|
|
||||||
nameMap = {
|
nameMap = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue