WIP: 实现二级菜单中Spectra组件,修改一级菜单结构,并在菜单中增加已选中文件功能;绘制3D Scatter和3D Surface 图表(进行中)

This commit is contained in:
Xu Zhimeng 2023-06-29 17:43:15 +08:00
parent f36c94fa4e
commit 005a057f47
9 changed files with 652 additions and 100 deletions

View File

@ -24,6 +24,7 @@
"dayjs": "^1.8.0", "dayjs": "^1.8.0",
"dom-align": "1.12.0", "dom-align": "1.12.0",
"echarts": "^5.4.2", "echarts": "^5.4.2",
"echarts-gl": "^2.0.9",
"enquire.js": "^2.1.6", "enquire.js": "^2.1.6",
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"lodash.get": "^4.4.2", "lodash.get": "^4.4.2",

View File

@ -0,0 +1,51 @@
<template>
<div class="custom-chart" ref="containerRef" :style="{ height: height + 'px' }"></div>
</template>
<script>
import * as echarts from 'echarts'
import 'echarts-gl'
export default {
props: {
option: {
type: Object,
default: () => ({})
},
height: {
type: Number,
default: 0
}
},
data() {
return {}
},
mounted() {
this.chart = echarts.init(this.$refs.containerRef)
this.chart.setOption(this.option)
},
methods: {
resize() {
this.chart && this.chart.resize()
}
},
watch: {
option: {
handler() {
if (this.chart) {
this.chart.setOption(this.option)
}
},
deep: true
},
height() {
this.$nextTick(() => {
this.chart && this.chart.resize()
})
}
}
}
</script>
<style lang="less" scoped>
.custom-chart {
height: 100% !important;
}
</style>

View File

