Browse Source

fix: 完善雷达图

develop
song 4 years ago
parent
commit
5f52d35031
  1. 1
      .eslintignore
  2. 3
      CHANGELOG.md
  3. 3663
      src/common/u-charts.min.js
  4. 87
      src/components/Evaluated/EvaluatedNLCP.vue
  5. 65
      src/components/EvaluationChart/EvaluationChart.vue
  6. 130
      src/components/UCharts/UCharts.vue

1
.eslintignore

@ -9,5 +9,6 @@ postcss.config.js
.eslint.js .eslint.js
vue.config.js vue.config.js
src/common/styles/index.css src/common/styles/index.css
src/common/u-charts.min.js
src/pages.json src/pages.json
src/manifest.json src/manifest.json

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-11-17) # 0.1.0 (2021-11-18)
### 🌟 新功能 ### 🌟 新功能
范围|描述|commitId 范围|描述|commitId
@ -143,6 +143,7 @@
- | 切换到默认项目角色没有激活状态的bug | [438d448](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/438d448) - | 切换到默认项目角色没有激活状态的bug | [438d448](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/438d448)
- | 切换日历时查询小红点 | [7091789](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/7091789) - | 切换日历时查询小红点 | [7091789](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/7091789)
- | 初始展示角色修改 | [2ac4053](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/2ac4053) - | 初始展示角色修改 | [2ac4053](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/2ac4053)
- | 卸载stylus | [610b465](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/610b465)
- | 定期任务key值修改 | [c6688db](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/c6688db) - | 定期任务key值修改 | [c6688db](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/c6688db)
- | 定期任务接口 | [aa4981c](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/aa4981c) - | 定期任务接口 | [aa4981c](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/aa4981c)
- | 定期任务插件 | [92b3254](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/92b3254) - | 定期任务插件 | [92b3254](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/92b3254)

3663
src/common/u-charts.min.js

File diff suppressed because it is too large

87
src/components/Evaluated/EvaluatedNLCP.vue

@ -1,20 +1,32 @@
<template> <template>
<view> <view class="charts-box">
<text>{{ task.name }}</text> <view class="flex justify-between">
<EvaluationChart /> <text>{{ task.name }}</text>
<u-icon name="arrow-down" color="#909399"></u-icon>
</view>
<view class="bg-white" v-if="obj && obj.id">
<UCharts
:canvas-id="obj.id"
:chartType="obj.chartType"
:cWidth="cWidth"
:cHeight="cHeight"
:opts="obj.opts"
:ref="obj.id"
:max="obj.max"
/>
</view>
<view class="mt-2"> <view class="mt-2">
<view>测评结果</view> <view>测评结果</view>
<view class="flex justify-between">
<u-rate <u-rate
:count="task.data.mentalTest.gradeResult" :count="task.data.mentalTest.gradeResult"
v-model="task.data.mentalTest.gradeResult" v-model="task.data.mentalTest.gradeResult"
:disabled="true" :disabled="true"
:size="26" :size="26"
:gutter="2" :gutter="2"
active-color="#1890FF" active-color="#1890FF"
></u-rate> ></u-rate>
<u-icon name="arrow-down" color="#909399"></u-icon>
</view>
</view> </view>
</view> </view>
</template> </template>
@ -23,7 +35,52 @@
export default { export default {
props: { task: { type: Object, default: null } }, props: { task: { type: Object, default: null } },
data() { data() {
return {}; return {
cWidth: '',
cHeight: '',
obj: {},
};
},
mounted() {
this.$nextTick(() => {
const query = uni.createSelectorQuery().in(this);
query
.selectAll('.charts-box')
.boundingClientRect(data => {
this.cWidth = data[0].width;
})
.exec();
this.cHeight = uni.upx2px(400);
this.getData();
});
},
methods: {
//
getData() {
const { attentionNum, countNum, directionNum, expressNum, logicNum, memoryNum, viewNum } = this.task.data.mentalTest;
let radarA = {
categories: [
`注意力${attentionNum}`,
`计算能力${countNum}`,
`定向力${directionNum}`,
`语言能力${expressNum}`,
`逻辑执行${logicNum}`,
`记忆力${memoryNum}`,
`视空间${viewNum}`,
],
series: [{ data: [attentionNum, countNum, directionNum, expressNum, logicNum, memoryNum, viewNum] }],
};
this.obj = {
opts: radarA,
chartType: 'radar',
id: 'aaaa',
max: 1,
};
},
}, },
}; };
</script> </script>

