feat: 柱状图折线图添加网格配置

This commit is contained in:
蒋承 2022-10-14 16:46:41 +08:00
parent 5a981109de
commit 3cb4dbb12b
8 changed files with 92 additions and 20 deletions

View File

@ -210,6 +210,26 @@
</setting-item-box>
</collapse-item>
<collapse-item v-if="grid" name="网格">
<template #header>
<n-switch v-model:value="grid.show" size="small"></n-switch>
</template>
<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.left" size="small"></n-input>
</setting-item>
<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.left" size="small"></n-input>
</setting-item>
</setting-item-box>
</collapse-item>
<collapse-item v-if="visualMap" name="视觉映射">
<template #header>
<n-switch v-model:value="visualMap.show" size="small"></n-switch>
@ -289,6 +309,10 @@ const legend = computed(() => {
return props.optionData.legend
})
const grid = computed(() => {
return props.optionData.grid
})
const visualMap = computed(() => {
return props.optionData.visualMap
})

View File

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

View File

@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis']
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
export const seriesItem = {
type: 'bar',
barWidth: null,
@ -31,6 +31,13 @@ export const option = {
legend: {
show: true
},
grid: {
show: false,
left: '10%',
top: '60',
right: '10%',
bottom: '60'
},
xAxis: {
show: true,
type: 'value'

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis']
export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
export const option = {
tooltip: {
@ -17,6 +17,13 @@ export const option = {
legend: {
show: true
},
grid: {
show: false,
left: '10%',
top: '60',
right: '10%',
bottom: '60'
},
xAxis: {
show: true,
type: 'category'

View File

@ -88,5 +88,12 @@
"textStyle": {
"color": "#B9B8CE"
}
},
"grid": {
"show": false,
"left": "10%",
"top": "60",
"right": "10%",
"bottom": "60"
}
}