@ -30,7 +30,6 @@ export default {
option: { option: {
handler() { handler() {
if(this.chart) { if(this.chart) {
this.chart.clear()
this.chart.setOption(this.option) this.chart.setOption(this.option)
} }
}, },

View File

@ -10,34 +10,51 @@
> >
</div> </div>
<div class="beta-gamma-spectrum-chart-main"> <div class="beta-gamma-spectrum-chart-main">
<custom-chart ref="chartRef" :option="option" /> <!-- 2D 图表 -->
<div class="_2d-chart" v-if="active == 0">
<custom-chart ref="chartRef" :option="twoDOption" />
<div class="bar">
<div>256</div>
<div class="bar-main"></div>
<div>0</div>
</div>
</div>
<!-- 2D图表结束 -->
<!-- 3D Surface开始 -->
<Custom3DChart v-if="active == 1" key="1" ref="_3dSurfaceRef" :option="threeDSurfaceOption" />
<!-- 3D Surface结束 -->
<!-- 3D Scatter -->
<Custom3DChart v-if="active == 2" key="2" ref="_3dScannerRef" :option="threeDScatterOption" />
<!-- 3D Scatter结束 -->
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import CustomChart from '@/components/CustomChart/index.vue' import CustomChart from '@/components/CustomChart/index.vue'
import Custom3DChart from '@/components/Custom3DChart/index.vue'
const buttons = ['2D', '3D Surface', '3D Scatter', 'Unzoom'] const buttons = ['2D', '3D Surface', '3D Scatter', 'Unzoom']
const option = { // 2D
visualMap: [{ const twoDOption = {
min: 0,
max: 256,
calculable: true,
orient: 'vertical',
right: 0,
top: 0,
bottom: 0,
inRange: {
color: ['#fff', '#f00']
}
}],
grid: { grid: {
top: 15, top: 15,
left: 55, left: 55,
right: 40, right: 10,
bottom: 45 bottom: 45
}, },
tooltip: {
trigger: 'axis',
showContent: false,
axisPointer: {
animation: false,
type: 'cross',
lineStyle: {
type: 'dashed'
}
}
},
xAxis: { xAxis: {
name: 'Beta Channel', name: 'Beta Channel',
nameTextStyle: { nameTextStyle: {
@ -61,8 +78,7 @@ const option = {
}, },
min: 0, min: 0,
max: 256, max: 256,
interval: 64, interval: 64
data: new Array(256).fill(0).map((_, index) => index)
}, },
yAxis: { yAxis: {
name: 'Gamma Channel', name: 'Gamma Channel',
@ -87,24 +103,169 @@ const option = {
}, },
min: 0, min: 0,
max: 256, max: 256,
interval: 64, interval: 64
data: new Array(256).fill(0).map((_, index) => index) },
series: [
{
xAxisIndex: 0,
yAxisIndex: 0,
type: 'scatter',
symbolSize: 2.5,
itemStyle: {
color: '#fff'
},
data: new Array(1256).fill(0).map(() => [parseInt(Math.random() * 256), parseInt(Math.random() * 256)])
},
{
type: 'line'
}
]
}
//3D Surface
const threeDSurfaceOption = {
visualMap: {
show: false,
dimension: 2,
min: 0,
max: 5,
inRange: ['#47C134', '#f00']
},
grid3D: {
axisLabel: {
color: '#C4E5A6'
},
axisPointer: {
show: false
},
axisLine: {
lineStyle: {
color: '#fff'
}
},
splitLine: {
lineStyle: {
color: '#fff'
}
}
},
xAxis3D: {
name: 'Beta Channel',
nameTextStyle: {
color: '#C4E5A6',
fontSize: 14
},
min: 0,
max: 256,
interval: 64
},
yAxis3D: {
name: 'Gamma Channel',
nameTextStyle: {
color: '#C4E5A6',
fontSize: 14
},
min: 0,
max: 256,
interval: 64
},
zAxis3D: {
name: 'Count',
nameTextStyle: {
color: '#C4E5A6',
fontSize: 14
},
max: 5
}, },
series: { series: {
type: 'scatter', type: 'surface',
symbolSize: 2, data: [
data: new Array(256).fill(0).map(() => [parseInt(Math.random() * 256), parseInt(Math.random() * 256)]) [64, 64, 0],
[66, 66, 0],
[66, 66, 0],
[65, 65, 4],
[128, 128, 0],
[130, 130, 0],
[130, 130, 0],
[129, 129, 4]
]
} }
} }
// 3D Scatter
const threeDScatterOption = {
grid3D: {
axisLabel: {
color: '#C4E5A6'
},
axisPointer: {
show: false
},
axisLine: {
lineStyle: {
color: '#fff'
}
},
splitLine: {
lineStyle: {
color: '#fff'
}
}
},
xAxis3D: {
name: 'Beta Channel',
nameTextStyle: {
color: '#C4E5A6',
fontSize: 14
},
min: 0,
max: 256,
interval: 64
},
yAxis3D: {
name: 'Gamma Channel',
nameTextStyle: {
color: '#C4E5A6',
fontSize: 14
},
min: 0,
max: 256,
interval: 64
},
zAxis3D: {
name: 'Count',
nameTextStyle: {
color: '#C4E5A6',
fontSize: 14
},
max: 6
},
series: {
type: 'scatter3D',
symbolSize: 2.5,
itemStyle: {
color: '#a2d092'
},
data: new Array(512)
.fill(0)
.map(() => [parseInt(Math.random() * 256), parseInt(Math.random() * 256), 4.5 + Math.random() * 0.1])
}
}
export default { export default {
components: { components: {
CustomChart CustomChart,
Custom3DChart
}, },
data() { data() {
this.buttons = buttons this.buttons = buttons
return { return {
active: 0, active: 1,
option twoDOption,
threeDSurfaceOption,
threeDScatterOption
} }
}, },
methods: { methods: {
@ -113,7 +274,9 @@ export default {
}, },
resize() { resize() {
this.$refs.chartRef.resize() this.$refs.chartRef && this.$refs.chartRef.resize()
this.$refs._3dSurfaceRef && this.$refs._3dSurfaceRef.resize()
this.$refs._3dScannerRef && this.$refs._3dScannerRef.resize()
} }
} }
} }
@ -152,7 +315,34 @@ export default {
} }
&-main { &-main {
height: calc(100% - 26px); height: calc(100% - 40px);
margin-top: 15px;
._2d-chart {
height: 100%;
display: flex;
.custom-chart {
width: calc(100% - 45px);
}
.bar {
width: 30px;
margin-left: 15px;
height: 100%;
color: #ade6ee;
padding-top: 5px;
padding-bottom: 38px;
text-align: center;
&-main {
display: inline-block;
width: 14px;
height: calc(100% - 42px);
background: linear-gradient(to bottom, #ff0000 0, #fff 100%);
}
}
}
} }
} }
</style> </style>

