From 9a41015b6c6816ef05b2b3e49f4102de94288d13 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Mon, 26 Aug 2024 09:36:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8-=E7=83=AD=E5=8A=9B?= =?UTF-8?q?=E5=9B=BE):=20=E4=BF=AE=E5=A4=8D=E6=A8=AA=E7=BA=B5=E8=BD=B4?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E7=9B=B8=E4=BA=92=E5=BD=B1=E5=93=8D=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/drag-item/DimensionItem.vue | 28 +++++++++----- .../views/chart/components/editor/index.vue | 5 --- .../js/panel/charts/table/t-heatmap.ts | 38 +++++++++++++------ 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/editor/drag-item/DimensionItem.vue b/core/core-frontend/src/views/chart/components/editor/drag-item/DimensionItem.vue index 42c6c4d940..3ca5e59ec3 100644 --- a/core/core-frontend/src/views/chart/components/editor/drag-item/DimensionItem.vue +++ b/core/core-frontend/src/views/chart/components/editor/drag-item/DimensionItem.vue @@ -173,6 +173,15 @@ const showCustomSort = item => { } return !item.chartId && (item.deType === 0 || item.deType === 5) } +const showSort = () => { + const isExtColor = props.type === 'extColor' + const isChartMix = props.chart.type.includes('chart-mix') + const isDimensionOrDimensionStack = props.type === 'dimension' || props.type === 'dimensionStack' + if (isExtColor) { + return false + } + return !isChartMix || isDimensionOrDimensionStack +} onMounted(() => { getItemTagType() }) @@ -186,7 +195,7 @@ onMounted(() => { :class="['editor-' + props.themes, `${themes}_icon-right`]" :style="{ backgroundColor: tagType + '0a', border: '1px solid ' + tagType }" > - + @@ -203,6 +212,14 @@ onMounted(() => { /> + + + + + { class="drop-style" :class="themes === 'dark' ? 'dark-dimension-quota' : ''" > - + { renderChart(view.value) } -const onChangExtColorForm = val => { - view.value.extColor = val - renderChart(view.value) -} - const showRename = val => { recordSnapshotInfo('render') state.itemForm = JSON.parse(JSON.stringify(val)) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/t-heatmap.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/t-heatmap.ts index 8f0e19159f..ce383d51f1 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/t-heatmap.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/t-heatmap.ts @@ -80,6 +80,26 @@ export class TableHeatmap extends G2PlotChartView { } return defaultLength } + protected sortData = (fieldObj, data) => { + const { deType, sort, customSort } = fieldObj + + if (sort === 'desc') { + if (deType === 0) { + return data.sort().reverse() + } else { + return data.sort((a, b) => b - a) + } + } else if (sort === 'asc') { + if (deType === 0) { + return data.sort() + } else { + return data.sort((a, b) => a - b) + } + } + + // 如果没有指定排序方式,直接返回原始数据或 customSort + return customSort && customSort.length > 0 ? customSort : data + } async drawChart(drawOptions: G2PlotDrawOptions): Promise { const { chart, container, action } = drawOptions const xAxis = deepCopy(chart.xAxis) @@ -100,6 +120,7 @@ export class TableHeatmap extends G2PlotChartView { } }) }) + // options const initOptions: HeatmapOptions = { data: data, @@ -109,11 +130,12 @@ export class TableHeatmap extends G2PlotChartView { appendPadding: getPadding(chart), meta: { [xField]: { - type: 'cat' + type: 'cat', + values: this.sortData(xAxis[0], [...new Set(data.map(i => i[[xField]]))]) }, [xFieldExt]: { type: 'cat', - values: [...new Set(data.map(i => i[[xFieldExt]]))].reverse() + values: this.sortData(xAxisExt[0], [...new Set(data.map(i => i[[xFieldExt]]))]).reverse() } }, legend: { @@ -136,8 +158,7 @@ export class TableHeatmap extends G2PlotChartView { } const pointData = param.data.data const dimensionList = [] - const quotaList = [] - chart.data.fields.forEach((item, index) => { + chart.data.fields.forEach(item => { Object.keys(pointData).forEach(key => { if (key.startsWith('f_') && item.dataeaseName === key) { dimensionList.push({ @@ -146,13 +167,6 @@ export class TableHeatmap extends G2PlotChartView { value: pointData[key] }) } - if (!key.startsWith('f_')) { - quotaList.push({ - id: item.id, - dataeaseName: item.dataeaseName, - value: pointData[key] - }) - } }) }) action({ @@ -183,7 +197,7 @@ export class TableHeatmap extends G2PlotChartView { protected configBasicStyle(chart: Chart, options: HeatmapOptions): HeatmapOptions { const basicStyle = parseJson(chart.customAttr).basicStyle - const color = basicStyle.colors?.map((ele, index) => { + const color = basicStyle.colors?.map(ele => { return hexColorToRGBA(ele, basicStyle.alpha) }) return {