Merge branch 'dev-v2' into pr@dev-v2_dzz

This commit is contained in:
dataeaseShu 2023-10-25 10:24:15 +08:00
commit 9d527dc2eb
18 changed files with 152 additions and 115 deletions

View File

@ -6,24 +6,25 @@
<a href="https://github.com/dataease/dataease"><img src="https://img.shields.io/github/stars/dataease/dataease?color=%231890FF&style=flat-square" alt="Stars"></a>
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2F1dataease%2Fdataease?ref=badge_shield"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdataease%2Fdataease.svg?type=shield" alt="FOSSA Status"></a>
</p>
|说明|
|------------------|
|此分支为 DataEase v2 版本的开发分支。DataEase v2 正在快速迭代中,如是在生产环境部署 DataEase建议使用 v1.18.* 的最新稳定版本。|
<hr/>
## 什么是 DataEase
DataEase 是开源的数据可视化分析工具帮助用户快速分析数据并洞察业务趋势从而实现业务的改进与优化。DataEase 支持丰富的数据源连接,能够通过拖拉拽方式快速制作图表,并可以方便的与他人分享。
**DataEase 的功能包括**
**DataEase 的工作原理**
- 图表展示:支持 PC 端、移动端、大屏及嵌入式使用场景;
- 图表制作:支持丰富的图表类型、支持拖拉拽方式快速制作仪表板;
- 数据引擎:基于 Apache Calcite实现统一的 SQL 解析、验证、优化和执行;
- 数据连接:支持数据仓库/数据湖、OLAP 数据库、OLTP 数据库、Excel 数据文件、API 等各种数据源。
![image](https://github.com/dataease/dataease/assets/41712985/68d46fac-985e-4d1d-8548-2baadf9cd2e8)
**DataEase 的优势:**
- 开源开放:零门槛,线上快速获取和安装;快速获取用户反馈、按月发布新版本
- 开源开放:零门槛,线上快速获取和安装,按月迭代
- 简单易用:极易上手,通过鼠标点击和拖拽即可完成分析;
- 全场景支持:多平台支持、多种嵌入式方案支持;
- 全场景支持:多平台安装和多样化嵌入支持;
- 安全分享:支持多种数据分享方式,确保数据安全。
**DataEase 支持的数据源:**
@ -39,30 +40,11 @@ DataEase 是开源的数据可视化分析工具,帮助用户快速分析数
<img src="https://dataease.io/images/dataSource/mongodb.jpg" alt="mongodb" border="0" width="155" height="107"/>
<img src="https://dataease.io/images/dataSource/redshift.jpg" alt="redshift" border="0" width="155" height="107"/>
<img src="https://dataease.io/images/dataSource/DB2.jpg" alt="DB2" border="0" width="155" height="107"/>
<img src="https://dataease.io/images/dataSource/API.jpg" alt="API" border="0" width="155" height="107"/>
<img src="https://dataease.io/images/dataSource/TiDB.jpg" alt="TiDB" border="0" width="155" height="107"/>
<img src="https://dataease.io/images/dataSource/StarRocks.jpg" alt="StarRocks" border="0" width="155" height="107"/>
</p>
## 快速开始
**一键安装**
仅需两步快速安装 DataEase
1. 准备一台不小于 8 G内存的 64位 Linux 主机;
2. 以 root 用户执行如下命令一键安装 DataEase。
```sh
curl -sSL https://dataease.oss-cn-hangzhou.aliyuncs.com/quick_start.sh | bash
```
**学习资料**
- [在线文档](https://dataease.io/docs/)
- [社区论坛](https://bbs.fit2cloud.com/c/de/6)
## DataEase 的技术栈
**DataEase 的技术栈:**
- 前端:[Vue.js](https://vuejs.org/)、[Element](https://element.eleme.cn/)
- 图库:[AntV](https://antv.vision/zh)
@ -71,13 +53,12 @@ curl -sSL https://dataease.oss-cn-hangzhou.aliyuncs.com/quick_start.sh | bash
- 数据处理:[Apache Calcite](https://github.com/apache/calcite/)
- 基础设施:[Docker](https://www.docker.com/)
## Star History
## DataEase 快速入门
[![Star History Chart](https://api.star-history.com/svg?repos=dataease/dataease&type=Date)](https://star-history.com/#dataease/dataease&Date)
## FOSSA Status
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdataease%2Fdataease.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdataease%2Fdataease?ref=badge_large)
- 安装部署教程
- 快速入门视频
- 完整在线文档
- 中文论坛支持
## License

View File

@ -821,9 +821,11 @@ public class ChartDataManage {
return list;
}
String assistLine = (String) JsonUtil.toJSONString(senior.get("assistLine"));
List<ChartSeniorAssistDTO> assistLines = JsonUtil.parseList(assistLine, new TypeReference<>() {
});
var assistLineCfg = JsonUtil.parseObject((String) JsonUtil.toJSONString(senior.get("assistLineCfg")), ChartSeniorAssistCfgDTO.class);
if (null == assistLineCfg || !assistLineCfg.isEnable()) {
return list;
}
List<ChartSeniorAssistDTO> assistLines = assistLineCfg.getAssistLine();
if (ObjectUtils.isEmpty(assistLines)) {
return list;

View File

@ -9,7 +9,7 @@ declare interface ChartSenior {
/**
* 线
*/
assistLine: AssistLine[]
assistLineCfg: ChartAssistLineCfg
/**
*
*/
@ -61,6 +61,19 @@ declare interface ChartFunctionCfg {
/**
* 线
*/
declare interface ChartAssistLineCfg {
/**
*
*/
enable: boolean
/**
* 线
*/
assistLine: AssistLine[]
}
/**
* 线
*/
declare interface AssistLine {
/**
* 线
@ -100,6 +113,10 @@ declare interface AssistLine {
*
*/
declare interface ChartThreshold {
/**
*
*/
enable: boolean
/**
* 仪表盘阈值: x,y,z
*/

View File

@ -5,7 +5,7 @@ import ScrollCfg from '@/views/chart/components/editor/editor-senior/components/
import AssistLine from '@/views/chart/components/editor/editor-senior/components/AssistLine.vue'
import Threshold from '@/views/chart/components/editor/editor-senior/components/Threshold.vue'
import CollapseSwitchItem from '@/components/collapse-switch-item/src/CollapseSwitchItem.vue'
import { computed, PropType, ref, toRefs } from 'vue'
import { computed, PropType, ref, toRefs, watch } from 'vue'
import LinkJumpSet from '@/components/visualization/LinkJumpSet.vue'
import LinkageSet from '@/components/visualization/LinkageSet.vue'
import { canvasSave } from '@/utils/canvasUtils'
@ -15,6 +15,8 @@ import { updateLinkageActive } from '@/api/visualization/linkage'
import { includesAny } from '../util/StringUtils'
import { ElIcon, ElMessage } from 'element-plus-secondary'
import { storeToRefs } from 'pinia'
import { BASE_VIEW_CONFIG } from '../util/chart'
import { cloneDeep, defaultsDeep } from 'lodash-es'
const dvMainStore = dvMainStoreWithOut()
const { dvInfo } = storeToRefs(dvMainStore)
@ -70,7 +72,12 @@ const props = defineProps({
})
const { chart, themes, properties, propertyInnerAll } = toRefs(props)
watch(
() => chart.value?.senior,
() => {
chart.value.senior = defaultsDeep(chart.value?.senior || {}, cloneDeep(BASE_VIEW_CONFIG.senior))
}
)
const seniorCounts = computed(() => {
let linkageCount = 0
let jumpCount = 0
@ -187,11 +194,14 @@ const linkageActiveChange = () => {
/>
</el-collapse-item>
<el-collapse-item
<collapse-switch-item
:effect="themes"
v-if="showProperties('assist-line')"
name="analyse"
:title="t('chart.assist_line')"
:change-model="chart.senior.assistLineCfg"
v-if="showProperties('assist-line')"
v-model="chart.senior.assistLineCfg.enable"
name="analyse"
@modelChange="val => onAssistLineChange({ data: val })"
>
<assist-line
:chart="props.chart"
@ -200,13 +210,13 @@ const linkageActiveChange = () => {
:property-inner="propertyInnerAll['assist-line']"
@onAssistLineChange="onAssistLineChange"
/>
</el-collapse-item>
</collapse-switch-item>
<collapse-switch-item
v-if="showProperties('scroll-cfg')"
:effect="themes"
:title="t('chart.scroll_cfg')"
:change-model="chart.senior.scrollCfg"
v-if="showProperties('scroll-cfg')"
v-model="chart.senior.scrollCfg.open"
name="scroll"
@modelChange="onScrollCfgChange"
@ -219,11 +229,14 @@ const linkageActiveChange = () => {
/>
</collapse-switch-item>
<el-collapse-item
<collapse-switch-item
:effect="themes"
:title="t('chart.threshold')"
:change-model="chart.senior.threshold"
v-model="chart.senior.threshold.enable"
v-if="showProperties('threshold')"
name="threshold"
:title="t('chart.threshold')"
@modelChange="onThresholdChange"
>
<threshold
:themes="themes"
@ -231,7 +244,7 @@ const linkageActiveChange = () => {
:property-inner="propertyInnerAll['threshold']"
@onThresholdChange="onThresholdChange"
/>
</el-collapse-item>
</collapse-switch-item>
<collapse-switch-item
v-if="showProperties('linkage')"

View File

@ -3,7 +3,8 @@ import { onMounted, reactive, watch, computed, PropType } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { ElIcon, ElMessage } from 'element-plus-secondary'
import AssistLineEdit from '@/views/chart/components/editor/editor-senior/components/dialog/AssistLineEdit.vue'
import _ from 'lodash'
import { defaultsDeep, find } from 'lodash-es'
import { DEFAULT_ASSIST_LINE_CFG } from '../../util/chart'
const { t } = useI18n()
@ -11,7 +12,7 @@ const emit = defineEmits(['onAssistLineChange'])
const props = defineProps({
chart: {
type: Object,
type: Object as PropType<ChartObj>,
required: true
},
quotaData: {
@ -32,28 +33,26 @@ const quotaFields = computed<Array<any>>(() => {
})
const state = reactive({
assistLine: [],
assistLineCfg: {
enable: false,
assistLine: []
},
editLineDialog: false,
lineArr: [],
quotaFields: []
})
watch(
() => props.chart,
() => props.chart.senior.assistLineCfg,
() => {
init()
}
},
{ deep: true }
)
const changeAssistLine = () => {
let flag = false
const arr = state.assistLine.filter(ele => {
return ele.field === '1'
})
if (arr && arr.length > 0) {
flag = true
}
emit('onAssistLineChange', { data: state.assistLine, requestData: flag })
const flag = state.assistLineCfg.assistLine.findIndex(ele => ele.field === '1') !== -1
emit('onAssistLineChange', { data: state.assistLineCfg, requestData: flag })
}
const lineChange = val => {
@ -68,7 +67,6 @@ const closeEditLine = () => {
}
const changeLine = () => {
console.log(state.lineArr)
// check line config
for (let i = 0; i < state.lineArr.length; i++) {
const ele = state.lineArr[i]
@ -96,35 +94,29 @@ const changeLine = () => {
}
}
}
state.assistLine = JSON.parse(JSON.stringify(state.lineArr))
state.assistLineCfg.assistLine = JSON.parse(JSON.stringify(state.lineArr))
changeAssistLine()
closeEditLine()
}
function existField(line) {
return !!_.find(quotaFields.value, d => d.id === line.id)
return !!find(quotaFields.value, d => d.id === line.id)
}
const init = () => {
const chart = JSON.parse(JSON.stringify(props.chart))
if (chart.senior) {
let senior = null
if (Object.prototype.toString.call(chart.senior) === '[object Object]') {
senior = JSON.parse(JSON.stringify(chart.senior))
} else {
senior = JSON.parse(chart.senior)
}
if (senior.assistLine) {
for (let i = 0; i < senior.assistLine.length; i++) {
if (!senior.assistLine[i].fontSize) {
senior.assistLine[i].fontSize = '10'
const senior = chart.senior
if (senior.assistLineCfg?.assistLine) {
const assistLine = senior.assistLineCfg.assistLine
for (let i = 0; i < assistLine.length; i++) {
if (!assistLine[i].fontSize) {
assistLine[i].fontSize = 10
}
}
state.assistLine = senior.assistLine
} else {
state.assistLine = []
state.assistLineCfg = defaultsDeep(senior.assistLineCfg, DEFAULT_ASSIST_LINE_CFG)
}
state.lineArr = JSON.parse(JSON.stringify(state.assistLine))
state.lineArr = JSON.parse(JSON.stringify(state.assistLineCfg.assistLine))
}
}
@ -141,16 +133,17 @@ onMounted(() => {
<span
class="set-text-info"
:class="{ 'set-text-info-dark': themes === 'dark' }"
v-if="state.assistLine.length > 0"
v-if="state.assistLineCfg.assistLine.length > 0"
>
已设置
</span>
<el-button
class="circle-button font14"
:class="'label-' + props.themes"
:style="{ width: '24px', marginLeft: '6px' }"
:disabled="!state.assistLineCfg.enable"
class="circle-button font14"
text
size="small"
:style="{ width: '24px', marginLeft: '6px' }"
@click="editLine"
>
<template #icon>
@ -162,7 +155,7 @@ onMounted(() => {
</span>
</div>
<el-row v-for="(item, index) in state.assistLine" :key="index" class="line-style">
<el-row v-for="(item, index) in state.assistLineCfg.assistLine" :key="index" class="line-style">
<el-col :span="8">
<span :title="item.name">{{ item.name }}</span>
</el-col>
@ -199,7 +192,7 @@ onMounted(() => {
class="dialog-css"
>
<assist-line-edit
:line="state.assistLine"
:line="state.assistLineCfg.assistLine"
:quota-fields="quotaFields"
@onAssistLineChange="lineChange"
/>

View File

@ -7,12 +7,13 @@ import TableThresholdEdit from '@/views/chart/components/editor/editor-senior/co
import TextLabelThresholdEdit from '@/views/chart/components/editor/editor-senior/components/dialog/TextLabelThresholdEdit.vue'
import TextThresholdEdit from '@/views/chart/components/editor/editor-senior/components/dialog/TextThresholdEdit.vue'
import { fieldType } from '@/utils/attr'
import { defaultsDeep } from 'lodash-es'
const { t } = useI18n()
const props = defineProps({
chart: {
type: Object,
type: Object as PropType<ChartObj>,
required: true
},
themes: {
@ -28,14 +29,15 @@ const showProperty = prop => props.propertyInner?.includes(prop)
const emit = defineEmits(['onThresholdChange'])
watch(
() => props.chart,
() => props.chart.senior.threshold,
() => {
init()
}
},
{ deep: true }
)
const state = reactive({
thresholdForm: JSON.parse(JSON.stringify(DEFAULT_THRESHOLD)),
thresholdForm: {} as ChartThreshold,
editTextLabelThresholdDialog: false,
textThresholdArr: [],
editLabelThresholdDialog: false,
@ -47,14 +49,9 @@ const state = reactive({
const init = () => {
const chart = JSON.parse(JSON.stringify(props.chart))
if (chart.senior) {
let senior = null
if (Object.prototype.toString.call(chart.senior) === '[object Object]') {
senior = JSON.parse(JSON.stringify(chart.senior))
} else {
senior = JSON.parse(chart.senior)
}
const senior = chart.senior
if (senior.threshold) {
state.thresholdForm = senior.threshold
state.thresholdForm = defaultsDeep(senior.threshold, DEFAULT_THRESHOLD)
}
state.textThresholdArr = JSON.parse(JSON.stringify(state.thresholdForm.textLabelThreshold))
state.thresholdArr = JSON.parse(JSON.stringify(state.thresholdForm.labelThreshold))
@ -243,9 +240,10 @@ init()
<span>0,</span>
<el-input
:effect="themes"
:placeholder="t('chart.threshold_range')"
:disabled="!state.thresholdForm.enable"
v-model="state.thresholdForm.gaugeThreshold"
style="width: 100px; margin: 0 10px"
:placeholder="t('chart.threshold_range')"
size="small"
clearable
@change="gaugeThresholdChange"
@ -409,11 +407,12 @@ init()
</span>
<el-button
:title="t('chart.edit')"
class="circle-button"
:class="'label-' + props.themes"
:style="{ width: '24px', marginLeft: '6px' }"
:disabled="!state.thresholdForm.enable"
class="circle-button"
text
size="small"
:style="{ width: '24px', marginLeft: '6px' }"
@click="editTableThreshold"
>
<template #icon>

View File

@ -562,7 +562,7 @@ span {
.series-select-option {
display: flex;
align-items: center;
justify-content: start;
justify-content: flex-start;
padding: 0 11px;
}
</style>

View File

@ -814,7 +814,7 @@ onMounted(() => {
.series-select-option {
display: flex;
align-items: center;
justify-content: start;
justify-content: flex-start;
padding: 0 11px;
}
.m-divider {

View File

@ -863,12 +863,12 @@ onMounted(() => {
.series-select-option {
display: flex;
align-items: center;
justify-content: start;
justify-content: flex-start;
padding: 0 11px;
}
.invalid-field {
::v-deep(.ed-input__wrapper) {
:deep(.ed-input__wrapper) {
box-shadow: 0 0 0 1px rgb(245, 74, 69) inset !important;
}
}

View File

@ -666,7 +666,7 @@ const onBackgroundChange = val => {
}
const onAssistLineChange = val => {
view.value.senior.assistLine = val.data
view.value.senior.assistLineCfg = val.data
if (val.requestData) {
calcData(view.value)
} else {

View File

@ -604,7 +604,12 @@ export const DEFAULT_FUNCTION_CFG: ChartFunctionCfg = {
emptyDataStrategy: 'breakLine',
emptyDataFieldCtrl: []
}
export const DEFAULT_ASSIST_LINE_CFG: ChartAssistLineCfg = {
enable: false,
assistLine: []
}
export const DEFAULT_THRESHOLD: ChartThreshold = {
enable: false,
gaugeThreshold: '',
labelThreshold: [],
tableThreshold: [],
@ -1268,7 +1273,7 @@ export const BASE_VIEW_CONFIG = {
},
senior: {
functionCfg: DEFAULT_FUNCTION_CFG,
assistLine: [],
assistLineCfg: DEFAULT_ASSIST_LINE_CFG,
threshold: DEFAULT_THRESHOLD,
scrollCfg: DEFAULT_SCROLL
}

View File

@ -143,7 +143,7 @@ export class Gauge extends G2PlotChartView<GaugeOptions, G2Gauge> {
if (chart.senior) {
const senior = parseJson(chart.senior)
const threshold = senior.threshold ?? DEFAULT_THRESHOLD
if (threshold.gaugeThreshold) {
if (threshold.enable && threshold.gaugeThreshold) {
hasThreshold = true
const arr = threshold.gaugeThreshold.split(',')
for (let i = 0; i < arr.length; i++) {

View File

@ -534,7 +534,11 @@ export function getSlider(chart: Chart) {
export function getAnalyse(chart: Chart) {
const assistLine = []
const senior = parseJson(chart.senior)
if (senior.assistLine?.length > 0) {
if (!senior.assistLineCfg?.enable) {
return assistLine
}
const assistLineArr = senior.assistLineCfg.assistLine
if (assistLineArr?.length > 0) {
const customStyle = parseJson(chart.customStyle)
let yAxisPosition, axisFormatterCfg
if (customStyle.yAxis) {
@ -545,8 +549,8 @@ export function getAnalyse(chart: Chart) {
: DEFAULT_YAXIS_STYLE.axisLabelFormatter
}
const fixedLines = senior.assistLine.filter(ele => ele.field === '0')
const dynamicLineFields = senior.assistLine
const fixedLines = assistLineArr.filter(ele => ele.field === '0')
const dynamicLineFields = assistLineArr
.filter(ele => ele.field === '1')
.map(item => item.fieldId)
const quotaFields = _.filter(chart.yAxis, ele => ele.summary !== '' && ele.id !== '-1')
@ -589,7 +593,11 @@ export function getAnalyse(chart: Chart) {
export function getAnalyseHorizontal(chart: Chart) {
const assistLine = []
const senior = parseJson(chart.senior)
if (senior.assistLine?.length > 0) {
if (!senior.assistLineCfg?.enable) {
return assistLine
}
const assistLineArr = senior.assistLineCfg.assistLine
if (assistLineArr?.length > 0) {
const customStyle = parseJson(chart.customStyle)
let xAxisPosition, axisFormatterCfg
if (customStyle.xAxis) {
@ -600,8 +608,8 @@ export function getAnalyseHorizontal(chart: Chart) {
: DEFAULT_XAXIS_STYLE.axisLabelFormatter
}
const fixedLines = senior.assistLine.filter(ele => ele.field === '0')
const dynamicLineFields = senior.assistLine
const fixedLines = assistLineArr.filter(ele => ele.field === '0')
const dynamicLineFields = assistLineArr
.filter(ele => ele.field === '1')
.map(item => item.fieldId)
const quotaFields = _.filter(chart.yAxis, ele => ele.summary !== '' && ele.id !== '-1')

View File

@ -329,11 +329,15 @@ export function getCurrentField(valueFieldList: Axis[], field: ChartViewField) {
}
export function getConditions(chart: Chart) {
const { threshold } = parseJson(chart.senior)
if (!threshold.enable) {
return
}
const res = {
text: [],
background: []
}
const conditions = parseJson(chart.senior).threshold.tableThreshold ?? []
const conditions = threshold.tableThreshold ?? []
if (conditions?.length > 0) {
const { tableCell, basicStyle } = parseJson(chart.customAttr)

View File

@ -290,7 +290,7 @@ onBeforeUnmount(() => {
.canvas-content {
width: 100% !important;
height: 100% !important;
::v-deep(.g2-tooltip) {
:deep(.g2-tooltip) {
position: fixed !important;
}
}

View File

@ -18,8 +18,10 @@ import { useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache()
const eventCheck = e => {
if (e.key === 'panel-weight' && !compareStorage(e.oldValue, e.newValue)) {
const { resourceId } = window.DataEaseBi || router.currentRoute.value.query
check(wsCache.get('panel-weight'), resourceId)
const { resourceId, opt } = window.DataEaseBi || router.currentRoute.value.query
if (!(opt && opt === 'create')) {
check(wsCache.get('panel-weight'), resourceId)
}
}
}
const dvMainStore = dvMainStoreWithOut()

View File

@ -28,8 +28,10 @@ import { useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache()
const eventCheck = e => {
if (e.key === 'screen-weight' && !compareStorage(e.oldValue, e.newValue)) {
const { dvId } = window.DataEaseBi || router.currentRoute.value.query
check(wsCache.get('screen-weight'), dvId)
const { dvId, opt } = window.DataEaseBi || router.currentRoute.value.query
if (!(opt && opt === 'create')) {
check(wsCache.get('screen-weight'), dvId)
}
}
}
const mainCanvasCoreRef = ref(null)

View File

@ -0,0 +1,11 @@
package io.dataease.api.chart.dto;
import lombok.Data;
import java.util.List;
@Data
public class ChartSeniorAssistCfgDTO {
private boolean enable;
private List<ChartSeniorAssistDTO> assistLine;
}