View File

@ -0,0 +1,65 @@
<template>
<a-menu class="spectra-list-in-menu">
<a-menu-item v-for="item in list" :key="item.id" @click="handleClick(item)">
<span class="checkbox">
<a-icon v-if="item.checked" type="check" style="color: #0de30d" />
</span>
<span class="name">{{ item.name }}</span>
<a-icon type="delete" @click.stop="handleRemove(item)" />
</a-menu-item>
</a-menu>
</template>
<script>
export default {
props: {
list: {
type: Array,
default: () => []
}
},
methods: {
handleClick(spectraItem) {
this.list.forEach(item => (item.checked = false))
spectraItem && (spectraItem.checked = true)
this.$emit('change', spectraItem)
this.$forceUpdate()
},
handleRemove(spectraItem) {
const index = this.list.findIndex(item => item == spectraItem)
this.list.splice(index, 1)
//
if (spectraItem.checked) {
if (index == 0) {
//
this.handleClick(this.list[0])
} else {
//
this.handleClick(this.list[index - 1])
}
}
this.$forceUpdate()
}
}
}
</script>
<style lang="less" scoped>
.spectra-list-in-menu {
.checkbox {
width: 14px;
height: 14px;
display: inline-block;
}
.name {
display: inline-block;
width: 300px;
margin: 0 5px;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: top;
}
}
</style>

View File

@ -12,7 +12,7 @@ import { cloneDeep } from 'lodash'
const initialOption = { const initialOption = {
grid: { grid: {
top: 25, top: 25,
right: 0, right: 12,
bottom: 40 bottom: 40
}, },
title: { title: {
@ -33,7 +33,9 @@ const initialOption = {
} }
}, },
xAxis: { xAxis: {
type: 'category', min: 0,
max: 256,
interval: 64,
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: 'rgb(119, 181, 213, 0.5)' color: 'rgb(119, 181, 213, 0.5)'
@ -57,10 +59,12 @@ const initialOption = {
fontSize: 14, fontSize: 14,
color: '#5b9cba' color: '#5b9cba'
}, },
nameGap: 25, nameGap: 25
data: new Array(256).fill(0).map((_, index) => index)
}, },
yAxis: { yAxis: {
min: 0,
max: 21099,
interval: 21000 / 4,
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
@ -84,7 +88,7 @@ const initialOption = {
symbol: 'none', symbol: 'none',
data: new Array(256) data: new Array(256)
.fill(0) .fill(0)
.map((_, index) => (Math.random() < 0.05 ? parseInt(Math.random() * 19644) : parseInt(Math.random() * 800))) .map((_, index) => [index, (Math.random() < 0.05 ? parseInt(Math.random() * 19644) : parseInt(Math.random() * 800))])
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<a-popover :placement="placement" overlayClassName="popover-with-icon"> <a-popover :placement="placement" overlayClassName="popover-with-icon" v-model="innerVisible">
<div class="pop-over-with-icon"> <div class="pop-over-with-icon">
<span class="text"> <span class="text">
<slot /> <slot />
@ -17,6 +17,25 @@ export default {
placement: { placement: {
type: String, type: String,
default: 'bottom' default: 'bottom'
},
value: {
type: Boolean
}
},
data() {
return {
innerVisible: false
}
},
watch: {
value: {
handler(val) {
this.innerVisible = val
},
immediate: true
},
innerVisible(val) {
this.$emit('input', val)
} }
} }
} }

