|
@@ -1,13 +1,14 @@
|
|
|
<template>
|
|
|
<!--<div class="hello" style="width:100%; height:195px;margin:0 auto;padding:20px 0">-->
|
|
|
- <div class="hello" :style="'width:'+ barwidthL +'%;height:'+barheight+'px;margin:0 auto;padding:20px 0'">
|
|
|
- <!--<div class="topic_box">-->
|
|
|
- <!--<p class="topic_title">题目:</p>-->
|
|
|
- <!--<div class="topic_content">题目内容</div>-->
|
|
|
- <!--</div>-->
|
|
|
- <!--<button @click="drawLine(1)">变色</button>-->
|
|
|
- <div id="main" :style="'width:'+barwidthL+'%;height:'+barheight+'px;'"></div>
|
|
|
- </div>
|
|
|
+ <div class="hello" :style="'width:'+ barwidthL +'%;height:'+barheight+'px;margin:0 auto;padding:20px 0'">
|
|
|
+ <!--<div class="topic_box">-->
|
|
|
+ <!--<p class="topic_title">题目:</p>-->
|
|
|
+ <!--<div class="topic_content">题目内容</div>-->
|
|
|
+ <!--</div>-->
|
|
|
+ <!--<button @click="drawLine(1)">变色</button>-->
|
|
|
+ <div id="main" :style="'width:'+barwidthL+'%;height:'+barheight+'px;'" v-if="oneanswer"></div>
|
|
|
+ <div id="multiplebar" :style="'width:'+barwidthL+'%;height:'+barheight+'px;'" v-if="multiple"></div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
<script>
|
|
|
export default {
|
|
@@ -20,11 +21,15 @@
|
|
|
cssvalue: '',
|
|
|
barheight: '240',
|
|
|
barwidthL: '95',
|
|
|
- letterOrnumber:["A", "B", "C", "D","E","F","G","H","I","J"],
|
|
|
+ letterOrnumber: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"],
|
|
|
+ //是否有二次作答
|
|
|
+ oneanswer:true,
|
|
|
+ multiple:false,
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.init();
|
|
|
+ this.charinit()
|
|
|
},
|
|
|
mounted() {
|
|
|
this.cssvalues()
|
|
@@ -58,65 +63,65 @@
|
|
|
shopCharts.resize();
|
|
|
}
|
|
|
},
|
|
|
- drawLine(defaultcolor,Data,patternvalue) {
|
|
|
- // 基于准备好的dom,初始化echarts实例
|
|
|
- let myChart = this.$echarts.init(document.getElementById('main'))
|
|
|
- // 绘制图表
|
|
|
- myChart.setOption({
|
|
|
- tooltip: {},
|
|
|
- xAxis: {
|
|
|
- data:patternvalue,
|
|
|
- axisLabel: {
|
|
|
- show: true,
|
|
|
- textStyle: {
|
|
|
- color: '#6D7278', //更改坐标轴文字颜色
|
|
|
- fontSize : 20 //更改坐标轴文字大小
|
|
|
- }
|
|
|
- },
|
|
|
- },
|
|
|
- yAxis : [
|
|
|
- {
|
|
|
- min: 0,
|
|
|
- max: 100,
|
|
|
- axisLine: {show:false},
|
|
|
- axisTick: {show:false},
|
|
|
- splitLine:{show:false},
|
|
|
- axisLabel : {
|
|
|
- formatter: function(){
|
|
|
- return " ";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- ],
|
|
|
- series: [{
|
|
|
- name: '答案占比',
|
|
|
- type: 'bar',
|
|
|
- barWidth: 80,
|
|
|
- data: Data,
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- //柱形图圆角,初始化效果
|
|
|
- barBorderRadius: [10, 10, 0, 0],
|
|
|
- color: function(params) {
|
|
|
- var colorList = defaultcolor;
|
|
|
- return colorList[params.dataIndex]
|
|
|
- },
|
|
|
- label: {
|
|
|
- show: true,//是否展示,
|
|
|
- position: "top",
|
|
|
- formatter: '{@score}%',
|
|
|
- textStyle: {
|
|
|
- fontSize : '20',
|
|
|
- fontFamily: '微软雅黑',
|
|
|
- color:"#1E90FF"
|
|
|
+ drawLine(defaultcolor, Data, patternvalue) {
|
|
|
+ // 基于准备好的dom,初始化echarts实例
|
|
|
+ let myChart = this.$echarts.init(document.getElementById('main'))
|
|
|
+ // 绘制图表
|
|
|
+ myChart.setOption({
|
|
|
+ tooltip: {},
|
|
|
+ xAxis: {
|
|
|
+ data: patternvalue,
|
|
|
+ axisLabel: {
|
|
|
+ show: true,
|
|
|
+ textStyle: {
|
|
|
+ color: '#6D7278', //更改坐标轴文字颜色
|
|
|
+ fontSize: 20 //更改坐标轴文字大小
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
- },
|
|
|
- }
|
|
|
- },
|
|
|
- }
|
|
|
- ]
|
|
|
- });
|
|
|
- },
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ min: 0,
|
|
|
+ max: 100,
|
|
|
+ axisLine: { show: false },
|
|
|
+ axisTick: { show: false },
|
|
|
+ splitLine: { show: false },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: function () {
|
|
|
+ return " ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ series: [{
|
|
|
+ name: '答案占比',
|
|
|
+ type: 'bar',
|
|
|
+ barWidth: 80,
|
|
|
+ data: Data,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ //柱形图圆角,初始化效果
|
|
|
+ barBorderRadius: [10, 10, 0, 0],
|
|
|
+ color: function (params) {
|
|
|
+ var colorList = defaultcolor;
|
|
|
+ return colorList[params.dataIndex]
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ show: true,//是否展示,
|
|
|
+ position: "top",
|
|
|
+ formatter: '{@score}%',
|
|
|
+ textStyle: {
|
|
|
+ fontSize: '20',
|
|
|
+ fontFamily: '微软雅黑',
|
|
|
+ color: "#1E90FF"
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ },
|
|
|
init() {
|
|
|
let answerpattern = this.$store.state.answerpattern
|
|
|
let AnswerSelect = this.$store.state.AnswerSelect
|
|
@@ -161,20 +166,125 @@
|
|
|
this.BarData=this.$store.state.echartbaranswer
|
|
|
}
|
|
|
console.log(this.$store.state.answervalue, '目前答案结果');
|
|
|
- },
|
|
|
+ },
|
|
|
+ charinit() {
|
|
|
+ let reuse = this.$store.state.FirstRecord
|
|
|
+ console.log(reuse,'!!!!')
|
|
|
+ if (reuse.length != 0) {
|
|
|
+ console.log('查看是否执行')
|
|
|
+ this.oneanswer = false
|
|
|
+ this.multiple=true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //二次作答柱状图
|
|
|
+ multiplecharbar(defaultcolor, Data, patternvalue) {
|
|
|
+ // 基于准备好的dom,初始化echarts实例
|
|
|
+ let myChart = this.$echarts.init(document.getElementById('multiplebar'))
|
|
|
+ // 绘制图表
|
|
|
+ myChart.setOption({
|
|
|
+ tooltip: {},
|
|
|
+ xAxis: {
|
|
|
+ data: patternvalue,
|
|
|
+ axisLabel: {
|
|
|
+ show: true,
|
|
|
+ textStyle: {
|
|
|
+ color: '#6D7278', //更改坐标轴文字颜色
|
|
|
+ fontSize: 20 //更改坐标轴文字大小
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ min: 0,
|
|
|
+ max: 100,
|
|
|
+ axisLine: { show: false },
|
|
|
+ axisTick: { show: false },
|
|
|
+ splitLine: { show: false },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: function () {
|
|
|
+ return " ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ series: [{
|
|
|
+ name: '第一次作答',
|
|
|
+ type: 'bar',
|
|
|
+ barWidth: 80,
|
|
|
+ data: Data,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ //柱形图圆角,初始化效果
|
|
|
+ barBorderRadius: [10, 10, 0, 0],
|
|
|
+ color: function (params) {
|
|
|
+ var colorList = defaultcolor;
|
|
|
+ return colorList[params.dataIndex]
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ show: true,//是否展示,
|
|
|
+ position: "top",
|
|
|
+ formatter: '{@score}%',
|
|
|
+ textStyle: {
|
|
|
+ fontSize: '20',
|
|
|
+ fontFamily: '微软雅黑',
|
|
|
+ color: "#1E90FF"
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '第二次作答',
|
|
|
+ type: 'bar',
|
|
|
+ barWidth: 80,
|
|
|
+ data: Data,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ //柱形图圆角,初始化效果
|
|
|
+ barBorderRadius: [10, 10, 0, 0],
|
|
|
+ color: function (params) {
|
|
|
+ var colorList = defaultcolor;
|
|
|
+ return colorList[params.dataIndex]
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ show: true,//是否展示,
|
|
|
+ position: "top",
|
|
|
+ formatter: '{@score}%',
|
|
|
+ textStyle: {
|
|
|
+ fontSize: '20',
|
|
|
+ fontFamily: '微软雅黑',
|
|
|
+ color: "#1E90FF"
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
echartbaranswer(a) {
|
|
|
console.log(a,'a')
|
|
|
let newColor = ['#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF']
|
|
|
let nowpattern=this.letterOrnumber
|
|
|
- this.drawLine(newColor, a,nowpattern);
|
|
|
+ let reuse = this.$store.state.FirstRecord
|
|
|
+ if (reuse.length != 0) {
|
|
|
+ this.multiplecharbar(newColor, b, nowpattern);
|
|
|
+ } else if (reuse.length == 0) {
|
|
|
+ this.drawLine(newColor, b, nowpattern);
|
|
|
+ }
|
|
|
},
|
|
|
BarData(b) {
|
|
|
console.log(b,'b')
|
|
|
let newColor = ['#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF', '#0097FF']
|
|
|
let nowpattern=this.letterOrnumber
|
|
|
- this.drawLine(newColor,b,nowpattern);
|
|
|
+ let reuse = this.$store.state.FirstRecord
|
|
|
+ if (reuse.length != 0) {
|
|
|
+ this.multiplecharbar(newColor, b, nowpattern);
|
|
|
+ } else if (reuse.length == 0) {
|
|
|
+ this.drawLine(newColor, b, nowpattern);
|
|
|
+ }
|
|
|
},
|
|
|
defaultcolor(e) {
|
|
|
let answercolor = e
|