@publishfx/publish-chart 2.1.13 → 2.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,6 @@ function renderG2GroupBarChart(container, options) {
13
13
  paddingBottom: 0,
14
14
  insetBottom: 0
15
15
  });
16
- console.log('isLegend:', legend, isLegend);
17
16
  const view = getMainView(chart);
18
17
  view.attr('marginBottom', isLegend ? 0 : 16);
19
18
  if (isHorizontal) view.coordinate({
@@ -23,7 +22,6 @@ function renderG2GroupBarChart(container, options) {
23
22
  }
24
23
  ]
25
24
  });
26
- console.log(legendItems, 'legendItems');
27
25
  view.data(data);
28
26
  applyScaleYLinear(view, {
29
27
  field: 'y',
@@ -124,7 +122,6 @@ function renderG2GroupBarChart(container, options) {
124
122
  }
125
123
  applyAuxiliaryLineY(view, auxiliaryLineData);
126
124
  const nodeList = [];
127
- console.log('nodeList data:', data);
128
125
  data.forEach((item)=>{
129
126
  view.shape().data([
130
127
  {
@@ -2,7 +2,6 @@ import { applyAuxiliaryLineY, applyAxisX, applyAxisY, applyHighlightDate, applyN
2
2
  const Y_AXIS_FIELD = 'groupValue';
3
3
  function renderG2LineChart(container, options) {
4
4
  const { data, nodeData, x, y, minY, maxY, timeRange: _timeRange, themeColors, indicators = [], indicatorMap: _indicatorMap = {}, formatAxis, highlightDate = [], auxiliaryLineData = [], isDataTag = false, isLegend = true, isHighlight = true, formatLabel, height = 300, legendLength: _legendLength, legendSize: _legendSize, tooltipRender, onNodeListChange, onChartRender } = options;
5
- console.log('g2line data:', data, x, y);
6
5
  const colorOpts = {
7
6
  themeColors,
8
7
  primaryKey: y,
@@ -28,12 +27,11 @@ function renderG2LineChart(container, options) {
28
27
  key: 'main'
29
28
  });
30
29
  applyHighlightDate(view, x, data, highlightDate, isHighlight);
31
- console.log('g2linets:', x, Y_AXIS_FIELD, data, indicators);
32
- const line = view.line().data(data.filter((item)=>!item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').encode('series', 'groupType').style({
30
+ const line = view.line().data(data.filter((item)=>!item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').encode('series', 'groupType').animate(false).style({
33
31
  lineWidth: 2,
34
32
  stroke: (datum)=>getColorByGroupType(datum[0]?.groupType ?? '', colorOpts)
35
33
  });
36
- const compareLine = view.line().data(data.filter((item)=>item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').style({
34
+ const compareLine = view.line().data(data.filter((item)=>item.groupType.includes('_compare'))).encode('x', x).encode('y', Y_AXIS_FIELD).encode('color', 'groupType').encode('series', 'groupType').animate(false).style({
37
35
  lineDash: [
38
36
  4,
39
37
  4
@@ -62,7 +60,6 @@ function renderG2LineChart(container, options) {
62
60
  ]
63
61
  });
64
62
  const hasCompareData = data.some((item)=>item.groupType.includes('_compare'));
65
- console.log('hasCompareData:', hasCompareData, data);
66
63
  if (hasCompareData) compareLine.tooltip({
67
64
  items: [
68
65
  (datum)=>({
@@ -95,16 +92,13 @@ function renderG2LineChart(container, options) {
95
92
  bounding: tooltipBounding,
96
93
  render: (_event, payload)=>{
97
94
  const { title, items } = payload;
98
- console.log('tooltipRender:', title, items, indicators);
99
95
  if (indicators.length) {
100
96
  const groupedItems = indicators.map((indicator)=>items.filter((i)=>i.indicatorId === String(indicator)));
101
- console.log(groupedItems.flat(), 'tooltip groupedItems');
102
97
  const sortedItems = groupedItems.map((group)=>[
103
98
  group.filter((i)=>i.name === i.indicatorId),
104
99
  group.filter((i)=>i.compareTime),
105
100
  group.filter((i)=>i.name.includes('_change'))
106
101
  ].filter(Boolean).flat()).flat();
107
- console.log(sortedItems, 'tooltip sortedItems');
108
102
  const formatItems = sortedItems.map((item)=>({
109
103
  ...item,
110
104
  color: getColorByGroupType(item?.indicatorId, colorOpts)
@@ -7,47 +7,20 @@ function isValidColor(color) {
7
7
  return "" !== s.color;
8
8
  }
9
9
  function validateAndNormalizeProps(props) {
10
- const isDev = "development" === process.env.NODE_ENV;
10
+ process.env.NODE_ENV;
11
11
  let { min = 0, max } = props;
12
- if ("number" != typeof max || !isFinite(max)) {
13
- if (isDev) console.warn("[G2GaugeChart] max 必须是有效的数字,使用默认值 100", {
14
- max
15
- });
16
- max = 100;
17
- }
18
- if ("number" != typeof min || !isFinite(min)) {
19
- if (isDev) console.warn("[G2GaugeChart] min 必须是有效的数字,使用默认值 0", {
20
- min
21
- });
22
- min = 0;
23
- }
12
+ if ("number" != typeof max || !isFinite(max)) max = 100;
13
+ if ("number" != typeof min || !isFinite(min)) min = 0;
24
14
  if (min >= max) {
25
- if (isDev) console.warn(`[G2GaugeChart] min (${min}) 必须小于 max (${max}),自动调整为 max - 1`, {
26
- min,
27
- max
28
- });
29
15
  min = max - 1;
30
16
  if (min < 0) {
31
17
  min = 0;
32
18
  max = 100;
33
- if (isDev) console.warn("[G2GaugeChart] min 和 max 都无效,使用默认值 min=0, max=100");
34
19
  }
35
20
  }
36
21
  let { value } = props;
37
- if ("number" != typeof value || !isFinite(value)) {
38
- if (isDev) console.warn(`[G2GaugeChart] value 必须是有效的数字,使用默认值 (min + max) / 2`, {
39
- value
40
- });
41
- value = (min + max) / 2;
42
- }
43
- const originalValue = value;
22
+ if ("number" != typeof value || !isFinite(value)) value = (min + max) / 2;
44
23
  value = Math.min(Math.max(value, min), max);
45
- if (originalValue !== value && isDev) console.warn(`[G2GaugeChart] value (${originalValue}) 超出范围 [${min}, ${max}],已限制为 ${value}`, {
46
- originalValue,
47
- min,
48
- max,
49
- clampedValue: value
50
- });
51
24
  let thresholds = [];
52
25
  const defaultColors = [
53
26
  '#9596d9',
@@ -68,33 +41,18 @@ function validateAndNormalizeProps(props) {
68
41
  let colors = [];
69
42
  if (props.thresholds && Array.isArray(props.thresholds) && props.thresholds.length > 0 && "object" == typeof props.thresholds[0]) colors = props.thresholds.map((t)=>t.color).filter((c)=>!!c && isValidColor(c));
70
43
  if (0 === colors.length && props.thresholdColors) colors = props.thresholdColors.filter((c)=>isValidColor(c));
71
- if (0 === colors.length) {
72
- colors = [
73
- ...defaultColors
74
- ];
75
- if (isDev) console.warn("[G2GaugeChart] 未提供有效的颜色,使用默认颜色", {
76
- colors
77
- });
78
- }
44
+ if (0 === colors.length) colors = [
45
+ ...defaultColors
46
+ ];
79
47
  while(colors.length < thresholds.length){
80
48
  const lastColor = colors[colors.length - 1];
81
49
  colors.push(lastColor || defaultColors[0]);
82
50
  }
83
51
  let height = props.height ?? 300;
84
- if ("number" != typeof height || !isFinite(height) || height <= 0) {
85
- if (isDev) console.warn(`[G2GaugeChart] height 必须是大于 0 的数字,使用默认值 300`, {
86
- height: props.height
87
- });
88
- height = 300;
89
- }
52
+ if ("number" != typeof height || !isFinite(height) || height <= 0) height = 300;
90
53
  height = Math.min(Math.max(height, 100), 2000);
91
54
  let pointerColor = props.pointerColor ?? "#c5c5c5";
92
- if (!isValidColor(pointerColor)) {
93
- if (isDev) console.warn(`[G2GaugeChart] pointerColor 无效,使用默认值 #c5c5c5`, {
94
- pointerColor: props.pointerColor
95
- });
96
- pointerColor = "#c5c5c5";
97
- }
55
+ if (!isValidColor(pointerColor)) pointerColor = "#c5c5c5";
98
56
  const formatter = props.formatter;
99
57
  const tickFormatter = props.tickFormatter;
100
58
  return {
@@ -116,11 +74,7 @@ function safeFormat(formatter, value, percent, fallback) {
116
74
  try {
117
75
  return formatter(value, percent);
118
76
  } catch (error) {
119
- if ("development" === process.env.NODE_ENV) console.warn("[G2GaugeChart] formatter 函数执行出错,使用降级值", {
120
- error,
121
- value,
122
- percent
123
- });
77
+ process.env.NODE_ENV;
124
78
  return fallback;
125
79
  }
126
80
  }
@@ -129,10 +83,7 @@ function safeTickFormat(tickFormatter, value, fallback) {
129
83
  try {
130
84
  return tickFormatter(value);
131
85
  } catch (error) {
132
- if ("development" === process.env.NODE_ENV) console.warn("[G2GaugeChart] tickFormatter 函数执行出错,使用降级值", {
133
- error,
134
- value
135
- });
86
+ process.env.NODE_ENV;
136
87
  return fallback;
137
88
  }
138
89
  }
@@ -1,3 +1,4 @@
1
+ import type { AuxiliaryLineData } from "../../../core/ChartTypes";
1
2
  type Item = {
2
3
  color?: string;
3
4
  name?: string;
@@ -7,6 +8,7 @@ type Item = {
7
8
  indicatorId?: string;
8
9
  percent?: string | number;
9
10
  hidden?: boolean;
11
+ isCombine?: boolean;
10
12
  };
11
13
  interface Props {
12
14
  isGroupBar?: boolean;
@@ -15,10 +17,7 @@ interface Props {
15
17
  safeIndicatorMap: any;
16
18
  formatter: any;
17
19
  safeLegend: string;
18
- auxiliaryLineData: undefined | {
19
- name: string;
20
- value: string | number;
21
- }[];
20
+ auxiliaryLineData?: AuxiliaryLineData[];
22
21
  }
23
22
  declare const _default: import("react").NamedExoticComponent<Props>;
24
23
  export default _default;
@@ -3,8 +3,8 @@ import { memo } from "react";
3
3
  import { CompareChange } from "@publishfx/publish-components";
4
4
  import { getIndicatorCompareName } from "../../../utils/indicatorHelpers.js";
5
5
  const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap, formatter, safeLegend, auxiliaryLineData })=>{
6
- let auxiIndicatorId = "";
7
- console.log('G2CompareTooltip:', items);
6
+ let auxiIndicatorId = '';
7
+ let combineIndicatorId = '';
8
8
  const uniqueColors = [];
9
9
  return /*#__PURE__*/ jsxs("div", {
10
10
  style: {
@@ -14,7 +14,8 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
14
14
  /*#__PURE__*/ jsx("div", {
15
15
  children: title
16
16
  }),
17
- items?.map(({ color, value, isChange, compareTime, indicatorId, name, percent, hidden }, index)=>{
17
+ items?.map(({ color, value, isChange, compareTime, indicatorId, name, percent, hidden, isCombine }, index)=>{
18
+ if (isCombine) combineIndicatorId = indicatorId ?? "";
18
19
  let isFirst = false;
19
20
  if (0 === index) auxiIndicatorId = indicatorId ?? "";
20
21
  if (color && !uniqueColors.includes(color)) {
@@ -61,9 +62,7 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
61
62
  ]
62
63
  }, index);
63
64
  }),
64
- auxiliaryLineData?.map(({ name, value }, index)=>{
65
- console.log("auxiliaryLineData:", name, value, safeLegend);
66
- return /*#__PURE__*/ jsxs("div", {
65
+ auxiliaryLineData?.map(({ name, value, axis }, index)=>/*#__PURE__*/ jsxs("div", {
67
66
  style: {
68
67
  display: "flex",
69
68
  justifyContent: "space-between",
@@ -82,11 +81,10 @@ const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap,
82
81
  ]
83
82
  }),
84
83
  /*#__PURE__*/ jsx("div", {
85
- children: formatter.formatIndicator(value, safeIndicatorMap[auxiIndicatorId ?? ""] ?? {})
84
+ children: 'right' === axis ? formatter.formatIndicator(value, safeIndicatorMap[combineIndicatorId ?? ''] ?? {}) : formatter.formatIndicator(value, safeIndicatorMap[auxiIndicatorId ?? ''] ?? {})
86
85
  })
87
86
  ]
88
- }, index);
89
- })
87
+ }, index))
90
88
  ]
91
89
  });
92
90
  };
@@ -3,9 +3,7 @@ import "react";
3
3
  import { Popover } from "@arco-design/web-react";
4
4
  import { nodeMap } from "../../core/ChartConfig.js";
5
5
  import { NodePopoverContent } from "./NodePopoverContent.js";
6
- const NodeDetail = ({ chartWidth, chartOffset, dvRows, ratio = 1 })=>{
7
- console.log(dvRows, 'dvRows');
8
- return /*#__PURE__*/ jsx("div", {
6
+ const NodeDetail = ({ chartWidth, chartOffset, dvRows, ratio = 1 })=>/*#__PURE__*/ jsx("div", {
9
7
  style: {
10
8
  display: 'flex',
11
9
  justifyContent: 'space-around',
@@ -106,5 +104,4 @@ const NodeDetail = ({ chartWidth, chartOffset, dvRows, ratio = 1 })=>{
106
104
  });
107
105
  })
108
106
  });
109
- };
110
107
  export { NodeDetail };
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  type NodeInfoItem = {
3
3
  area: string;
4
4
  description: string;
@@ -15,19 +15,25 @@ const NodePopover = ({ style, pointData, pointP })=>{
15
15
  return /*#__PURE__*/ jsx(Fragment, {
16
16
  children: /*#__PURE__*/ jsx(Popover, {
17
17
  blurToHide: true,
18
- unmountOnExit: true,
18
+ unmountOnExit: false,
19
19
  position: "right",
20
20
  style: {
21
- maxWidth: 'auto'
21
+ maxWidth: "auto"
22
22
  },
23
23
  content: /*#__PURE__*/ jsx(Fragment, {
24
24
  children: /*#__PURE__*/ jsx(NodePopoverContent, {
25
25
  nodeInfos: nodeInfos
26
26
  })
27
27
  }),
28
+ onVisibleChange: (visible)=>{
29
+ if (visible) {
30
+ const tooltip = document.querySelector(".g2-tooltip");
31
+ if (tooltip) tooltip.style.visibility = "hidden";
32
+ }
33
+ },
28
34
  children: /*#__PURE__*/ jsx("div", {
29
35
  style: {
30
- position: 'absolute',
36
+ position: "absolute",
31
37
  top: pointP.y - 10,
32
38
  left: pointP.x - 10,
33
39
  zIndex: 999,
@@ -16,9 +16,7 @@ const calculateBarWidth = (chart, data, xField, widthRatio = 0.5)=>{
16
16
  const estimatedBarWidth = xValueWidth * widthRatio;
17
17
  return estimatedBarWidth;
18
18
  }
19
- } catch (error) {
20
- console.error('计算主图柱状图宽度失败', error);
21
- }
19
+ } catch (error) {}
22
20
  };
23
21
  const getAxisHorPaddingByText = (value, indicatorMap, y)=>7 * getAxisFormat(value, indicatorMap, y).length + 26;
24
22
  const getAxisFormat = (val, indicatorMap, y)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@publishfx/publish-chart",
3
- "version": "2.1.13",
3
+ "version": "2.1.15",
4
4
  "description": "A React chart component library for the Publish platform, including BarChart, LineChart, BarLineChart and other visualization components",
5
5
  "type": "module",
6
6
  "keywords": [