@publishfx/publish-chart 1.4.3 → 1.4.5

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 柱状折线组合图组件
2
+ * 柱状折线组合图组件(暂时用不到)
3
3
  */
4
4
  import React from 'react';
5
5
  import type { BaseChartProps } from '../../core/ChartTypes';
@@ -123,14 +123,6 @@ const GroupBar = ({ height, data, x = 'groupName', y = '', legend = 'groupType',
123
123
  isDataTag,
124
124
  horPaddingRight
125
125
  ]);
126
- const scale = {
127
- [yAxis]: {
128
- min: 0,
129
- max: maxY,
130
- type: 'linear-strict',
131
- nice: true
132
- }
133
- };
134
126
  const topLabel = {};
135
127
  dv.rows.forEach((item)=>{
136
128
  const infos = [
@@ -180,11 +172,31 @@ const GroupBar = ({ height, data, x = 'groupName', y = '', legend = 'groupType',
180
172
  });
181
173
  return Array.from(uniqueMap.values());
182
174
  }, [
183
- transformData
175
+ transformData,
176
+ legend
184
177
  ]);
185
178
  const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, y) - 25, [
186
179
  maxY
187
180
  ]);
181
+ const finalXAxisValues = useMemo(()=>{
182
+ const allXValues = transformData.map((item)=>item[x]);
183
+ return Array.from(new Set(allXValues));
184
+ }, [
185
+ transformData,
186
+ x
187
+ ]);
188
+ const scale = {
189
+ [yAxis]: {
190
+ min: 0,
191
+ max: maxY,
192
+ type: 'linear-strict',
193
+ nice: true
194
+ },
195
+ [x]: {
196
+ type: 'cat',
197
+ values: finalXAxisValues
198
+ }
199
+ };
188
200
  return /*#__PURE__*/ jsxs(Chart, {
189
201
  height: height || 300,
190
202
  data: transformData,
@@ -397,10 +409,12 @@ const GroupBar = ({ height, data, x = 'groupName', y = '', legend = 'groupType',
397
409
  scale: {
398
410
  node: {
399
411
  min: 0,
400
- max: 1
412
+ max: 1,
413
+ nice: false
401
414
  },
402
- groupName: {
403
- type: 'cat'
415
+ [x]: {
416
+ type: 'cat',
417
+ values: finalXAxisValues
404
418
  }
405
419
  },
406
420
  children: [
@@ -408,6 +422,10 @@ const GroupBar = ({ height, data, x = 'groupName', y = '', legend = 'groupType',
408
422
  name: "node",
409
423
  visible: false
410
424
  }),
425
+ /*#__PURE__*/ jsx(Axis, {
426
+ name: x,
427
+ visible: false
428
+ }),
411
429
  /*#__PURE__*/ jsx(Legend, {
412
430
  name: "color",
413
431
  visible: false
@@ -125,12 +125,23 @@ const GroupBarLine = ({ height = 300, data, x = "groupName", y = "", legend = "g
125
125
  const maxYLeft = Math.max(maxLeft, leftAuxi && Math.max(...leftAuxi.map((item)=>+item.value)) || 0);
126
126
  const maxYRightValue = Math.max(maxRight, rightAuxi && Math.max(...rightAuxi.map((item)=>+item.value)) || 0);
127
127
  const maxYRight = maxYRightValue !== maxRight && rightAuxi && rightAuxi.length > 0 ? 1.2 * Math.max(...rightAuxi.map((item)=>+item.value)) : maxYRightValue;
128
+ const finalXAxisValues = useMemo(()=>{
129
+ const allXValues = leftData.map((item)=>item[x]);
130
+ return Array.from(new Set(allXValues));
131
+ }, [
132
+ leftData,
133
+ x
134
+ ]);
128
135
  const scale = {
129
136
  groupValue: {
130
137
  type: "linear-strict",
131
138
  min: 0,
132
139
  nice: true,
133
140
  max: maxYLeft
141
+ },
142
+ [x]: {
143
+ type: 'cat',
144
+ values: finalXAxisValues
134
145
  }
135
146
  };
136
147
  useEffect(()=>{
@@ -216,7 +227,8 @@ const GroupBarLine = ({ height = 300, data, x = "groupName", y = "", legend = "g
216
227
  });
217
228
  return Array.from(uniqueMap.values());
218
229
  }, [
219
- transformData
230
+ transformData,
231
+ legend
220
232
  ]);
221
233
  return /*#__PURE__*/ jsxs(Chart, {
222
234
  height: height,
@@ -551,17 +563,24 @@ const GroupBarLine = ({ height = 300, data, x = "groupName", y = "", legend = "g
551
563
  scale: {
552
564
  node: {
553
565
  min: 0,
554
- max: 1
566
+ max: 1,
567
+ nice: false
555
568
  },
556
- groupName: {
557
- type: 'cat'
569
+ [x]: {
570
+ type: 'cat',
571
+ values: finalXAxisValues
558
572
  }
559
573
  },
574
+ padding: 0,
560
575
  children: [
561
576
  /*#__PURE__*/ jsx(Axis, {
562
577
  name: "node",
563
578
  visible: false
564
579
  }),
580
+ /*#__PURE__*/ jsx(Axis, {
581
+ name: x,
582
+ visible: false
583
+ }),
565
584
  /*#__PURE__*/ jsx(Legend, {
566
585
  name: "color",
567
586
  visible: false
@@ -26,6 +26,8 @@ const GroupCompare = ({ height = 300, data, x = "", y = "", indicatorMap, onChar
26
26
  const BAR_PADDING_RIGHT = mergedConfig.layout.barPaddingRight || 10;
27
27
  const HOR_BAR_PADDING_RIGHT = mergedConfig.layout.horBarPaddingRight || 50;
28
28
  const { isDescend = false, isLegend = true, isHorizontal = false, isDataTag = false, isHighlight = true } = config || {};
29
+ console.log('isLegend', isLegend);
30
+ console.log('config', config);
29
31
  const [chartInsWidth, setChartInsWidth] = useState(0);
30
32
  const [mainBarSize, setMainBarSize] = useState(void 0);
31
33
  const [backgroundHeight, setBackgroundHeight] = useState(1000);
@@ -201,6 +203,30 @@ const GroupCompare = ({ height = 300, data, x = "", y = "", indicatorMap, onChar
201
203
  const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, y) - 22, [
202
204
  maxY
203
205
  ]);
206
+ const nodeViewData = useMemo(()=>{
207
+ const uniqueMap = new Map();
208
+ transformData.forEach((item)=>{
209
+ const hasNode = (item?.nodeInfos?.info?.length || 0) > 0 || (item?.nodeInfos?.infosCompare?.length || 0) > 0;
210
+ if (hasNode && !uniqueMap.has(item.groupName)) uniqueMap.set(item.groupName, {
211
+ groupName: item.groupName,
212
+ node: 0,
213
+ nodeInfos: item.nodeInfos,
214
+ color: item.color,
215
+ [legend]: 'NodeEvent'
216
+ });
217
+ });
218
+ return Array.from(uniqueMap.values());
219
+ }, [
220
+ transformData,
221
+ legend
222
+ ]);
223
+ const finalXAxisValues = useMemo(()=>{
224
+ const allXValues = transformData.map((item)=>item[x]);
225
+ return Array.from(new Set(allXValues));
226
+ }, [
227
+ transformData,
228
+ x
229
+ ]);
204
230
  return /*#__PURE__*/ jsxs(Chart, {
205
231
  height: height,
206
232
  data: transformData,
@@ -241,6 +267,10 @@ const GroupCompare = ({ height = 300, data, x = "", y = "", indicatorMap, onChar
241
267
  type: "linear-strict",
242
268
  max: maxY,
243
269
  nice: true
270
+ },
271
+ [x]: {
272
+ type: 'cat',
273
+ values: finalXAxisValues
244
274
  }
245
275
  },
246
276
  children: [
@@ -590,10 +620,43 @@ const GroupCompare = ({ height = 300, data, x = "", y = "", indicatorMap, onChar
590
620
  } catch (error) {}
591
621
  }
592
622
  }),
623
+ /*#__PURE__*/ jsx(Legend, {
624
+ name: "color",
625
+ visible: false
626
+ }),
593
627
  transformData.some((item)=>item?.nodeInfos?.info?.length > 0 || item?.nodeInfos?.infosCompare?.length > 0) ? /*#__PURE__*/ jsx(Fragment, {
594
- children: 1 == nodeSetting.showType && NodeGeom ? /*#__PURE__*/ jsx(NodeGeom, {
595
- pointData: pointData,
596
- pointP: pointP
628
+ children: 1 == nodeSetting.showType && NodeGeom ? /*#__PURE__*/ jsxs(View, {
629
+ data: nodeViewData,
630
+ scale: {
631
+ node: {
632
+ min: 0,
633
+ max: 1,
634
+ nice: false
635
+ },
636
+ [x]: {
637
+ type: 'cat',
638
+ values: finalXAxisValues
639
+ }
640
+ },
641
+ children: [
642
+ /*#__PURE__*/ jsx(Axis, {
643
+ name: "node",
644
+ visible: false
645
+ }),
646
+ /*#__PURE__*/ jsx(Axis, {
647
+ name: x,
648
+ visible: false
649
+ }),
650
+ /*#__PURE__*/ jsx(Legend, {
651
+ name: "color",
652
+ visible: false
653
+ }),
654
+ /*#__PURE__*/ jsx(NodeGeom, {
655
+ pointData: pointData,
656
+ pointP: pointP,
657
+ isLegend: isLegend
658
+ })
659
+ ]
597
660
  }) : 2 == nodeSetting.showType && NodeDetail ? 0 == chartOffset || chartOffset ? /*#__PURE__*/ jsx(NodeDetail, {
598
661
  chartWidth: chartWidth,
599
662
  chartOffset: chartOffset,
@@ -103,11 +103,19 @@ const GroupLine = ({ height, data, x = 'groupName', y = '', legend = 'groupType'
103
103
  });
104
104
  return Array.from(uniqueMap.values());
105
105
  }, [
106
- transformData
106
+ transformData,
107
+ legend
107
108
  ]);
108
109
  const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, y) - 22, [
109
110
  maxY
110
111
  ]);
112
+ const finalXAxisValues = useMemo(()=>{
113
+ const allXValues = transformData.map((item)=>item[x]);
114
+ return Array.from(new Set(allXValues));
115
+ }, [
116
+ transformData,
117
+ x
118
+ ]);
111
119
  return /*#__PURE__*/ jsxs(Chart, {
112
120
  height: height || 300,
113
121
  data: transformData,
@@ -118,6 +126,10 @@ const GroupLine = ({ height, data, x = 'groupName', y = '', legend = 'groupType'
118
126
  type: 'linear',
119
127
  max: maxY,
120
128
  nice: true
129
+ },
130
+ [x]: {
131
+ type: 'cat',
132
+ values: finalXAxisValues
121
133
  }
122
134
  },
123
135
  onPointMouseover: (e)=>{
@@ -284,8 +296,9 @@ const GroupLine = ({ height, data, x = 'groupName', y = '', legend = 'groupType'
284
296
  min: 0,
285
297
  max: 1
286
298
  },
287
- groupName: {
288
- type: 'cat'
299
+ [x]: {
300
+ type: 'cat',
301
+ values: finalXAxisValues
289
302
  }
290
303
  },
291
304
  children: [
@@ -293,6 +306,10 @@ const GroupLine = ({ height, data, x = 'groupName', y = '', legend = 'groupType'
293
306
  name: "node",
294
307
  visible: false
295
308
  }),
309
+ /*#__PURE__*/ jsx(Axis, {
310
+ name: x,
311
+ visible: false
312
+ }),
296
313
  /*#__PURE__*/ jsx(Legend, {
297
314
  name: "color",
298
315
  visible: false
@@ -207,11 +207,19 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
207
207
  });
208
208
  return Array.from(uniqueMap.values());
209
209
  }, [
210
- transformData
210
+ transformData,
211
+ legend
211
212
  ]);
212
213
  const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, y) - 22, [
213
214
  maxY
214
215
  ]);
216
+ const finalXAxisValues = useMemo(()=>{
217
+ const allXValues = transformData.map((item)=>item[x]);
218
+ return Array.from(new Set(allXValues));
219
+ }, [
220
+ transformData,
221
+ x
222
+ ]);
215
223
  return /*#__PURE__*/ jsxs(Chart, {
216
224
  height: height || 300,
217
225
  data: transformData,
@@ -222,6 +230,10 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
222
230
  type: 'linear',
223
231
  max: maxY,
224
232
  nice: true
233
+ },
234
+ [x]: {
235
+ type: 'cat',
236
+ values: finalXAxisValues
225
237
  }
226
238
  },
227
239
  onPointMouseover: (e)=>{
@@ -470,8 +482,9 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
470
482
  min: 0,
471
483
  max: 1
472
484
  },
473
- groupName: {
474
- type: 'cat'
485
+ [x]: {
486
+ type: 'cat',
487
+ values: finalXAxisValues
475
488
  }
476
489
  },
477
490
  children: [
@@ -479,6 +492,10 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
479
492
  name: "node",
480
493
  visible: false
481
494
  }),
495
+ /*#__PURE__*/ jsx(Axis, {
496
+ name: x,
497
+ visible: false
498
+ }),
482
499
  /*#__PURE__*/ jsx(Legend, {
483
500
  name: "color",
484
501
  visible: false
@@ -96,11 +96,19 @@ const MultipleCompareLine = ({ height, data, x = 'groupName', legend = 'groupTyp
96
96
  });
97
97
  return Array.from(uniqueMap.values());
98
98
  }, [
99
- transformData
99
+ transformData,
100
+ legend
100
101
  ]);
101
102
  const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, '') - 22, [
102
103
  maxY
103
104
  ]);
105
+ const finalXAxisValues = useMemo(()=>{
106
+ const allXValues = transformData.map((item)=>item[x]);
107
+ return Array.from(new Set(allXValues));
108
+ }, [
109
+ transformData,
110
+ x
111
+ ]);
104
112
  return /*#__PURE__*/ jsxs(Chart, {
105
113
  height: height || 300,
106
114
  data: transformData,
@@ -109,6 +117,10 @@ const MultipleCompareLine = ({ height, data, x = 'groupName', legend = 'groupTyp
109
117
  type: 'linear',
110
118
  max: maxY,
111
119
  nice: true
120
+ },
121
+ [x]: {
122
+ type: 'cat',
123
+ values: finalXAxisValues
112
124
  }
113
125
  },
114
126
  ...defaultChartConfig.baseChartConfig,
@@ -328,10 +340,12 @@ const MultipleCompareLine = ({ height, data, x = 'groupName', legend = 'groupTyp
328
340
  scale: {
329
341
  node: {
330
342
  min: 0,
331
- max: 1
343
+ max: 1,
344
+ nice: false
332
345
  },
333
- groupName: {
334
- type: 'cat'
346
+ [x]: {
347
+ type: 'cat',
348
+ values: finalXAxisValues
335
349
  }
336
350
  },
337
351
  children: [
@@ -339,6 +353,10 @@ const MultipleCompareLine = ({ height, data, x = 'groupName', legend = 'groupTyp
339
353
  name: "node",
340
354
  visible: false
341
355
  }),
356
+ /*#__PURE__*/ jsx(Axis, {
357
+ name: x,
358
+ visible: false
359
+ }),
342
360
  /*#__PURE__*/ jsx(Legend, {
343
361
  name: "color",
344
362
  visible: false
@@ -96,11 +96,19 @@ const MultipleLine = ({ height, data, x = 'groupName', legend = 'groupType', ind
96
96
  });
97
97
  return Array.from(uniqueMap.values());
98
98
  }, [
99
- transformData
99
+ transformData,
100
+ legend
100
101
  ]);
101
102
  const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, '') - 22, [
102
103
  maxY
103
104
  ]);
105
+ const finalXAxisValues = useMemo(()=>{
106
+ const allXValues = transformData.map((item)=>item[x]);
107
+ return Array.from(new Set(allXValues));
108
+ }, [
109
+ transformData,
110
+ x
111
+ ]);
104
112
  return /*#__PURE__*/ jsxs(Chart, {
105
113
  height: height || 300,
106
114
  data: transformData,
@@ -109,6 +117,10 @@ const MultipleLine = ({ height, data, x = 'groupName', legend = 'groupType', ind
109
117
  type: 'linear',
110
118
  max: maxY,
111
119
  nice: true
120
+ },
121
+ [x]: {
122
+ type: 'cat',
123
+ values: finalXAxisValues
112
124
  }
113
125
  },
114
126
  ...defaultChartConfig.baseChartConfig,
@@ -285,10 +297,12 @@ const MultipleLine = ({ height, data, x = 'groupName', legend = 'groupType', ind
285
297
  scale: {
286
298
  node: {
287
299
  min: 0,
288
- max: 1
300
+ max: 1,
301
+ nice: false
289
302
  },
290
- groupName: {
291
- type: 'cat'
303
+ [x]: {
304
+ type: 'cat',
305
+ values: finalXAxisValues
292
306
  }
293
307
  },
294
308
  children: [
@@ -296,6 +310,10 @@ const MultipleLine = ({ height, data, x = 'groupName', legend = 'groupType', ind
296
310
  name: "node",
297
311
  visible: false
298
312
  }),
313
+ /*#__PURE__*/ jsx(Axis, {
314
+ name: x,
315
+ visible: false
316
+ }),
299
317
  /*#__PURE__*/ jsx(Legend, {
300
318
  name: "color",
301
319
  visible: false
@@ -22,10 +22,6 @@ const NodeGeom = ({ pointData, pointP, isLegend = true })=>/*#__PURE__*/ jsxs(Fr
22
22
  name: "node",
23
23
  visible: false
24
24
  }),
25
- /*#__PURE__*/ jsx(Axis, {
26
- name: "groupName",
27
- visible: false
28
- }),
29
25
  isLegend && /*#__PURE__*/ jsx(Legend, {
30
26
  name: "color",
31
27
  visible: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@publishfx/publish-chart",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
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": [
@@ -20,7 +20,9 @@
20
20
  },
21
21
  "types": "./dist/index.d.ts",
22
22
  "files": [
23
- "dist"
23
+ "dist",
24
+ "CHANGELOG.md",
25
+ "README.md"
24
26
  ],
25
27
  "devDependencies": {
26
28
  "@antv/data-set": "^0.11.8",