Merge branch 'dev' into dev-commet

This commit is contained in:
tnt group 2022-10-15 18:37:12 +08:00
commit af50a00111
12 changed files with 94 additions and 76 deletions

View File

@ -21,6 +21,23 @@
</setting-item-box> </setting-item-box>
</collapse-item> </collapse-item>
<collapse-item v-if="grid" name="容器">
<setting-item-box name="距离">
<setting-item name="左侧距离">
<n-input v-model:value="grid.left" size="small"></n-input>
</setting-item>
<setting-item name="右侧距离">
<n-input v-model:value="grid.right" size="small"></n-input>
</setting-item>
<setting-item name="上侧距离">
<n-input v-model:value="grid.top" size="small"></n-input>
</setting-item>
<setting-item name="下侧距离">
<n-input v-model:value="grid.bottom" size="small"></n-input>
</setting-item>
</setting-item-box>
</collapse-item>
<collapse-item v-if="xAxis" name="X轴"> <collapse-item v-if="xAxis" name="X轴">
<template #header> <template #header>
<n-switch v-model:value="xAxis.show" size="small"></n-switch> <n-switch v-model:value="xAxis.show" size="small"></n-switch>
@ -51,6 +68,9 @@
<setting-item name="大小"> <setting-item name="大小">
<n-input-number v-model:value="xAxis.axisLabel.fontSize" :min="8" size="small"></n-input-number> <n-input-number v-model:value="xAxis.axisLabel.fontSize" :min="8" size="small"></n-input-number>
</setting-item> </setting-item>
<setting-item name="偏移量">
<n-input-number v-model:value="xAxis.axisLabel.rotate" :min="-90" :max="90" size="small"></n-input-number>
</setting-item>
</setting-item-box> </setting-item-box>
<setting-item-box name="轴线"> <setting-item-box name="轴线">
<setting-item name="展示"> <setting-item name="展示">
@ -140,6 +160,9 @@
<setting-item name="大小"> <setting-item name="大小">
<n-input-number v-model:value="yAxis.axisLabel.fontSize" :min="8" size="small"></n-input-number> <n-input-number v-model:value="yAxis.axisLabel.fontSize" :min="8" size="small"></n-input-number>
</setting-item> </setting-item>
<setting-item name="偏移量">
<n-input-number v-model:value="yAxis.axisLabel.rotate" :min="-90" :max="90" size="small"></n-input-number>
</setting-item>
</setting-item-box> </setting-item-box>
<setting-item-box name="轴线"> <setting-item-box name="轴线">
<setting-item name="展示"> <setting-item name="展示">
@ -289,6 +312,10 @@ const legend = computed(() => {
return props.optionData.legend return props.optionData.legend
}) })
const grid = computed(() => {
return props.optionData.grid
})
const visualMap = computed(() => { const visualMap = computed(() => {
return props.optionData.visualMap return props.optionData.visualMap
}) })

View File