View File

@ -1,14 +1,74 @@
<template> <template>
<div class="spectra"> <div class="spectra">
spectra <div
:class="'spectra-item' + (item.title == innerValue ? ' active' : '')"
v-for="(item, index) in list"
:key="index"
@click="handleClick(item)"
>
{{ item.title }}
</div>
</div> </div>
</template> </template>
<script> <script>
export default {} const list = [
{
title: 'Sample Data'
},
{
title: 'GasBg Data'
},
{
title: 'DetBg Data'
},
{
title: 'QC Data'
}
]
export default {
props: {
value: {
type: String,
required: true
}
},
data() {
this.list = list
return {}
},
methods: {
handleClick(item) {
this.innerValue = item.title
}
},
computed: {
innerValue: {
set(val) {
this.$emit('input', val)
},
get() {
return this.value
}
}
}
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.spectra { .spectra {
width: 159px;
max-height: 200px;
overflow: auto;
&-item {
padding: 4px 14px;
cursor: pointer;
&:hover,
&.active {
background-color: #055565;
}
}
} }
</style> </style>

View File

@ -2,15 +2,23 @@
<div class="spectrum-analysis"> <div class="spectrum-analysis">
<!-- 顶部操作栏 --> <!-- 顶部操作栏 -->
<div class="spectrum-analysis-operators"> <div class="spectrum-analysis-operators">
<a-dropdown class="spectrum-analysis-operators-item" v-for="operation in operations" :key="operation.title"> <a-dropdown
class="spectrum-analysis-operators-item"
overlayClassName="spectrum-analysis-operators-dropdown-overlay"
:overlay-style="operation.style"
v-for="operation in operations"
:key="operation.title"
>
<a-button type="primary">{{ operation.title }}</a-button> <a-button type="primary">{{ operation.title }}</a-button>
<template slot="overlay"> <div slot="overlay">
<a-menu> <template v-for="(child, index) in operation.children">
<a-menu-item v-for="child in operation.children" :key="child.title" @click="child.handler"> <component :is="child.type" :key="index" v-bind="child.attrs" v-on="child.on">
{{ child.title }} <component :is="item.type" v-for="item in child.children" :key="item.title" @click="item.handler">
</a-menu-item> {{ item.title }}
</a-menu> </component>
</template> </component>
</template>
</div>
</a-dropdown> </a-dropdown>
</div> </div>
<!-- 顶部操作栏结束 --> <!-- 顶部操作栏结束 -->
@ -46,9 +54,9 @@
<!-- beta-gamma 独有的二级交互栏 --> <!-- beta-gamma 独有的二级交互栏 -->
<template v-if="analysisType == ANALYZE_TYPE.BETA_GAMMA"> <template v-if="analysisType == ANALYZE_TYPE.BETA_GAMMA">
<pop-over-with-icon placement="bottomLeft" style="width: 159px"> <pop-over-with-icon placement="bottomLeft" style="width: 159px" v-model="spectraVisible">
Spectra Spectra
<spectra slot="content" /> <spectra slot="content" v-model="spectraType" @input="spectraVisible = false" />
</pop-over-with-icon> </pop-over-with-icon>
</template> </template>
<!-- beta-gamma 独有的二级交互栏结束 --> <!-- beta-gamma 独有的二级交互栏结束 -->
@ -74,6 +82,7 @@ import QcFlags from './components/sub-operators/QcFlags.vue'
import GammaAnalysis from './gamma-analysis.vue' import GammaAnalysis from './gamma-analysis.vue'
import BetaGammaAnalysis from './beta-gamma-analysis.vue' import BetaGammaAnalysis from './beta-gamma-analysis.vue'
import Spectra from './components/sub-operators/Spectra.vue' import Spectra from './components/sub-operators/Spectra.vue'
import SpectraListInMenu from './components/SpectraListInMenu.vue'
// //
const ANALYZE_TYPE = { const ANALYZE_TYPE = {
@ -90,24 +99,39 @@ export default {
GraphAssistance, GraphAssistance,
DetailedInfomation, DetailedInfomation,
NuclearLibrary, NuclearLibrary,
Spectra Spectra,
SpectraListInMenu
}, },
data() { data() {
this.ANALYZE_TYPE = ANALYZE_TYPE this.ANALYZE_TYPE = ANALYZE_TYPE
return { return {
analysisType: ANALYZE_TYPE.BETA_GAMMA // analysisType: ANALYZE_TYPE.BETA_GAMMA, //
spectraType: 'Sample Data',
spectraVisible: false,
spectraList: [
{ id: 1, name: 'AUX01 003-20151223 1855 S FULL 40183.7.PHD' },
{ id: 2, name: 'AUX02 003-20151223 1855 S FULL 40183.7.PHD' }
]
} }
}, },
methods: { methods: {
//
handleLoadFromDb() { handleLoadFromDb() {
console.log('%c [ handleLoadFromDb ]-46', 'font-size:13px; background:pink; color:#bf2c9f;') console.log('%c [ handleLoadFromDb ]-46', 'font-size:13px; background:pink; color:#bf2c9f;')
}, },
//
handleLoadFromFile() { handleLoadFromFile() {
console.log('%c [ handleLoadFromFile ]-46', 'font-size:13px; background:pink; color:#bf2c9f;') console.log('%c [ handleLoadFromFile ]-46', 'font-size:13px; background:pink; color:#bf2c9f;')
}, },
//
handleCleanAll() {
console.log('%c [ handleCleanAll ]-118', 'font-size:13px; background:pink; color:#bf2c9f;')
},
// peak info // peak info
handlePeakInfoChange(direction) { handlePeakInfoChange(direction) {
this.$refs.gammaAnalysisRef.moveMarkLine(direction) this.$refs.gammaAnalysisRef.moveMarkLine(direction)
@ -125,12 +149,46 @@ export default {
title: 'SAMPLE', title: 'SAMPLE',
children: [ children: [
{ {
title: 'Load From DB', type: 'a-menu',
handler: this.handleLoadFromDb children: [
{
type: 'a-menu-item',
title: 'Load From DB',
handler: this.handleLoadFromDb
},
{
type: 'a-menu-item',
title: 'Load From File',
handler: this.handleLoadFromFile
},
{
type: 'a-menu-item',
title: 'Clean All',
handler: this.handleCleanAll
}
]
}, },
{ {
title: 'Load From File', type: 'a-divider',
handler: this.handleLoadFromFile attrs: {
style: {
marginTop: '5px',
marginBottom: '5px',
display: this.spectraList.length ? '' : 'none'
}
}
},
{
type: 'SpectraListInMenu',
attrs: {
list: this.spectraList
},
on: {
change: event => {
console.log('%c [ event ]-187', 'font-size:13px; background:pink; color:#bf2c9f;', event)
console.log('%c [ ]-188', 'font-size:13px; background:pink; color:#bf2c9f;', this)
}
}
} }
] ]
}, },
@ -138,12 +196,21 @@ export default {
title: 'SAVE', title: 'SAVE',
children: [ children: [
{ {
title: 'Load From DB', type: 'a-menu',
handler: this.handleLoadFromDb children: [
}, {
{ title: 'Load From DB',
title: 'Load From File', handler: this.handleLoadFromDb
handler: this.handleLoadFromFile },
{
title: 'Load From File',
handler: this.handleLoadFromFile
},
{
title: 'Clean All',
handler: this.handleCleanAll
}
]
} }
] ]
}, },
@ -151,12 +218,21 @@ export default {
title: 'ANALYZE', title: 'ANALYZE',
children: [ children: [
{ {
title: 'Load From DB', type: 'a-menu',
handler: this.handleLoadFromDb children: [
}, {
{ title: 'Load From DB',
title: 'Load From File', handler: this.handleLoadFromDb
handler: this.handleLoadFromFile },
{
title: 'Load From File',
handler: this.handleLoadFromFile
},
{
title: 'Clean All',
handler: this.handleCleanAll
}
]
} }
] ]
}, },
@ -164,12 +240,21 @@ export default {
title: 'CALIBRATION', title: 'CALIBRATION',
children: [ children: [
{ {
title: 'Load From DB', type: 'a-menu',
handler: this.handleLoadFromDb children: [
}, {
{ title: 'Load From DB',
title: 'Load From File', handler: this.handleLoadFromDb
handler: this.handleLoadFromFile },
{
title: 'Load From File',
handler: this.handleLoadFromFile
},
{
title: 'Clean All',
handler: this.handleCleanAll
}
]
} }
] ]
}, },
@ -177,12 +262,21 @@ export default {
title: 'NUCLIDELIBRARY', title: 'NUCLIDELIBRARY',
children: [ children: [
{ {
title: 'Load From DB', type: 'a-menu',
handler: this.handleLoadFromDb children: [
}, {
{ title: 'Load From DB',
title: 'Load From File', handler: this.handleLoadFromDb
handler: this.handleLoadFromFile },
{
title: 'Load From File',
handler: this.handleLoadFromFile
},
{
title: 'Clean All',
handler: this.handleCleanAll
}
]
} }
] ]
}, },
@ -190,12 +284,21 @@ export default {
title: 'COMMENTS', title: 'COMMENTS',
children: [ children: [
{ {
title: 'Load From DB', type: 'a-menu',
handler: this.handleLoadFromDb children: [
}, {
{ title: 'Load From DB',
title: 'Load From File', handler: this.handleLoadFromDb
handler: this.handleLoadFromFile },
{
title: 'Load From File',
handler: this.handleLoadFromFile
},
{
title: 'Clean All',
handler: this.handleCleanAll
}
]
} }
] ]
}, },
@ -203,12 +306,21 @@ export default {
title: 'REPORTS', title: 'REPORTS',
children: [ children: [
{ {
title: 'Load From DB', type: 'a-menu',
handler: this.handleLoadFromDb children: [
}, {
{ title: 'Load From DB',
title: 'Load From File', handler: this.handleLoadFromDb
handler: this.handleLoadFromFile },
{
title: 'Load From File',
handler: this.handleLoadFromFile
},
{
title: 'Clean All',
handler: this.handleCleanAll
}
]
} }
] ]
}, },
@ -216,12 +328,21 @@ export default {
title: 'LOG', title: 'LOG',
children: [ children: [
{ {
title: 'Load From DB', type: 'a-menu',
handler: this.handleLoadFromDb children: [
}, {
{ title: 'Load From DB',
title: 'Load From File', handler: this.handleLoadFromDb
handler: this.handleLoadFromFile },
{
title: 'Load From File',
handler: this.handleLoadFromFile
},
{
title: 'Clean All',
handler: this.handleCleanAll
}
]
} }
] ]
}, },
@ -229,12 +350,21 @@ export default {
title: 'HELP', title: 'HELP',
children: [ children: [
{ {
title: 'Load From DB', type: 'a-menu',
handler: this.handleLoadFromDb children: [
}, {
{ title: 'Load From DB',
title: 'Load From File', handler: this.handleLoadFromDb
handler: this.handleLoadFromFile },
{
title: 'Load From File',
handler: this.handleLoadFromFile
},
{
title: 'Clean All',
handler: this.handleCleanAll
}
]
} }
] ]
} }
@ -343,3 +473,36 @@ export default {
// //
} }
</style> </style>
<style lang="less">
.spectrum-analysis-operators-dropdown-overlay {
background-color: #03353f;
.ant-menu {
background: transparent;
padding: 0;
position: relative;
border-right: 0;
&-item {
color: #fff;
font-family: Arial;
border: 0;
background-color: transparent !important;
padding: 4px 14px;
height: 30px;
line-height: 22px;
&:hover {
background-color: #055565 !important;
}
&-selected {
font-weight: normal;
}
&-disabled {
color: #476d74 !important;
&:hover {
background-color: transparent !important;
}
}
}
}
}
</style>