dataease/frontend/src/views/panel/panel.js

78 lines
2.8 KiB
JavaScript
Raw Normal View History

2021-06-24 14:43:52 +08:00
// eslint-disable-next-line no-unused-vars
2021-06-22 14:14:31 +08:00
import { BASE_CHART, BASE_CHART_STRING } from '@/views/chart/chart/chart'
2021-05-07 19:20:47 +08:00
import { deepCopy } from '@/components/canvas/utils/utils'
2021-05-05 22:14:23 +08:00
export const DEFAULT_PANEL_STYLE = {
color: '#ffffff',
2021-05-05 22:14:23 +08:00
imageUrl: null,
backgroundType: 'image',
gap: 'yes',
resultMode: 'all', // 视图结果显示模式 all 视图 custom 仪表板自定义
resultCount: 1000 // 视图结果显示条数
2021-05-05 22:14:23 +08:00
}
2021-06-22 14:14:31 +08:00
export const CANVAS_STYLE = {
width: 1600,
height: 900,
2021-05-05 22:14:23 +08:00
scale: 100,
scaleWidth: 100,
scaleHeight: 100,
selfAdaption: true,
auxiliaryMatrix: true,
2021-05-05 22:14:23 +08:00
openCommonStyle: true,
2021-09-23 17:00:13 +08:00
panel: DEFAULT_PANEL_STYLE,
2021-11-03 17:44:20 +08:00
refreshViewLoading: true, // 仪表板视图loading提示
refreshUnit: 'minute', // 仪表板刷新时间带外 默认 分钟
refreshTime: 5 // 仪表板刷新时间 默认5分钟
2021-06-22 14:14:31 +08:00
}
export const DEFAULT_COMMON_CANVAS_STYLE_STRING = {
...CANVAS_STYLE,
chart: BASE_CHART_STRING
}
2021-05-07 19:20:47 +08:00
export function chartTransStr2Object(targetIn, copy) {
const target = copy === 'Y' ? deepCopy(targetIn) : targetIn
if (target.chart) {
if (target.chart.xaxis && typeof target.chart.xaxis === 'string') {
target.chart.xaxis = JSON.parse(target.chart.xaxis)
}
if (target.chart.yaxis && typeof target.chart.yaxis === 'string') {
target.chart.yaxis = JSON.parse(target.chart.yaxis)
}
if (target.chart.customAttr && typeof target.chart.customAttr === 'string') {
target.chart.customAttr = JSON.parse(target.chart.customAttr)
}
if (target.chart.customStyle && typeof target.chart.customStyle === 'string') {
target.chart.customStyle = JSON.parse(target.chart.customStyle)
}
if (target.chart.customFilter && typeof target.chart.customFilter === 'string') {
target.chart.customFilter = JSON.parse(target.chart.customFilter)
}
}
return target
}
export function chartTransObject2Str(targetIn, deepCopy) {
2021-06-24 14:43:52 +08:00
// eslint-disable-next-line no-undef
2021-05-07 19:20:47 +08:00
const target = copy === 'Y' ? deepCopy(targetIn) : targetIn
if (target.chart) {
if (target.chart.xaxis && typeof target.chart.xaxis !== 'string') {
target.chart.xaxis = JSON.stringify(target.chart.xaxis)
}
if (target.chart.yaxis && typeof target.chart.yaxis !== 'string') {
target.chart.yaxis = JSON.stringify(target.chart.yaxis)
}
if (target.chart.customAttr && typeof target.chart.customAttr !== 'string') {
target.chart.customAttr = JSON.stringify(target.chart.customAttr)
}
if (target.chart.customStyle && typeof target.chart.customStyle !== 'string') {
target.chart.customStyle = JSON.stringify(target.chart.customStyle)
}
if (target.chart.customFilter && typeof target.chart.customFilter !== 'string') {
target.chart.customFilter = JSON.stringify(target.chart.customFilter)
}
}
return target
}