fix: 新增图表居中拖拽

This commit is contained in:
MTrun
2022-01-27 23:16:51 +08:00
parent e8999a7fdf
commit dc7db58a8e
9 changed files with 83 additions and 34 deletions
@@ -1,10 +1,15 @@
import { getUUID } from '@/utils'
import { BarCommonConfig } from './index'
export const chartSize = {
w: 500,
h: 300
}
export default class Config {
private id: string = getUUID()
private key: string = BarCommonConfig.key
public attr = { x: 0, y: 0, w: 500, h: 300 }
public attr = { x: 0, y: 0, ...chartSize }
// 图表配置项
public config = {
@@ -17,21 +22,21 @@ export default class Config {
},
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value',
type: 'value'
},
series: [
{
data: [120, 200, 150, 80, 70, 110, 130],
type: 'bar',
},
],
type: 'bar'
}
]
}
// 设置坐标
public setPosition(x: number, y: number):void {
public setPosition(x: number, y: number): void {
this.attr.x = x
this.attr.y = y
}
@@ -2,6 +2,7 @@ import BarCommon from './index.vue'
import image from '@/assets/images/chart/charts/bar_x.png'
import { ConfigType, PackagesCategoryEnum } from '@/packages/index.d'
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
import { chartSize } from './config'
export const BarCommonConfig: ConfigType = {
key: 'VBarCommon',
@@ -10,5 +11,6 @@ export const BarCommonConfig: ConfigType = {
categoryName: ChatCategoryEnumName.BAR,
package: PackagesCategoryEnum.CHARTS,
node: BarCommon,
image: image
image: image,
chartData: { chartSize }
}
+8 -2
View File
@@ -7,6 +7,12 @@ export type ConfigType = {
category: string
categoryName: string
package: string
chartData: {
chartSize: {
w: number
h: number
}
}
node: Component
image: string | (() => Promise<typeof import('*.png')>)
[T: string]: unknown
@@ -16,14 +22,14 @@ export enum PackagesCategoryEnum {
CHARTS = 'Charts',
TABLES = 'Tables',
INFORMATION = 'Informations',
DECORATES = 'Decorates',
DECORATES = 'Decorates'
}
export enum PackagesCategoryName {
CHARTS = '图表',
TABLES = '表格',
INFORMATION = '信息',
DECORATES = '小组件',
DECORATES = '小组件'
}
export type PackagesType = {