diff --git a/nezha-fronted/src/components/charts/charLlist和chart-list-group的区别.md b/nezha-fronted/src/components/charts/charLlist和chart-list-group的区别.md new file mode 100644 index 000000000..a61c3b6af --- /dev/null +++ b/nezha-fronted/src/components/charts/charLlist和chart-list-group的区别.md @@ -0,0 +1,10 @@ + +``` bash +# list +向下传递 index + +# groupList +是 chart type=’group‘ 的子组件 +向下传递的是处理过后的 chartIndex +``` + diff --git a/nezha-fronted/src/components/charts/chart-bar-statistics.vue b/nezha-fronted/src/components/charts/chart-bar-statistics.vue new file mode 100644 index 000000000..38562a419 --- /dev/null +++ b/nezha-fronted/src/components/charts/chart-bar-statistics.vue @@ -0,0 +1,766 @@ + + + + diff --git a/nezha-fronted/src/components/charts/chart-group.vue b/nezha-fronted/src/components/charts/chart-group.vue index 3ca56ed75..7d86a2e68 100644 --- a/nezha-fronted/src/components/charts/chart-group.vue +++ b/nezha-fronted/src/components/charts/chart-group.vue @@ -16,16 +16,16 @@ {{chartData.name}} - {{dataList.length}} panel collapse + ({{chartData.children.length}} charts) - - - + + + - + @@ -214,9 +214,11 @@ export default { this.$emit('on-edit-chart-block', this.data.id) }, editGroupItem (chart) { + chart.isGroup = true this.$emit('on-edit-group-chart', chart) }, duplicateGroupItem (chart) { + chart.isGroup = true this.$emit('on-duplicate-group-chart', chart) }, // 删除该图表 @@ -224,10 +226,13 @@ export default { this.dropdownMenuShow = false this.$emit('on-remove-chart-block', this.data.id) }, - // 删除该图表 + // 删除group 下的该图表 removeChartGroup (chart) { this.$emit('on-remove-group-chart', chart) }, + addGroupItemChart () { + this.$emit('on-add-group-item-chart', this.data.id) + }, clickos () { this.dropdownMenuShow = false }, @@ -314,4 +319,8 @@ export default { -90deg ); } + .collapse-content{ + font-size: 12px; + color: #999999; + } diff --git a/nezha-fronted/src/components/charts/chart-list-group.vue b/nezha-fronted/src/components/charts/chart-list-group.vue index 54cc1cc6b..a81965f7a 100644 --- a/nezha-fronted/src/components/charts/chart-list-group.vue +++ b/nezha-fronted/src/components/charts/chart-list-group.vue @@ -67,7 +67,7 @@ }" style="width: 100%;height: 100%">
- - + { this.dataList.forEach((item, index) => { - if (item.type === 'text') { - console.log(item) - } - console.log(item, index, this.filter) this.getChartData(item, index, this.filter) this.setChartSize(item, index) }) @@ -238,7 +247,6 @@ export default { filterParent: { immediate: true, handler (n) { - console.log(n) this.filter = { ...n } this.pagePanelId = this.filter.panelId } @@ -626,7 +634,6 @@ export default { this.dataTotalList = [...chartListTmp] this.dataList = [...this.dataTotalList] - console.log(this.dataList) this.dataList.push({ ...this.dataList[0], group: { @@ -886,6 +893,26 @@ export default { data: [] } } + if (chartInfo.type === 'bar' && chartInfo.param.statistics && chartInfo.param.statistics !== 'null') { + pieSeries = { + type: 'bar', + // roseType: 'radius', + itemStyle: { + borderRadius: 5, + borderColor: '#fff', + borderWidth: 1 + }, + label: { + show: false + }, + emphasis: { + label: { + show: false + } + }, + data: [] + } + } res.forEach((response, innerPos) => { if (response.status === 'success') { errorMsg = '' @@ -1011,6 +1038,8 @@ export default { }) if (chartInfo.type === 'pie') { pieSeries.data.push({ value: bus.getSingleStatRlt(chartInfo.param.statistics, seriesItem.theData.data), name: host + '-' + chartItem.elements[innerPos].id + '-' + resIndex }) + } else if (chartInfo.type === 'bar' && chartInfo.param.statistics && chartInfo.param.statistics !== 'null') { + pieSeries.data.push({ value: bus.getSingleStatRlt(chartInfo.param.statistics, seriesItem.theData.data), name: host + '-' + chartItem.elements[innerPos].id + '-' + resIndex }) } else { series.push(seriesItem.theData) seriesItem = null @@ -1048,6 +1077,9 @@ export default { if (chartInfo.type === 'pie') { series.push(pieSeries) } + if (chartInfo.type === 'bar' && chartInfo.param.statistics && chartInfo.param.statistics !== 'null') { + series.push(pieSeries) + } const chartData = { chartItem: chartItem, series: series, @@ -1475,7 +1507,6 @@ export default { if (this.additionalInfo) { this.$set(chartInfo, 'param', { endpointId: this.additionalInfo.id }) } - console.log(this.$refs['editChart' + chartInfo.id]) this.$refs['editChart' + chartInfo.id][0].getAlertList(filterType) }, getAlertRuleChartData (chartInfo) { diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index bb785e3f3..b8bc02b8d 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -67,7 +67,7 @@ handle: '.chart-title' }" >
- + { item.isLoaded = false }) - - response.data.list.forEach((item, index) => { // 把chart放入对应的group - if (item.type === 'group') { - item.children = response.data.list.filter(item1 => item1.groupId === item.id) - } - }) - response.data.list = response.data.list.filter((item) => item.groupId === -1 || !item.groupId) // 处理外层存在的groupItem - console.log(response.data.list) + // response.data.list = response.data.list.filter((item) => item.groupId === -1 || !item.groupId) // 处理外层存在的groupItem + // console.log(response.data.list) if (response.data.list) { this.dataTotalListBak = response.data.list } else { @@ -658,19 +667,6 @@ export default { this.dataTotalList = [...chartListTmp] this.dataList = [...this.dataTotalList] - console.log(this.dataList) - // this.dataList.push({ - // ...this.dataList[0], - // group: { - // id: 1, - // name: 'chart group' - // }, - // type: 'group', - // span: 12, - // height: 600, - // id: 999999, - // children: [...this.dataList] - // }) let addGroupIndex = 0 this.dataList.forEach((item) => { if (item.type === 'group') { @@ -932,6 +928,26 @@ export default { data: [] } } + if (chartInfo.type === 'bar' && chartInfo.param.statistics && chartInfo.param.statistics !== 'null') { + pieSeries = { + type: 'bar', + // roseType: 'radius', + itemStyle: { + borderRadius: 5, + borderColor: '#fff', + borderWidth: 1 + }, + label: { + show: false + }, + emphasis: { + label: { + show: false + } + }, + data: [] + } + } res.forEach((response, innerPos) => { if (response.status === 'success') { errorMsg = '' @@ -1022,7 +1038,6 @@ export default { host = chartItem.elements[innerPos].expression } // 处理legend别名 - console.log(chartItem.id) let alias = this.$refs['editChart' + chartItem.id][0].dealLegendAlias(host, chartItem.elements[innerPos].legend) if (!alias || alias === '') { alias = host @@ -1058,6 +1073,8 @@ export default { }) if (chartInfo.type === 'pie') { pieSeries.data.push({ value: bus.getSingleStatRlt(chartInfo.param.statistics, seriesItem.theData.data), name: host + '-' + chartItem.elements[innerPos].id + '-' + resIndex }) + } else if (chartInfo.type === 'bar' && chartInfo.param.statistics && chartInfo.param.statistics !== 'null') { + pieSeries.data.push({ value: bus.getSingleStatRlt(chartInfo.param.statistics, seriesItem.theData.data), name: host + '-' + chartItem.elements[innerPos].id + '-' + resIndex }) } else { series.push(seriesItem.theData) seriesItem = null @@ -1095,6 +1112,9 @@ export default { if (chartInfo.type === 'pie') { series.push(pieSeries) } + if (chartInfo.type === 'bar' && chartInfo.param.statistics && chartInfo.param.statistics !== 'null') { + series.push(pieSeries) + } const chartData = { chartItem: chartItem, series: series, @@ -1184,6 +1204,9 @@ export default { return Number('-' + (txtWidth + 5)) } }, + addGroupItem (id) { + this.$emit('on-add-group-item-chart', id) + }, modelStaticData (chartInfo, filterType) { const series = [] const legend = [] @@ -1596,6 +1619,7 @@ export default { // 删除图表 removeChart (chartId) { // from 区分从哪里点击的删除 1.从图表面板 2.从编辑框 const chart = this.dataList.find(item => item.id === chartId) + console.log(chart) if (chart) { this.$emit('on-remove-chart', chart) } diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 045cbd7d5..8177fef82 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -762,10 +762,10 @@ export default { sum += self.numberWithEConvent(val) str += '
' str += `
${tip ? (tip.alias ? tip.alias : tip.name) : item.seriesName}
` - str += '
' + str += '
' str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(val, null, -1, oldDot) if (previousItem) { - str += '' + str += '' let previousval = parseFloat(Number(previousItem.data[1]).toFixed(2)) if (previousval === 0) { previousval = Number(item.data[1]).toExponential(2) @@ -782,7 +782,7 @@ export default { str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(minusVal, null, 2) str += '' } else if (tip.alias.indexOf('Previous ') !== -1) { - str += '' + str += '' str += '' } str += '
' @@ -1200,10 +1200,10 @@ export default { sum += self.numberWithEConvent(val) str += '
' str += `
${tip ? (tip.alias ? tip.alias : tip.name) : item.seriesName}
` - str += '
' + str += '
' str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(val, null, 2) if (previousItem) { - str += '' + str += '' let previousval = parseFloat(Number(previousItem.data[1]).toFixed(2)) if (previousval === 0) { previousval = Number(item.data[1]).toExponential(2) @@ -1220,7 +1220,7 @@ export default { str += chartDataFormat.getUnit(chartInfo.unit ? chartInfo.unit : 2).compute(minusVal, null, 2) str += '' } else if (tip.alias.indexOf('Previous ') !== -1) { - str += '' + str += '' str += '' } str += '
' diff --git a/nezha-fronted/src/components/charts/text-chart.vue b/nezha-fronted/src/components/charts/text-chart.vue index beba1f239..e2c26daa5 100644 --- a/nezha-fronted/src/components/charts/text-chart.vue +++ b/nezha-fronted/src/components/charts/text-chart.vue @@ -188,7 +188,6 @@ export default { }, // 设置数据, filter区分 setData (chartItem, seriesItem, panelId, filter, area) { - console.log(chartItem); this.$nextTick(() => { this.resize(chartItem) }) diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js index d73a1c1d7..5d2050944 100644 --- a/nezha-fronted/src/components/common/js/tools.js +++ b/nezha-fronted/src/components/common/js/tools.js @@ -335,7 +335,7 @@ export const chartResizeTool = { chartTableBlankHeight: 6, // 表格型图表额外空白占位高度 chartBlankWidth: 2, // 图表空白占位宽度 containerBlankWidth: 5, // 容器空白占位宽度(#listContainer的padding) - titleHeight: 28, // 标题dom高度 + titleHeight: 40, // 标题dom高度 stepHeight: 50, // 单元高度 timeouter: null, stepWidth (containerWidth) { // 单元宽度,参数为容器总宽度 diff --git a/nezha-fronted/src/components/common/language/cn.js b/nezha-fronted/src/components/common/language/cn.js index 8497a89ff..8d0293300 100644 --- a/nezha-fronted/src/components/common/language/cn.js +++ b/nezha-fronted/src/components/common/language/cn.js @@ -193,6 +193,8 @@ const cn = { last: 'Last', threshold: '阈值', thresholds: '阈值', + group: '组', + remark: '描述', typeVal: { line: { label: '曲线图' @@ -235,7 +237,7 @@ const cn = { last: 'Last', range: 'Range', different: 'Different', - null: 'Null' + null: 'None' }, width: '宽', high: '高', diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index 340f06ea5..27daa6cae 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -206,12 +206,14 @@ const en = { last: 'Last', threshold: 'Threshold', thresholds: 'Thresholds', + group: 'Group', + remark: 'Description', typeVal: { line: { label: 'Line Chart' // "曲线图" }, bar: { - label: 'Bar' // "柱状图" + label: 'Bar Chart' // "柱状图" }, table: { label: 'Table' // "表格" @@ -227,7 +229,7 @@ const en = { label: 'Single value' }, pie: { - label: 'Pie' + label: 'Pie Chart' }, alertList: { label: 'Alert list' @@ -248,7 +250,7 @@ const en = { last: 'Last', range: 'Range', different: 'Different', - null: 'Null' + null: 'None' }, width: 'Width', // "宽" high: 'High', // "高" diff --git a/nezha-fronted/src/components/common/popBox/selectPanel.vue b/nezha-fronted/src/components/common/popBox/selectPanel.vue index d183b1a6c..8c362dcf4 100644 --- a/nezha-fronted/src/components/common/popBox/selectPanel.vue +++ b/nezha-fronted/src/components/common/popBox/selectPanel.vue @@ -1,5 +1,5 @@