@ -4,15 +4,15 @@ import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json' import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis'] export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
export const seriesItem = { export const seriesItem = {
type: 'bar', type: 'bar',
barWidth: 15, barWidth: 15,
label:{ label: {
show: true, show: true,
position: 'top', position: 'top',
color: "#fff", color: '#fff',
fontSize: 12, fontSize: 12
}, },
itemStyle: { itemStyle: {
color: null, color: null,
@ -28,10 +28,7 @@ export const option = {
type: 'shadow' type: 'shadow'
} }
}, },
legend: { xAxis: {
show: true
},
xAxis: {
show: true, show: true,
type: 'category' type: 'category'
}, },

View File

@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json' import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis'] export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
export const seriesItem = { export const seriesItem = {
type: 'bar', type: 'bar',
barWidth: null, barWidth: null,
@ -28,9 +28,6 @@ export const option = {
type: 'shadow' type: 'shadow'
} }
}, },
legend: {
show: true
},
xAxis: { xAxis: {
show: true, show: true,
type: 'value' type: 'value'

View File

@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index' import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import dataJson from './data.json' import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis'] export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
export const seriesItem = { export const seriesItem = {
type: 'line', type: 'line',
label: { label: {
@ -21,7 +21,7 @@ export const seriesItem = {
lineStyle: { lineStyle: {
type: 'solid', type: 'solid',
width: 3, width: 3,
color: null, color: null
} }
} }
@ -33,9 +33,6 @@ export const option = {
type: 'line' type: 'line'
} }
}, },
legend: {
show: true
},
xAxis: { xAxis: {
show: true, show: true,
type: 'category' type: 'category'

View File

@ -5,7 +5,7 @@ import { graphic } from 'echarts/core'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index' import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import dataJson from './data.json' import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis'] export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
const options = { const options = {
tooltip: { tooltip: {
@ -15,12 +15,9 @@ const options = {
type: 'line' type: 'line'
} }
}, },
legend: {
show: true
},
xAxis: { xAxis: {
show: true, show: true,
type: 'category', type: 'category'
}, },
yAxis: { yAxis: {
show: true, show: true,
@ -32,11 +29,11 @@ const options = {
type: 'line', type: 'line',
smooth: false, smooth: false,
symbolSize: 5, //设定实心点的大小 symbolSize: 5, //设定实心点的大小
label:{ label: {
show: true, show: true,
position: 'top', position: 'top',
color: "#fff", color: '#fff',
fontSize: 12, fontSize: 12
}, },
lineStyle: { lineStyle: {
type: 'solid', type: 'solid',
@ -59,8 +56,7 @@ const options = {
] ]
} }
export default class Config extends PublicConfigClass export default class Config extends PublicConfigClass implements CreateComponentType {
implements CreateComponentType {
public key: string = LineGradientSingleConfig.key public key: string = LineGradientSingleConfig.key
public chartConfig = LineGradientSingleConfig public chartConfig = LineGradientSingleConfig
// 图表配置项 // 图表配置项

View File

@ -5,12 +5,9 @@ import { graphic } from 'echarts/core'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index' import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import dataJson from './data.json' import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis'] export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
const option = { const option = {
legend: {
show: true
},
tooltip: { tooltip: {
show: true, show: true,
trigger: 'axis', trigger: 'axis',

View File

@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index' import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import dataJson from './data.json' import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis'] export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
export const option = { export const option = {
tooltip: { tooltip: {
@ -14,9 +14,6 @@ export const option = {
type: 'line' type: 'line'
} }
}, },
legend: {
show: true
},
xAxis: { xAxis: {
show: true, show: true,
type: 'category' type: 'category'

View File

@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
import dataJson from './data.json' import dataJson from './data.json'
export const includes = ['xAxis', 'yAxis'] export const includes = ['xAxis', 'yAxis', 'grid']
export const option = { export const option = {
dataset: { ...dataJson }, dataset: { ...dataJson },

View File

@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json' import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis'] export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
export const seriesItem = { export const seriesItem = {
type: 'scatter', type: 'scatter',

View File

@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json' import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis'] export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
export const option = { export const option = {
dataset: dataJson, dataset: dataJson,

View File

@ -22,7 +22,8 @@
"axisLabel": { "axisLabel": {
"show": true, "show": true,
"fontSize": 12, "fontSize": 12,
"color": "#B9B8CE" "color": "#B9B8CE",
"rotate": 0
}, },
"position": "bottom", "position": "bottom",
"axisLine": { "axisLine": {
@ -58,7 +59,8 @@
"axisLabel": { "axisLabel": {
"show": true, "show": true,
"fontSize": 12, "fontSize": 12,
"color": "#B9B8CE" "color": "#B9B8CE",
"rotate": 0
}, },
"position": "left", "position": "left",
"axisLine": { "axisLine": {
@ -88,5 +90,12 @@
"textStyle": { "textStyle": {
"color": "#B9B8CE" "color": "#B9B8CE"
} }
},
"grid": {
"show": false,
"left": "10%",
"top": "60",
"right": "10%",
"bottom": "60"
} }
} }

View File

@ -18,7 +18,7 @@ const componentMerge = (object: any, sources: any, notComponent = false) => {
if (notComponent) return merge(object, sources) if (notComponent) return merge(object, sources)
// 组件排除 options // 组件排除 options
const option = sources.option const option = sources.option
if(!option) return merge(object, sources) if (!option) return merge(object, sources)
// 为 undefined 的 sources 来源对象属性将被跳过详见 https://www.lodashjs.com/docs/lodash.merge // 为 undefined 的 sources 来源对象属性将被跳过详见 https://www.lodashjs.com/docs/lodash.merge
sources.option = undefined sources.option = undefined
@ -66,12 +66,8 @@ export const useSync = () => {
intComponent(e as CreateComponentType) intComponent(e as CreateComponentType)
} }
}) })
// 数据赋值
for (const key in projectData) { // 创建函数-重新创建是为了处理类种方法消失的问题
// 组件
if (key === ChartEditStoreEnum.COMPONENT_LIST) {
for (const comItem of projectData[key]) {
// 重新创建是为了处理类种方法消失的问题
const create = async ( const create = async (
_componentInstance: CreateComponentType, _componentInstance: CreateComponentType,
callBack?: (componentInstance: CreateComponentType) => void callBack?: (componentInstance: CreateComponentType) => void
@ -97,6 +93,11 @@ export const useSync = () => {
} }
} }
// 数据赋值
for (const key in projectData) {
// 组件
if (key === ChartEditStoreEnum.COMPONENT_LIST) {
for (const comItem of projectData[key]) {
if (comItem.isGroup) { if (comItem.isGroup) {
// 创建分组 // 创建分组
let groupClass = new PublicGroupConfigClass() let groupClass = new PublicGroupConfigClass()
@ -106,19 +107,19 @@ export const useSync = () => {
groupClass = componentMerge(groupClass, comItem) groupClass = componentMerge(groupClass, comItem)
} }
// 注册子应用 // 异步注册子应用
const targetList: CreateComponentType[] = [] const targetList: CreateComponentType[] = []
;(comItem as CreateComponentGroupType).groupList.forEach(groupItem => { for (const groupItem of (comItem as CreateComponentGroupType).groupList) {
create(groupItem, e => { await create(groupItem, e => {
targetList.push(e) targetList.push(e)
}) })
}) }
groupClass.groupList = targetList groupClass.groupList = targetList
// 分组插入到列表 // 分组插入到列表
chartEditStore.addComponentList(groupClass, false, true) chartEditStore.addComponentList(groupClass, false, true)
} else { } else {
create(comItem as CreateComponentType) await create(comItem as CreateComponentType)
} }
} }
} else { } else {