sea-chart 2.0.22 → 2.0.23

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.
@@ -699,6 +699,21 @@ class ChartComponent extends _react.Component {
699
699
  const groupsData = this.getLegendDataGroups(legendData);
700
700
  const legendWrapper = this.chart.append('g').attr('class', 'legend-wrapper');
701
701
 
702
+ // legend offset bottom and When there is only one line of legend, it is displayed in the center (for scatter chart)
703
+ if (bottomLegendSpace) {
704
+ queueMicrotask(() => {
705
+ let curTranslateX = 0;
706
+ const curTranslateY = bottomLegendSpace ? chartHeight - bottomLegendSpace : 0;
707
+ if (groupsData.length === 1) {
708
+ const {
709
+ width
710
+ } = legendWrapper.node().getBoundingClientRect();
711
+ curTranslateX = (chartWidth - width - insertPadding * 2) / 2;
712
+ }
713
+ legendWrapper.attr('transform', "translate(".concat(curTranslateX, ",").concat(curTranslateY, ")"));
714
+ });
715
+ }
716
+
702
717
  // Render first group legend
703
718
  this.renderLegend({
704
719
  legendWrapper,
@@ -768,8 +783,7 @@ class ChartComponent extends _react.Component {
768
783
  } = g.node().parentNode.getBoundingClientRect();
769
784
  groupTranslateY = groupTranslateY + height + legendItemMargin;
770
785
  }
771
- const curTranslateY = bottomLegendSpace ? chartHeight - bottomLegendSpace : groupTranslateY; // pageNavigator offset bottom
772
- g.attr('transform', "translate(".concat(groupTranslateX, ", ").concat(curTranslateY, ")"));
786
+ g.attr('transform', "translate(".concat(groupTranslateX, ", ").concat(groupTranslateY, ")"));
773
787
  });
774
788
  }
775
789
  };
@@ -994,20 +1008,15 @@ class ChartComponent extends _react.Component {
994
1008
  }
995
1009
  };
996
1010
  this.setLegendItemOffset = (legendItems, end) => {
997
- const {
998
- height: chartHeight,
999
- bottomLegendSpace
1000
- } = this.chartBoundingClientRect;
1001
1011
  const endItem = legendItems[legendItems.length - 1];
1002
1012
  const endTranslateX = Number(endItem.getAttribute('data-translateX'));
1003
1013
  const {
1004
1014
  width: endWidth
1005
1015
  } = endItem.getBoundingClientRect();
1006
1016
  const offset = end - (endTranslateX + endWidth);
1007
- const curTranslateY = bottomLegendSpace ? chartHeight - bottomLegendSpace : 0; // legend offset bottom
1008
1017
  legendItems.forEach(legendItem => {
1009
1018
  const curTranslateX = Number(legendItem.getAttribute('data-translateX')) + offset;
1010
- d3.select(legendItem).attr('transform', "translate(".concat(curTranslateX, ", ").concat(curTranslateY, ")")).attr('data-translateX', curTranslateX);
1019
+ d3.select(legendItem).attr('transform', "translate(".concat(curTranslateX, ", 0)")).attr('data-translateX', curTranslateX);
1011
1020
  d3.select(legendItem).attr('opacity', 1);
1012
1021
  });
1013
1022
  };
@@ -268,7 +268,7 @@ class Scatter extends _chartComponent.default {
268
268
  this.setLegend({
269
269
  legendName: 'groupby',
270
270
  theme,
271
- legendPosition: 'top-right',
271
+ legendPosition: 'top-left',
272
272
  data,
273
273
  groupColumn: this.props.columnGroupbyColumn,
274
274
  chart,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@dnd-kit/core": "^6.1.0",