|
|
@@ -53,11 +53,29 @@
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <el-dialog v-model="visualizeVisible" title="可视化" @open="open(chart.analysisFunction)" width="700px">
|
|
|
+ <el-form :model="chart" width="400px">
|
|
|
+ <el-form-item label="分析函数: " >
|
|
|
+ {{chart.analysisFunction}}
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="分析结果: " v-if="chart.analysisFunction!=='SCATTER_PLOT'">
|
|
|
+ {{chart.analysisResult}}
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="可视化: " v-if="chart.analysisFunction === 'DATA_DISTRIBUTION'">
|
|
|
+ <div id="chartPie" style="width: 600px;height: 300px" ></div>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="可视化: " v-if="chart.analysisFunction === 'SCATTER_PLOT'">
|
|
|
+ <div id="scatter" style="width: 600px;height: 300px" ></div>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {reactive, ref} from "vue";
|
|
|
+import {inject, nextTick, reactive, ref} from "vue";
|
|
|
import {deleteAnalysisPipeline, getAllAnalysisPipeline, useAnalysisPipeline} from "../../api/analysisPipeline";
|
|
|
import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
import {GetAllFile} from "../../api/file";
|
|
|
@@ -74,6 +92,17 @@ export default {
|
|
|
const formLabelWidth='120px'
|
|
|
const fileList = ref()
|
|
|
let usePipelineId = ref()
|
|
|
+ let visualizeVisible = ref(false)
|
|
|
+ const chart = reactive({
|
|
|
+ analysisFunction: '',
|
|
|
+ analysisResult: {},
|
|
|
+ pieResult: {},
|
|
|
+ })
|
|
|
+ let scatterData = ref([])
|
|
|
+ let scatterKey = ref([])
|
|
|
+
|
|
|
+ const echarts = inject('echarts')
|
|
|
+ const echartsScatter = inject('echarts')
|
|
|
|
|
|
const getPage = () => {
|
|
|
const uid=1;
|
|
|
@@ -104,23 +133,24 @@ export default {
|
|
|
beforeClose: (action, instance, done) => {
|
|
|
if (action === 'confirm') {
|
|
|
instance.confirmButtonLoading = true
|
|
|
- instance.confirmButtonText = '预测中...'
|
|
|
+ instance.confirmButtonText = '分析中...'
|
|
|
useAnalysisPipeline(data).then(res=>{
|
|
|
instance.confirmButtonLoading = false
|
|
|
console.log("predic_res: ",res);
|
|
|
if (res.msg === '成功')
|
|
|
{
|
|
|
- ElMessageBox({
|
|
|
- title: '流水线使用',
|
|
|
- message: `流水线使用成功`,
|
|
|
- confirmButtonText: '确定',
|
|
|
- })
|
|
|
+ // ElMessageBox({
|
|
|
+ // title: '流水线使用',
|
|
|
+ // message: `流水线使用成功`,
|
|
|
+ // confirmButtonText: '确定',
|
|
|
+ // })
|
|
|
done()
|
|
|
+ handleVisualize(res.result)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
console.log(res);
|
|
|
- ElMessage.error("预测失败!失败码:"+res.msg);
|
|
|
+ ElMessage.error("分析失败!失败码:"+res.msg);
|
|
|
done()
|
|
|
}
|
|
|
}).catch(err=>{
|
|
|
@@ -147,6 +177,166 @@ export default {
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
+ const handleVisualize = (result) => {
|
|
|
+ chart.analysisFunction = result.analysisFunction
|
|
|
+
|
|
|
+ if(chart.analysisFunction === 'SCATTER_PLOT'){
|
|
|
+ let tempArr= result.analysisResult
|
|
|
+ let tempObj = tempArr[0]
|
|
|
+ let out_arr = []
|
|
|
+ for(let key in tempObj){
|
|
|
+ out_arr.push(key)
|
|
|
+ }
|
|
|
+ scatterKey = out_arr
|
|
|
+ let tempScatterData = []
|
|
|
+ for (let i in tempArr){
|
|
|
+ let temp = []
|
|
|
+ for (let j in tempArr[i]){
|
|
|
+ temp.push(tempArr[i][j])
|
|
|
+ }
|
|
|
+ tempScatterData.push(temp)
|
|
|
+ }
|
|
|
+ scatterData = tempScatterData
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ chart.analysisResult = result.analysisResult
|
|
|
+ }
|
|
|
+
|
|
|
+ visualizeVisible.value = true
|
|
|
+
|
|
|
+ if(chart.analysisFunction === 'DATA_DISTRIBUTION'){
|
|
|
+ let out_arr = []
|
|
|
+ let in_obj = chart.analysisResult
|
|
|
+ for(let key in in_obj){
|
|
|
+ let temp = {}; //创建临时对象
|
|
|
+ temp.name = key; //存储对象的Key为name
|
|
|
+ temp.value = in_obj[key]; //存储value
|
|
|
+ out_arr.push(temp);
|
|
|
+ }
|
|
|
+ chart.pieResult = out_arr
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ const drawChart = () => {
|
|
|
+ let myChart = echarts.init(document.getElementById("chartPie"));
|
|
|
+ myChart.setOption({
|
|
|
+ //鼠标悬浮
|
|
|
+ tooltip: {
|
|
|
+ trigger: "item",
|
|
|
+ // formatter: "{a}<br/>{b}: <br/>{c}({d}%)", 其中 {a}指向name名称(访问来源)
|
|
|
+ formatter: "{b}: <br/>{c}({d}%)",
|
|
|
+ },
|
|
|
+ // legend: {
|
|
|
+ // // data: ["直接访问", "邮件营销", "联盟广告", "视频广告", "搜索引擎"],
|
|
|
+ // right: 300,
|
|
|
+ // orient: "vertical",
|
|
|
+ // // 下面注释的代码是控制分类放在哪个地方,需要体验的话,直接把上面的代码注释,把下面的代码解开注释即可
|
|
|
+ // data: ["红", "黄", "绿"],
|
|
|
+ // // left: "center",
|
|
|
+ // // top: "bottom",
|
|
|
+ // // orient: "horizontal"
|
|
|
+ // },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: "???",
|
|
|
+ type: "pie",
|
|
|
+ //圆圈的粗细
|
|
|
+ radius: ["50%", "80%"],
|
|
|
+ //圆圈的位置
|
|
|
+ center: ["50%", "50%"],
|
|
|
+ data: chart.pieResult,
|
|
|
+ animationDuration: 2000,
|
|
|
+ //控制是否显示指向文字的,默认为true
|
|
|
+ label: {
|
|
|
+ // show: false,
|
|
|
+ // position: "center",
|
|
|
+ //以下代码可以代表指向小文字的
|
|
|
+ show: true,
|
|
|
+ formatter: "{b} : {d}%",
|
|
|
+ textStyle: {
|
|
|
+ color: "#333",
|
|
|
+ fontSize: 14,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ })
|
|
|
+ window.onresize = function () {
|
|
|
+ myChart.resize()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const drawScatter = () => {
|
|
|
+ let myChart = echartsScatter.init(document.getElementById("scatter"));
|
|
|
+ myChart.setOption({
|
|
|
+ color: [
|
|
|
+ '#dd4444', '#fec42c', '#80F1BE'
|
|
|
+ ],
|
|
|
+ grid:{
|
|
|
+ right: '20%'
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ //十字线
|
|
|
+ axisPointer: {
|
|
|
+ type: 'cross'
|
|
|
+ },
|
|
|
+ padding: 10,
|
|
|
+ backgroundColor: '#222',
|
|
|
+ borderColor: '#777',
|
|
|
+ borderWidth: 1,
|
|
|
+ //设置tooltip的显示内容
|
|
|
+ formatter: function (obj) {
|
|
|
+ let value = obj.value;
|
|
|
+ return '<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 18px;padding-bottom: 7px;margin-bottom: 7px">'
|
|
|
+ + '具体数据:'
|
|
|
+ + '</div>'
|
|
|
+ + scatterKey[0] + ':' + value[0] + '<br>'
|
|
|
+ + scatterKey[1] + ':' + value[1] + '<br>'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ name: scatterKey[0],
|
|
|
+ splitLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ name: scatterKey[1],
|
|
|
+ splitLine: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ type: 'scatter',
|
|
|
+ itemStyle: {
|
|
|
+ shadowBlur: 10,
|
|
|
+ shadowColor: 'rgba(120, 36, 50, 0.5)',
|
|
|
+ shadowOffsetY: 5,
|
|
|
+ },
|
|
|
+ data: scatterData,
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ window.onresize = function () {
|
|
|
+ myChart.resize()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ const open = (func) =>{
|
|
|
+ if (func === 'DATA_DISTRIBUTION'){
|
|
|
+ nextTick(() => {
|
|
|
+ drawChart()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else if (func === 'SCATTER_PLOT'){
|
|
|
+ nextTick(() => {
|
|
|
+ drawScatter()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return{
|
|
|
tableData,
|
|
|
usePipelineVisible,
|
|
|
@@ -154,10 +344,20 @@ export default {
|
|
|
formLabelWidth,
|
|
|
fileList,
|
|
|
usePipelineId,
|
|
|
+ visualizeVisible,
|
|
|
+ chart,
|
|
|
+ scatterData,
|
|
|
+ scatterKey,
|
|
|
+ echarts,
|
|
|
+ echartsScatter,
|
|
|
getPage,
|
|
|
handleUsePipeline,
|
|
|
handleDelete,
|
|
|
goPipeline,
|
|
|
+ handleVisualize,
|
|
|
+ drawChart,
|
|
|
+ drawScatter,
|
|
|
+ open,
|
|
|
}
|
|
|
}
|
|
|
|