diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 1906e84237..651d34fae2 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -686,6 +686,7 @@ export default { table_show_row_tooltip: '开启行头提示', table_show_col_tooltip: '开启列头提示', table_show_cell_tooltip: '开启单元格提示', + table_show_header_tooltip: '开启表头提示', stripe: '斑马纹', start_angle: '起始角度', end_angle: '结束角度', diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/ChartStyle.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/ChartStyle.vue index 9c9e73a427..4480a36c4d 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/ChartStyle.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/ChartStyle.vue @@ -354,13 +354,14 @@ watch( /> { v-model="state.tableHeaderForm.showColTooltip" @change="changeTableHeader('showColTooltip')" > - {{ t('chart.table_show_col_tooltip') }} + {{ + chart.type === 'table-pivot' + ? t('chart.table_show_col_tooltip') + : t('chart.table_show_header_tooltip') + }} { propertyInner = { ...BAR_EDITOR_PROPERTY_INNER, 'label-selector': ['vPosition', 'seriesLabelFormatter'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'y-axis-selector': [...BAR_EDITOR_PROPERTY_INNER['y-axis-selector'], 'axisLabelFormatter'] } protected baseOptions: ColumnOptions = { @@ -236,7 +236,7 @@ export class StackBar extends Bar { propertyInner = { ...this['propertyInner'], 'label-selector': [...BAR_EDITOR_PROPERTY_INNER['label-selector'], 'vPosition'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'tooltipFormatter'] + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'tooltipFormatter', 'show'] } protected configLabel(chart: Chart, options: ColumnOptions): ColumnOptions { const baseOptions = super.configLabel(chart, options) @@ -372,7 +372,7 @@ export class PercentageStackBar extends GroupStackBar { propertyInner = { ...this['propertyInner'], 'label-selector': ['color', 'fontSize', 'vPosition', 'reserveDecimalCount'], - 'tooltip-selector': ['color', 'fontSize'] + 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'show'] } protected configLabel(chart: Chart, options: ColumnOptions): ColumnOptions { const baseOptions = super.configLabel(chart, options) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bidirectional-bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bidirectional-bar.ts index e35acd82cc..0a9c5cc4b0 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bidirectional-bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bidirectional-bar.ts @@ -88,7 +88,17 @@ export class BidirectionalHorizontalBar extends G2PlotChartView< 'legend-selector': ['icon', 'orient', 'fontSize', 'color', 'hPosition', 'vPosition'], 'function-cfg': ['emptyDataStrategy'], 'label-selector': ['hPosition', 'seriesLabelFormatter'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter'] + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter', 'show'] + } + + selectorSpec: EditorSelectorSpec = { + ...this['selectorSpec'], + 'dual-y-axis-selector': { + title: `${t('chart.xAxis')}` + }, + 'x-axis-selector': { + title: `${t('chart.yAxis')}` + } } drawChart(drawOptions: G2PlotDrawOptions): G2BidirectionalBar { diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/common.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/common.ts index 937017e007..d48243e348 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/common.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/common.ts @@ -30,7 +30,7 @@ export const BAR_EDITOR_PROPERTY_INNER: EditorPropertyInner = { 'background-overall-component': ['all'], 'basic-style-selector': ['colors', 'alpha', 'gradient'], 'label-selector': ['fontSize', 'color', 'labelFormatter'], - 'tooltip-selector': ['fontSize', 'color', 'tooltipFormatter'], + 'tooltip-selector': ['fontSize', 'color', 'tooltipFormatter', 'show'], 'x-axis-selector': [ 'name', 'color', diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/horizontal-bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/horizontal-bar.ts index f7764d10ee..da39748f56 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/horizontal-bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/horizontal-bar.ts @@ -34,7 +34,7 @@ export class HorizontalBar extends G2PlotChartView { propertyInner = { ...BAR_EDITOR_PROPERTY_INNER, 'label-selector': ['hPosition', 'seriesLabelFormatter'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'x-axis-selector': [...BAR_EDITOR_PROPERTY_INNER['x-axis-selector'], 'axisLabelFormatter'] } axis: AxisType[] = [...BAR_AXIS_TYPE] @@ -267,7 +267,7 @@ export class HorizontalStackBar extends HorizontalBar { propertyInner = { ...this['propertyInner'], 'label-selector': ['color', 'fontSize', 'hPosition', 'labelFormatter'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'tooltipFormatter'] + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'tooltipFormatter', 'show'] } protected configLabel(chart: Chart, options: BarOptions): BarOptions { const baseOptions = super.configLabel(chart, options) @@ -328,7 +328,7 @@ export class HorizontalPercentageStackBar extends HorizontalStackBar { propertyInner = { ...this['propertyInner'], 'label-selector': ['color', 'fontSize', 'hPosition', 'reserveDecimalCount'], - 'tooltip-selector': ['color', 'fontSize'] + 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'show'] } protected configLabel(chart: Chart, options: BarOptions): BarOptions { const baseOptions = super.configLabel(chart, options) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/progress-bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/progress-bar.ts index e7b61e6ba4..3a853fbe5e 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/progress-bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/progress-bar.ts @@ -49,7 +49,7 @@ export class ProgressBar extends G2PlotChartView { 'background-overall-component': ['all'], 'basic-style-selector': ['colors', 'alpha', 'gradient'], 'label-selector': ['hPosition', 'color', 'fontSize'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'tooltipFormatter'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'tooltipFormatter', 'show'], 'y-axis-selector': ['name', 'color', 'fontSize', 'axisForm', 'axisLabel', 'position'], 'function-cfg': ['emptyDataStrategy'] } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/range-bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/range-bar.ts index 5d4f5ab07a..30a1b4cebc 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/range-bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/range-bar.ts @@ -39,7 +39,14 @@ export class RangeBar extends G2PlotChartView { propertyInner = { ...BAR_EDITOR_PROPERTY_INNER, 'label-selector': ['hPosition', 'color', 'fontSize', 'labelFormatter', 'showGap'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'tooltipFormatter', 'showGap'], + 'tooltip-selector': [ + 'fontSize', + 'color', + 'backgroundColor', + 'tooltipFormatter', + 'showGap', + 'show' + ], 'x-axis-selector': [...BAR_EDITOR_PROPERTY_INNER['x-axis-selector'], 'axisLabelFormatter'] } axis: AxisType[] = [...BAR_AXIS_TYPE, 'yAxisExt'] @@ -47,7 +54,7 @@ export class RangeBar extends G2PlotChartView { data: [], xField: 'values', yField: 'field', - colorFiled: 'category', + colorField: 'category', isGroup: true, interactions: [ { diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/waterfall.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/waterfall.ts index 8a301037e1..f327d38041 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/waterfall.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/waterfall.ts @@ -23,7 +23,7 @@ export class Waterfall extends G2PlotChartView { 'background-overall-component': ['all'], 'basic-style-selector': ['colors', 'alpha', 'gradient'], 'label-selector': ['fontSize', 'color', 'vPosition', 'labelFormatter'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'title-selector': [ 'title', 'fontSize', diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts index 777e024bfe..5b5c376214 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts @@ -261,7 +261,7 @@ export class StackArea extends Area { propertyInner = { ...this['propertyInner'], 'label-selector': ['fontSize', 'color', 'labelFormatter'], - 'tooltip-selector': ['fontSize', 'color', 'tooltipFormatter'] + 'tooltip-selector': ['fontSize', 'color', 'tooltipFormatter', 'show'] } protected configLabel(chart: Chart, options: AreaOptions): AreaOptions { const customAttr = parseJson(chart.customAttr) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/line/common.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/line/common.ts index eaf0a9e484..f1f7a5ed9c 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/line/common.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/line/common.ts @@ -15,7 +15,7 @@ export const LINE_EDITOR_PROPERTY: EditorProperty[] = [ export const LINE_EDITOR_PROPERTY_INNER: EditorPropertyInner = { 'background-overall-component': ['all'], 'label-selector': ['fontSize', 'color'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'show'], 'basic-style-selector': [ 'colors', 'alpha', diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts index a60b06756f..0fce5e2a71 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts @@ -34,7 +34,7 @@ export const MAP_EDITOR_PROPERTY_INNER: EditorPropertyInner = { 'showDimension', 'showQuota' ], - 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'tooltipFormatter'], + 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'tooltipFormatter', 'show'], 'function-cfg': ['emptyDataStrategy'], 'map-mapping': [''] } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/chart-mix-common.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/chart-mix-common.ts index afca7d9f24..f094348493 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/chart-mix-common.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/chart-mix-common.ts @@ -15,7 +15,7 @@ export const CHART_MIX_EDITOR_PROPERTY: EditorProperty[] = [ export const CHART_MIX_EDITOR_PROPERTY_INNER: EditorPropertyInner = { 'background-overall-component': ['all'], 'label-selector': ['fontSize', 'color'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'show'], 'basic-style-selector': [ 'colors', 'alpha', diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/funnel.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/funnel.ts index 39beb3d0a0..7ab8895c06 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/funnel.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/funnel.ts @@ -24,7 +24,7 @@ export class Funnel extends G2PlotChartView { 'background-overall-component': ['all'], 'basic-style-selector': ['colors', 'alpha'], 'label-selector': ['fontSize', 'color', 'hPosition', 'labelFormatter'], - 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'seriesTooltipFormatter'], + 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'title-selector': [ 'show', 'title', diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/quadrant.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/quadrant.ts index e447f1a3ec..d6303d6f87 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/quadrant.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/quadrant.ts @@ -30,7 +30,7 @@ export class Quadrant extends G2PlotChartView { propertyInner: EditorPropertyInner = { 'basic-style-selector': ['colors', 'alpha', 'scatterSymbol', 'scatterSymbolSize'], 'label-selector': ['fontSize', 'color'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'x-axis-selector': [ 'position', 'name', diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/radar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/radar.ts index 9ac62e92dc..d054184e5b 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/radar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/radar.ts @@ -24,7 +24,7 @@ export class Radar extends G2PlotChartView { propertyInner: EditorPropertyInner = { 'basic-style-selector': ['colors', 'alpha', 'radarShape'], 'label-selector': ['seriesLabelFormatter'], - 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'seriesTooltipFormatter'], + 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'misc-style-selector': ['showName', 'color', 'fontSize', 'axisColor'], 'title-selector': [ 'show', @@ -42,6 +42,7 @@ export class Radar extends G2PlotChartView { 'legend-selector': ['icon', 'orient', 'color', 'fontSize', 'hPosition', 'vPosition'] } selectorSpec: EditorSelectorSpec = { + ...this['selectorSpec'], 'misc-style-selector': { title: `${t('chart.tooltip_axis')}` } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/sankey.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/sankey.ts index 0d8d9fe0c9..e7c0ce11a1 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/sankey.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/sankey.ts @@ -45,7 +45,7 @@ export class RangeBar extends G2PlotChartView { propertyInner = { ...SANKEY_EDITOR_PROPERTY_INNER, 'label-selector': ['color', 'fontSize'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'tooltipFormatter'] + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'tooltipFormatter', 'show'] } axis: AxisType[] = [...SANKEY_AXIS_TYPE] protected baseOptions: SankeyOptions = { diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/scatter.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/scatter.ts index 3cfe886394..70ebf7a9ba 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/scatter.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/scatter.ts @@ -29,7 +29,7 @@ export class Scatter extends G2PlotChartView { propertyInner: EditorPropertyInner = { 'basic-style-selector': ['colors', 'alpha', 'scatterSymbol', 'scatterSymbolSize'], 'label-selector': ['fontSize', 'color', 'labelFormatter'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'x-axis-selector': [ 'position', 'name', diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/treemap.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/treemap.ts index 4dd3e81e85..11be3a4663 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/treemap.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/treemap.ts @@ -29,7 +29,7 @@ export class Treemap extends G2PlotChartView { 'basic-style-selector': ['colors', 'alpha'], 'label-selector': ['fontSize', 'color', 'showDimension', 'showQuota', 'showProportion'], 'legend-selector': ['icon', 'orient', 'fontSize', 'color', 'hPosition', 'vPosition'], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'title-selector': [ 'title', 'fontSize', diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/word-cloud.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/word-cloud.ts index f75194b04d..44b1563586 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/word-cloud.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/word-cloud.ts @@ -41,7 +41,7 @@ export class WordCloud extends G2PlotChartView { 'fontShadow' ], 'misc-selector': ['wordSizeRange', 'wordSpacing'], - 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'seriesTooltipFormatter'] + 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'seriesTooltipFormatter', 'show'] } axis: AxisType[] = ['xAxis', 'yAxis', 'filter'] axisConfig: AxisConfig = { diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/pie/common.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/pie/common.ts index 567c449b00..8eb5a51484 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/pie/common.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/pie/common.ts @@ -22,7 +22,7 @@ export const PIE_EDITOR_PROPERTY_INNER: EditorPropertyInner = { 'showQuota', 'showProportion' ], - 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter'], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'basic-style-selector': ['colors', 'alpha', 'radius'], 'title-selector': [ 'title', diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/common.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/common.ts index 2d0f999147..4fa610f969 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/common.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/common.ts @@ -4,6 +4,7 @@ export const TABLE_EDITOR_PROPERTY: EditorProperty[] = [ 'table-header-selector', 'table-cell-selector', 'title-selector', + 'tooltip-selector', 'function-cfg', 'threshold', 'scroll-cfg', @@ -45,6 +46,7 @@ export const TABLE_EDITOR_PROPERTY_INNER: EditorPropertyInner = { 'letterSpace', 'fontShadow' ], + 'tooltip-selector': ['fontSize', 'color', 'backgroundColor'], 'function-cfg': ['emptyDataStrategy'], threshold: ['tableThreshold'] } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts index 082bf54099..36afc49597 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts @@ -5,7 +5,7 @@ import { S2ChartView, S2DrawOptions } from '../../types/impl/s2' import { TABLE_EDITOR_PROPERTY, TABLE_EDITOR_PROPERTY_INNER } from './common' import { useI18n } from '@/hooks/web/useI18n' import { isNumber } from 'lodash-es' -import { copyContent } from '@/views/chart/components/js/panel/common/common_table' +import { copyContent, SortTooltip } from '@/views/chart/components/js/panel/common/common_table' const { t } = useI18n() @@ -108,7 +108,8 @@ export class TableInfo extends S2ChartView { style: this.configStyle(chart), conditions: this.configConditions(chart), tooltip: { - getContainer: () => containerDom + getContainer: () => containerDom, + renderTooltip: sheet => new SortTooltip(sheet) } } // 开启序号之后,第一列就是序号列,修改 label 即可 @@ -135,7 +136,7 @@ export class TableInfo extends S2ChartView { } } // tooltip - this.configTooltip(s2Options) + this.configTooltip(chart, s2Options) // 隐藏表头,保留顶部的分割线, 禁用表头横向 resize if (customAttr.tableHeader.showTableHeader === false) { s2Options.style.colCfg.height = 1 diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts index 2bdaa5ca23..16a5dbf584 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts @@ -2,7 +2,11 @@ import { S2ChartView, S2DrawOptions } from '@/views/chart/components/js/panel/ty import { S2Event, S2Options, TableSheet, TableColCell, ViewMeta, TableDataCell } from '@antv/s2' import { parseJson } from '@/views/chart/components/js/util' import { formatterItem, valueFormatter } from '@/views/chart/components/js/formatter' -import { copyContent, getCurrentField } from '@/views/chart/components/js/panel/common/common_table' +import { + copyContent, + getCurrentField, + SortTooltip +} from '@/views/chart/components/js/panel/common/common_table' import { TABLE_EDITOR_PROPERTY, TABLE_EDITOR_PROPERTY_INNER } from './common' import { useI18n } from '@/hooks/web/useI18n' import { isNumber } from 'lodash-es' @@ -111,7 +115,8 @@ export class TableNormal extends S2ChartView { style: this.configStyle(chart), conditions: this.configConditions(chart), tooltip: { - getContainer: () => containerDom + getContainer: () => containerDom, + renderTooltip: sheet => new SortTooltip(sheet) } } // 开启序号之后,第一列就是序号列,修改 label 即可 @@ -134,7 +139,7 @@ export class TableNormal extends S2ChartView { } } // tooltip - this.configTooltip(s2Options) + this.configTooltip(chart, s2Options) // 隐藏表头,保留顶部的分割线, 禁用表头横向 resize if (customAttr.tableHeader.showTableHeader === false) { s2Options.style.colCfg.height = 1 diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-pivot.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-pivot.ts index a90a8d5f80..8bd20dc78b 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-pivot.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-pivot.ts @@ -1,4 +1,4 @@ -import { EXTRA_FIELD, PivotSheet, S2Event, S2Options, TOTAL_VALUE, S2Theme } from '@antv/s2' +import { EXTRA_FIELD, PivotSheet, S2Event, S2Options, TOTAL_VALUE, S2Theme, Totals } from '@antv/s2' import { formatterItem, valueFormatter } from '../../../formatter' import { hexColorToRGBA, parseJson } from '../../../util' import { S2ChartView, S2DrawOptions } from '../../types/impl/s2' @@ -20,6 +20,7 @@ export class TablePivot extends S2ChartView { 'table-cell-selector', 'table-total-selector', 'title-selector', + 'tooltip-selector', 'function-cfg', 'threshold', 'linkage', @@ -183,15 +184,20 @@ export class TablePivot extends S2ChartView { sortParams: sortParams } // options - const s2Options = { + const s2Options: S2Options = { width: containerDom.offsetWidth, height: containerDom.offsetHeight, style: this.configStyle(chart), - totals: tableTotal, + totals: tableTotal as Totals, conditions: this.configConditions(chart), + tooltip: { + getContainer: () => containerDom + }, hierarchyType: basicStyle.tableLayoutMode ?? 'grid' } + // tooltip + this.configTooltip(chart, s2Options) // 开始渲染 const s2 = new PivotSheet(containerDom, s2DataConfig, s2Options as unknown as S2Options) // hover diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts index a3afdc168b..9ed7a1a3a7 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts @@ -611,7 +611,7 @@ export function handleTableEmptyStrategy(chart: Chart) { } return newData } -class SortTooltip extends BaseTooltip { +export class SortTooltip extends BaseTooltip { show(showOptions) { const { iconName } = showOptions if (iconName) { @@ -656,7 +656,10 @@ class SortTooltip extends BaseTooltip { top: `${this.position?.y}px`, pointerEvents: enterable ? 'all' : 'none', zIndex: 9999, - position: 'absolute' + position: 'absolute', + color: 'black', + background: 'white', + fontSize: '16px' }, visible: true }) @@ -736,13 +739,22 @@ export function configHeaderInteraction(chart: Chart, option: S2Options) { ] } -export function configTooltip(option: S2Options) { +export function configTooltip(chart: Chart, option: S2Options) { + const { tooltip } = parseJson(chart.customAttr) option.tooltip = { ...option.tooltip, + style: { + background: tooltip.backgroundColor, + fontSize: tooltip.fontSize + 'px', + color: tooltip.color, + boxShadow: 'rgba(0, 0, 0, 0.1) 0px 4px 8px 0px', + borderRadius: '3px', + padding: '4px 12px', + opacity: 0.95 + }, adjustPosition: ({ event }) => { return getTooltipPosition(event) - }, - renderTooltip: sheet => new SortTooltip(sheet) + } } } diff --git a/core/core-frontend/src/views/chart/components/js/panel/types/impl/s2.ts b/core/core-frontend/src/views/chart/components/js/panel/types/impl/s2.ts index 2fc026a84d..89e8b95166 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/types/impl/s2.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/types/impl/s2.ts @@ -3,7 +3,7 @@ import { AntVDrawOptions, ChartLibraryType } from '@/views/chart/components/js/panel/types' -import { S2Theme, SpreadSheet, Style, S2Options, Meta } from '@antv/s2' +import { S2Theme, SpreadSheet, Style, S2Options, Meta, SERIES_NUMBER_FIELD } from '@antv/s2' import { configHeaderInteraction, configTooltip, @@ -42,8 +42,8 @@ export abstract class S2ChartView

extends AntVAbstractCha return handleTableEmptyStrategy(chart) } - protected configTooltip(option: S2Options) { - configTooltip(option) + protected configTooltip(chart: Chart, option: S2Options) { + configTooltip(chart, option) } protected configHeaderInteraction(chart: Chart, option: S2Options) { @@ -62,12 +62,19 @@ export abstract class S2ChartView

extends AntVAbstractCha switch (cell.cellType) { case 'dataCell': field = find(metaConfig, item => item.field === meta.valueField) + if (meta.fieldValue === 0) { + content = '0' + } if (meta.fieldValue) { content = field?.formatter?.(meta.fieldValue) } break case 'rowCell': case 'colCell': + if (meta.field === SERIES_NUMBER_FIELD) { + content = cell.getTextShape()['attrs'].text + break + } content = meta.label field = find(metaConfig, item => item.field === content) if (field) { diff --git a/core/core-frontend/src/views/chart/components/js/panel/types/index.ts b/core/core-frontend/src/views/chart/components/js/panel/types/index.ts index b527c00c95..62b240473a 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/types/index.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/types/index.ts @@ -100,6 +100,12 @@ export abstract class AntVAbstractChartView extends AbstractChartView { selectorSpec: EditorSelectorSpec = { 'misc-style-selector': { title: `${t('chart.size')}` + }, + 'dual-y-axis-selector': { + title: `${t('chart.yAxis')}` + }, + 'x-axis-selector': { + title: `${t('chart.xAxis')}` } } protected constructor(library: ChartLibraryType, name: string, defaultData?: any[]) {