65
src/components/EvaluationChart/EvaluationChart.vue

@ -1,65 +0,0 @@
<template>
<view style="width: 100%; height: 500rpx"><l-echart ref="chart"></l-echart></view>
</template>
<script>
// import * as echarts from 'components/l-echart/echarts';
export default {
data() {
return {
option: {
radar: [
{
indicator: [
{ text: '记忆力', max: 1 },
{ text: '语言能力', max: 1 },
{ text: '视空间', max: 1 },
{ text: '注意力', max: 1 },
{ text: '定向力', max: 1 },
{ text: '计算能力', max: 1 },
{ text: '逻辑执行', max: 1 },
],
radius: 80,
},
],
series: [
{
type: 'radar',
tooltip: { trigger: 'item' },
areaStyle: {},
data: [
{
value: [0.85, 0.65, 0.62, 0.71, 0.45, 0.55, 0.67],
name: 'A Software',
symbolSize: 5,
areaStyle: { color: 'rgba(24,144,255,.3)' },
lineStyle: { color: '#1da5ff' },
itemStyle: { color: '#1890ff' },
},
],
},
],
},
};
},
mounted() {
// this.$refs.chart.init(config => {
// const { canvas } = config;
// const chart = echarts.init(canvas, null, config);
// canvas.setChart(chart);
// chart.setOption(this.option);
// // chart
// return chart;
// });
},
};
</script>
<style>
.uni-ec-canvas {
width: 100%;
height: 100%;
display: block;
}
</style>

130
src/components/UCharts/UCharts.vue

@ -0,0 +1,130 @@
<template>
<canvas
v-if="canvasId"
:id="canvasId"
:canvasId="canvasId"
:style="{
width: cWidth * pixelRatio + 'px',
height: cHeight * pixelRatio + 'px',
transform: 'scale(' + 1 / pixelRatio + ')',
'margin-left': (-cWidth * (pixelRatio - 1)) / 2 + 'px',
'margin-top': (-cHeight * (pixelRatio - 1)) / 2 + 'px',
}"
@touchstart="touchStart"
@touchmove="touchMove"
@touchend="touchEnd"
@error="error"
>
</canvas>
</template>
<script>
import uCharts from '@/common/u-charts.min.js';
var canvases = {};
export default {
props: {
chartType: {
required: true,
type: String,
default: 'column',
},
opts: {
required: true,
type: Object,
default() {
return null;
},
},
canvasId: {
type: String,
default: 'u-canvas',
},
cWidth: { default: 375 },
cHeight: { default: 250 },
pixelRatio: {
type: Number,
default: 1,
},
max: {
type: Number,
default: 100,
},
},
mounted() {
this.init();
},
methods: {
init() {
switch (this.chartType) {
case 'radar':
this.initRadarChart();
break;
default:
break;
}
},
initRadarChart() {
canvases[this.canvasId] = new uCharts({
// $this: this,
// canvasId: this.canvasId,
context: uni.createCanvasContext(this.canvasId, this),
type: 'radar',
fontSize: 11,
padding: [20, 0, 0, 0],
legend: { show: false },
background: '#FFFFFF',
pixelRatio: this.pixelRatio,
animation: true,
dataLabel: true,
categories: this.opts.categories,
series: this.opts.series,
width: this.cWidth * this.pixelRatio,
height: this.cHeight * this.pixelRatio,
extra: {
radar: {
max: this.max, //
gridType: 'radar', //radarcircleradar
gridColor: '#eee',
labelColor: '#B9B9B9',
},
},
});
},
// cidcanvas-id,newdata
changeData(cid, newdata) {
canvases[cid].updateData({
series: newdata.series,
categories: newdata.categories,
});
},
touchStart(e) {
canvases[this.canvasId].showToolTip(e, {
format: function (item, category) {
return category + ' ' + item.name + ':' + item.data;
},
});
canvases[this.canvasId].scrollStart(e);
},
touchMove(e) {
canvases[this.canvasId].scroll(e);
},
touchEnd(e) {
canvases[this.canvasId].scrollEnd(e);
},
error(e) {
console.log(e);
},
},
};
</script>
<style scoped>
.charts {
width: 100%;
height: 100%;
flex: 1;
background-color: #ffffff;
}
</style>
Loading…
Cancel
Save