sea-chart 2.0.59 → 2.0.60

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.
@@ -22,12 +22,9 @@ class Pie extends _chartComponent.default {
22
22
  const {
23
23
  chart
24
24
  } = this.props;
25
- const {
26
- show_legend
27
- } = chart.config;
28
25
  const initConfig = {
29
26
  insertPadding: 30,
30
- rightLegendSpace: show_legend ? 50 : 0
27
+ rightLegendSpace: 0
31
28
  };
32
29
  this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
33
30
  };
@@ -57,8 +54,7 @@ class Pie extends _chartComponent.default {
57
54
  const {
58
55
  width: chartWidth,
59
56
  height: chartHeight,
60
- insertPadding,
61
- rightLegendSpace
57
+ insertPadding
62
58
  } = this.chartBoundingClientRect;
63
59
  this.isInnerLabel = !label_position || label_position === _constants.CHART_LABEL_POSITIONS[0];
64
60
  const currentTheme = _utils.BaseUtils.getCurrentTheme(chartColorTheme);
@@ -68,6 +64,17 @@ class Pie extends _chartComponent.default {
68
64
  colorMap
69
65
  } = _utils.BaseUtils.formatPieChartData(data, chart, tables, currentTheme, useSingleSelectColumnColor);
70
66
  if (!Array.isArray(newData) || newData.length === 0) return;
67
+ const {
68
+ rightLegendSpace = 0,
69
+ chartLegendGap = 0
70
+ } = show_legend ? this.getRightLegendLayout({
71
+ data: newData,
72
+ legendName: 'name',
73
+ theme
74
+ }) : {};
75
+ this.chartBoundingClientRect.rightLegendSpace = rightLegendSpace;
76
+ const plotWidth = Math.max(0, chartWidth - insertPadding * 2 - rightLegendSpace - chartLegendGap);
77
+ const radiusWidth = show_legend ? plotWidth : chartWidth;
71
78
 
72
79
  // Only the visible categories are laid out; the legend still shows every category.
73
80
  const visibleData = this.getVisibleLegendData(newData, 'name');
@@ -80,7 +87,7 @@ class Pie extends _chartComponent.default {
80
87
  // Pie and Arc
81
88
  const pie = d3.pie().sort(null).value(d => d.value);
82
89
  const arcs = pie(visibleData);
83
- const arc = d3.arc().innerRadius(0).outerRadius(Math.min(chartWidth, chartHeight) / 2 * 0.7);
90
+ const arc = d3.arc().innerRadius(0).outerRadius(Math.min(radiusWidth, chartHeight) / 2 * 0.7);
84
91
 
85
92
  // Draw Pie
86
93
  this.chart.append('g').attr('class', 'content-wrapper').attr('stroke', 'white').selectAll().data(arcs).join('path').attr('stroke-width', 2).attr('opacity', 1).attr('fill', d => color(d.data.name)).attr('d', arc).attr('data-groupName', d => d.data.name).call(g => {
@@ -91,7 +98,7 @@ class Pie extends _chartComponent.default {
91
98
  } = (_g$node$parentNode = g.node().parentNode) === null || _g$node$parentNode === void 0 ? void 0 : _g$node$parentNode.getBoundingClientRect();
92
99
  const left = width / 2 + insertPadding;
93
100
  const top = height / 2 + insertPadding;
94
- const offsetX = (chartWidth - (insertPadding + rightLegendSpace) - insertPadding - width) / 2;
101
+ const offsetX = (plotWidth - width) / 2;
95
102
  const offsetY = (chartHeight - insertPadding - insertPadding - height) / 2;
96
103
  d3.select(g.node().parentNode).attr('transform', `translate(${left + offsetX}, ${top + offsetY})`);
97
104
 
@@ -22,12 +22,9 @@ class Ring extends _chartComponent.default {
22
22
  const {
23
23
  chart
24
24
  } = this.props;
25
- const {
26
- show_legend
27
- } = chart.config;
28
25
  const initConfig = {
29
26
  insertPadding: 30,
30
- rightLegendSpace: show_legend ? 50 : 0
27
+ rightLegendSpace: 0
31
28
  };
32
29
  this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
33
30
  };
@@ -57,8 +54,7 @@ class Ring extends _chartComponent.default {
57
54
  const {
58
55
  width: chartWidth,
59
56
  height: chartHeight,
60
- insertPadding,
61
- rightLegendSpace
57
+ insertPadding
62
58
  } = this.chartBoundingClientRect;
63
59
  this.isInnerLabel = !label_position || label_position === _constants.CHART_LABEL_POSITIONS[0];
64
60
  const currentTheme = _utils.BaseUtils.getCurrentTheme(chartColorTheme);
@@ -69,6 +65,17 @@ class Ring extends _chartComponent.default {
69
65
  total: fullTotal
70
66
  } = _utils.BaseUtils.formatPieChartData(data, chart, tables, currentTheme, useSingleSelectColumnColor);
71
67
  if (!Array.isArray(newData) || newData.length === 0) return;
68
+ const {
69
+ rightLegendSpace = 0,
70
+ chartLegendGap = 0
71
+ } = show_legend ? this.getRightLegendLayout({
72
+ data: newData,
73
+ legendName: 'name',
74
+ theme
75
+ }) : {};
76
+ this.chartBoundingClientRect.rightLegendSpace = rightLegendSpace;
77
+ const plotWidth = Math.max(0, chartWidth - insertPadding * 2 - rightLegendSpace - chartLegendGap);
78
+ const radiusWidth = show_legend ? plotWidth : chartWidth;
72
79
 
73
80
  // Only the visible categories are laid out; the legend still shows every category.
74
81
  const visibleData = this.getVisibleLegendData(newData, 'name');
@@ -82,7 +89,8 @@ class Ring extends _chartComponent.default {
82
89
  // Ring and Arc
83
90
  const pie = d3.pie().sort(null).value(d => d.value);
84
91
  const arcs = pie(visibleData);
85
- const arc = d3.arc().innerRadius(Math.min(chartWidth, chartHeight) / 2 * 0.5).outerRadius(Math.min(chartWidth, chartHeight) / 2 * 0.7);
92
+ const radius = Math.min(radiusWidth, chartHeight) / 2;
93
+ const arc = d3.arc().innerRadius(radius * 0.5).outerRadius(radius * 0.7);
86
94
 
87
95
  // Draw Ring
88
96
  this.chart.append('g').attr('class', 'content-wrapper').selectAll().data(arcs).join('path').attr('stroke', 'white').attr('stroke-width', 2).attr('opacity', 1).attr('fill', d => color(d.data.name)).attr('d', arc).attr('data-groupName', d => d.data.name).call(g => {
@@ -93,7 +101,7 @@ class Ring extends _chartComponent.default {
93
101
  } = (_g$node$parentNode = g.node().parentNode) === null || _g$node$parentNode === void 0 ? void 0 : _g$node$parentNode.getBoundingClientRect();
94
102
  const left = width / 2 + insertPadding;
95
103
  const top = height / 2 + insertPadding;
96
- const offsetX = (chartWidth - (insertPadding + rightLegendSpace) - insertPadding - width) / 2;
104
+ const offsetX = (plotWidth - width) / 2;
97
105
  const offsetY = (chartHeight - insertPadding - insertPadding - height) / 2;
98
106
  d3.select(g.node().parentNode).attr('transform', `translate(${left + offsetX}, ${top + offsetY})`);
99
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "2.0.59",
3
+ "version": "2.0.60",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@dnd-kit/core": "^6.1.0",