sea-chart 2.0.15 → 2.0.17

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.
@@ -0,0 +1,400 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _classnames = _interopRequireDefault(require("classnames"));
12
+ var _lodashEs = require("lodash-es");
13
+ var d3 = _interopRequireWildcard(require("d3"));
14
+ var _constants = require("../../constants");
15
+ var _intl = _interopRequireDefault(require("../../intl"));
16
+ var _utils = require("../../utils");
17
+ var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
18
+ var _chartComponent = _interopRequireDefault(require("./chart-component"));
19
+ class Area extends _chartComponent.default {
20
+ constructor(props) {
21
+ super(props);
22
+ this.handleResize = () => {
23
+ this.chart.node() && this.chart.node().remove();
24
+ this.createChart();
25
+ this.drawChart();
26
+ };
27
+ this.createChart = () => {
28
+ const {
29
+ chart
30
+ } = this.props;
31
+ const {
32
+ y_axis_show_label,
33
+ x_axis_show_label,
34
+ y_axis_show_value
35
+ } = chart.config;
36
+ const initConfig = {
37
+ insertPadding: 30,
38
+ marginLeft: y_axis_show_label ? 20 : 0,
39
+ marginBottom: x_axis_show_label ? 20 : 0,
40
+ marginTop: y_axis_show_value ? 15 : 0
41
+ };
42
+ this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
43
+ };
44
+ this.drawChart = () => {
45
+ let {
46
+ result: data,
47
+ customRender
48
+ } = this.props;
49
+ data = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
50
+ if (!Array.isArray(data)) return;
51
+ this.draw(data);
52
+ (0, _utils.isFunction)(customRender) && customRender(this.chart);
53
+ this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
54
+ };
55
+ this.draw = data => {
56
+ const {
57
+ chart,
58
+ globalTheme,
59
+ tables
60
+ } = this.props;
61
+ const theme = _constants.CHART_THEME_COLOR[globalTheme];
62
+ const {
63
+ display_goal_line,
64
+ goal_label,
65
+ goal_value
66
+ } = chart.style_config || {};
67
+ const {
68
+ y_axis_summary_type,
69
+ y_axis_column_key,
70
+ y_axis_summary_column_key,
71
+ line_type,
72
+ y_axis_show_value,
73
+ label_font_size,
74
+ table_id,
75
+ y_axis_auto_range,
76
+ y_axis_min,
77
+ y_axis_max
78
+ } = chart.config;
79
+ const {
80
+ width: chartWidth,
81
+ height: chartHeight,
82
+ insertPadding,
83
+ marginTop
84
+ } = this.chartBoundingClientRect;
85
+ const tooltipTitle = this.getTitle(tables, table_id, y_axis_summary_type, y_axis_column_key || y_axis_summary_column_key);
86
+
87
+ // Y axis
88
+ const niceEnd = d3.nice(0, d3.max(data, d => d.value), 5)[1];
89
+ const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min || 0, y_axis_max || niceEnd]).range([chartHeight - insertPadding, insertPadding + marginTop]);
90
+ this.chart.append('g').attr('transform', "translate(".concat(insertPadding, ", 0)")).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => d)).call(g => this.drawYaxis(g, theme));
91
+
92
+ // X axis
93
+ const xDomain = data.map(item => item.name);
94
+ const x = d3.scaleBand().domain(xDomain).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
95
+ this.ticksWrapper = this.chart.append('g').attr('transform', "translate(0, ".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
96
+ this.ticksAddName(g);
97
+ g.selectAll('.domain').attr('stroke', theme.XAxisColor);
98
+ g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
99
+ g.selectAll('text').attr('font-size', theme.fontSize);
100
+ g.selectAll('text').attr('fill', theme.textColor);
101
+ this.checkTickOverlap(g);
102
+ });
103
+ const rectsWrapper = this.chart.append('g').attr('class', "rects-wrapper-".concat(chart === null || chart === void 0 ? void 0 : chart.id));
104
+
105
+ // Line
106
+ const circleData = xDomain.map(() => ({}));
107
+ const line = d3.line().x((d, index) => {
108
+ const xVal = x(d.name) + x.bandwidth() / 2;
109
+ circleData[index]['x'] = xVal;
110
+ circleData[index]['name'] = d.name;
111
+ return xVal;
112
+ }).y((d, index) => {
113
+ const yVal = y(d.value);
114
+ circleData[index]['y'] = yVal;
115
+ circleData[index]['value'] = d.value;
116
+ return yVal;
117
+ }).curve(line_type === _constants.CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
118
+ this.Line = rectsWrapper.append('path').attr('fill', 'none').attr('stroke', this.getAreaColor()).attr('stroke-width', 2).attr('d', () => line(data));
119
+
120
+ // Area
121
+ const area = d3.area().x(d => {
122
+ const xVal = x(d.name) + x.bandwidth() / 2;
123
+ return xVal;
124
+ }).y0(y(0)).y1(d => y(d.value)).curve(line_type === _constants.CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
125
+ this.Area = rectsWrapper.append('path').attr('fill', this.getAreaColor()).attr('d', () => area(data)).attr('opacity', '0.3');
126
+
127
+ // circle
128
+ circleData.forEach(item => {
129
+ rectsWrapper.append('circle').attr('cx', item.x).attr('cy', item.y).attr('r', 3).attr('fill', this.getAreaColor()).attr('opacity', y_axis_show_value ? 1 : 0).attr('data-text', item.value).attr('data-name', item.name).call(g => {
130
+ // circle label
131
+ if (y_axis_show_value) {
132
+ const curCircleEl = g.node();
133
+ rectsWrapper.append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(curCircleEl.getAttribute('data-text')).call(g => {
134
+ const {
135
+ width
136
+ } = g.node().getBoundingClientRect();
137
+ const translateX = Number(curCircleEl.getAttribute('cx')) - width / 2;
138
+ const translateY = Number(curCircleEl.getAttribute('cy')) - 10;
139
+ g.attr('transform', "translate(".concat(translateX, ", ").concat(translateY, ")"));
140
+ });
141
+ }
142
+ }).on('click', (event, data) => {
143
+ this.props.toggleRecords(data);
144
+ });
145
+ });
146
+ this.chart.on('mouseover', event => {
147
+ this.updateCircleAndTickStyle({
148
+ event,
149
+ state: 'zoomIn',
150
+ circleData,
151
+ rectsWrapper,
152
+ eventState: 'over',
153
+ tooltipTitle
154
+ });
155
+ }).on('mousemove', event => {
156
+ this.updateCircleAndTickStyle({
157
+ event,
158
+ state: 'zoomIn',
159
+ circleData,
160
+ rectsWrapper,
161
+ eventState: 'move',
162
+ tooltipTitle
163
+ });
164
+ }).on('mouseleave', event => {
165
+ this.updateCircleAndTickStyle({
166
+ event,
167
+ state: 'zoomOut',
168
+ circleData,
169
+ rectsWrapper,
170
+ eventState: 'leave',
171
+ tooltipTitle
172
+ });
173
+ });
174
+ if (display_goal_line && goal_label && goal_value) {
175
+ this.setDispalyGoalLine(goal_label, goal_value, insertPadding, y);
176
+ }
177
+ };
178
+ this.updateCircleAndTickStyle = _ref => {
179
+ var _rectsWrapper$selectA, _this$ticksWrapper$se;
180
+ let {
181
+ event,
182
+ state,
183
+ circleData,
184
+ rectsWrapper,
185
+ eventState,
186
+ tooltipTitle
187
+ } = _ref;
188
+ const {
189
+ y_axis_show_value
190
+ } = this.props.chart.config;
191
+ const {
192
+ height: chartHeight,
193
+ insertPadding,
194
+ marginTop
195
+ } = this.chartBoundingClientRect;
196
+ const {
197
+ offsetX
198
+ } = event;
199
+ const minDistanceItem = this.getMinDistanceItem(offsetX, circleData);
200
+ const circleList = (_rectsWrapper$selectA = rectsWrapper.selectAll('circle')) === null || _rectsWrapper$selectA === void 0 ? void 0 : _rectsWrapper$selectA.nodes();
201
+ if (circleList.length !== 0) {
202
+ if (state === 'zoomIn') {
203
+ circleList.forEach(circle => {
204
+ const name = circle.getAttribute('data-name');
205
+ if (name === minDistanceItem.name) {
206
+ d3.select(circle).attr('opacity', 1);
207
+ d3.select(circle).attr('r', 5);
208
+ } else {
209
+ d3.select(circle).attr('opacity', 0.3);
210
+ d3.select(circle).attr('r', 3);
211
+ }
212
+ });
213
+ this.Area.attr('opacity', 0.1);
214
+ this.Line.attr('opacity', 0.3);
215
+ } else {
216
+ circleList.forEach(circle => {
217
+ if (!y_axis_show_value) {
218
+ d3.select(circle).attr('opacity', 0);
219
+ } else {
220
+ d3.select(circle).attr('opacity', 1);
221
+ }
222
+ d3.select(circle).attr('r', 3);
223
+ });
224
+ this.Area.attr('opacity', 0.3);
225
+ this.Line.attr('opacity', 1);
226
+ }
227
+ }
228
+ const ticks = (_this$ticksWrapper$se = this.ticksWrapper.selectAll('.tick line')) === null || _this$ticksWrapper$se === void 0 ? void 0 : _this$ticksWrapper$se.nodes();
229
+ if (ticks.length !== 0) {
230
+ if (state === 'zoomIn') {
231
+ ticks.forEach(tick => {
232
+ const name = tick.getAttribute('data-name');
233
+ if (name === minDistanceItem.name) {
234
+ d3.select(tick).attr('y2', -(chartHeight - insertPadding * 2 - marginTop));
235
+ } else {
236
+ d3.select(tick).attr('y2', 0);
237
+ }
238
+ });
239
+ } else {
240
+ ticks.forEach(tick => {
241
+ d3.select(tick).attr('y2', 0);
242
+ });
243
+ }
244
+ }
245
+
246
+ // tooltip
247
+ if (eventState === 'over') {
248
+ this.showTooltip(event, minDistanceItem, tooltipTitle);
249
+ }
250
+ if (eventState === 'move') {
251
+ this.moveTooltip(event, minDistanceItem, tooltipTitle);
252
+ }
253
+ if (eventState === 'leave') {
254
+ this.hiddenTooltip();
255
+ }
256
+ };
257
+ this.showTooltip = (event, data, title) => {
258
+ const {
259
+ offsetX,
260
+ offsetY
261
+ } = event;
262
+ const {
263
+ chart,
264
+ summaryColumn
265
+ } = this.props;
266
+ const {
267
+ y_axis_summary_method
268
+ } = chart.config;
269
+ const newTooltipData = {
270
+ title: title,
271
+ items: [{
272
+ color: this.getAreaColor(),
273
+ name: data.name,
274
+ value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, data.value, y_axis_summary_method)
275
+ }]
276
+ };
277
+ this.setState({
278
+ tooltipData: newTooltipData
279
+ });
280
+ this.setState({
281
+ toolTipPosition: {
282
+ offsetX,
283
+ offsetY
284
+ }
285
+ });
286
+ };
287
+ this.moveTooltip = (event, data, title) => {
288
+ const {
289
+ offsetX,
290
+ offsetY
291
+ } = event;
292
+ const {
293
+ chart,
294
+ summaryColumn
295
+ } = this.props;
296
+ const {
297
+ y_axis_summary_method
298
+ } = chart.config;
299
+ const newTooltipData = {
300
+ title: title,
301
+ items: [{
302
+ color: this.getAreaColor(),
303
+ name: data.name,
304
+ value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, data.value, y_axis_summary_method)
305
+ }]
306
+ };
307
+ this.setState({
308
+ tooltipData: newTooltipData
309
+ });
310
+ this.setState({
311
+ toolTipPosition: {
312
+ offsetX,
313
+ offsetY
314
+ }
315
+ });
316
+ };
317
+ this.hiddenTooltip = event => {
318
+ this.setState({
319
+ toolTipPosition: null
320
+ });
321
+ };
322
+ this.getAreaColor = () => {
323
+ const {
324
+ chart,
325
+ chartColorTheme
326
+ } = this.props;
327
+ const {
328
+ y_axis_label_color,
329
+ color_option
330
+ } = chart.config;
331
+ let chartBarColor = _constants.CHART_STYLE_COLORS[0];
332
+ if (chartColorTheme) {
333
+ chartBarColor = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
334
+ }
335
+ if (color_option === _constants.TYPE_COLOR_USING.USE_SPECIFIC_COLORS && y_axis_label_color) {
336
+ chartBarColor = y_axis_label_color;
337
+ }
338
+ return chartBarColor;
339
+ };
340
+ this.chart = null;
341
+ this.state = {
342
+ tooltipData: null,
343
+ toolTipPosition: null
344
+ };
345
+ }
346
+ componentDidMount() {
347
+ this.createChart();
348
+ this.drawChart();
349
+ this.debouncedHandleResize = (0, _lodashEs.debounce)(this.handleResize, 300);
350
+ window.addEventListener('resize', this.debouncedHandleResize);
351
+ super.componentDidMount();
352
+ }
353
+ componentDidUpdate(prevProps) {
354
+ super.componentDidUpdate(prevProps);
355
+ if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
356
+ this.chart.node() && this.chart.node().remove();
357
+ this.createChart();
358
+ this.drawChart();
359
+ }
360
+ }
361
+ componentWillUnmount() {
362
+ this.chart.node() && this.chart.node().remove();
363
+ window.removeEventListener('resize', this.debouncedHandleResize);
364
+ super.componentWillUnmount();
365
+ }
366
+ render() {
367
+ const {
368
+ chart
369
+ } = this.props;
370
+ const {
371
+ tooltipData,
372
+ toolTipPosition
373
+ } = this.state;
374
+ return /*#__PURE__*/_react.default.createElement("div", {
375
+ ref: ref => this.container = ref,
376
+ className: (0, _classnames.default)('sea-chart-container', {
377
+ 'show-x-axis-label': this.isShowXAxisLabel(chart),
378
+ 'show-y-axis-label': this.isShowYAxisLabel(chart)
379
+ })
380
+ }, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
381
+ tooltipData: tooltipData,
382
+ toolTipPosition: toolTipPosition,
383
+ chart: this.chart
384
+ }));
385
+ }
386
+ }
387
+ Area.propTypes = {
388
+ canvasStyle: _propTypes.default.object,
389
+ chart: _propTypes.default.object,
390
+ groupbyColumn: _propTypes.default.object,
391
+ columnGroupbyColumn: _propTypes.default.object,
392
+ summaryColumn: _propTypes.default.object,
393
+ result: _propTypes.default.array,
394
+ tables: _propTypes.default.array,
395
+ globalTheme: _propTypes.default.string,
396
+ chartColorTheme: _propTypes.default.string,
397
+ toggleRecords: _propTypes.default.func,
398
+ customRender: _propTypes.default.func
399
+ };
400
+ var _default = exports.default = Area;
@@ -67,9 +67,9 @@ class BarCompare extends _chartComponent.default {
67
67
 
68
68
  // Y axis
69
69
  this.chart.append('g').attr('transform', "translate(".concat(insertPadding, ",0)")).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => d)).call(g => this.drawYaxis(g, theme));
70
- const fx = d3.scaleBand().domain(d3.group(data, d => d.name).keys()).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.1).paddingOuter(0.1);
70
+ const fx = d3.scaleBand().domain(d3.group(data, d => d.name).keys()).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
71
71
  const color = d3.scaleOrdinal().domain(d3.group(data, d => d.group_name).keys()).range(_chartUtils.BaseUtils.getCurrentTheme(chartColorTheme).colors).unknown('#ccc');
72
- const x = d3.scaleBand().domain(d3.group(data, d => d.group_name).keys()).range([0, fx.bandwidth()]);
72
+ const x = d3.scaleBand().domain(d3.group(data, d => d.group_name).keys()).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
73
73
 
74
74
  // X axis
75
75
  this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
@@ -206,7 +206,7 @@ class BarCompare extends _chartComponent.default {
206
206
  insertPadding
207
207
  } = this.chartBoundingClientRect;
208
208
  const circleData = increaseData.map(() => ({}));
209
- const lineX = d3.scaleBand().domain(increaseData.map(d => d.name)).range([insertPadding, chartWidth - insertPadding]).paddingInner(0.1).paddingOuter(0.1);
209
+ const lineX = d3.scaleBand().domain(increaseData.map(d => d.name)).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
210
210
  const lineY = d3.scaleLinear().domain(y_axis_auto_range ? [d3.min(increaseData, d => d.value), d3.max(increaseData, d => d.value)] : [y_axis_min, y_axis_max]).range([chartHeight - insertPadding, insertPadding]);
211
211
  const line = d3.line().x((d, index) => {
212
212
  const x = lineX(d.name) + lineX.bandwidth() / 2;
@@ -230,7 +230,7 @@ class BarCompare extends _chartComponent.default {
230
230
  // circle label
231
231
  if (display_increase_percentage) {
232
232
  const curCircleEl = g.node();
233
- wrapper.append('text').attr('fill', theme.labelColor).attr('font-size', _chartUtils.BaseUtils.getLabelFontSize(label_font_size)).text(curCircleEl.getAttribute('data-text')).call(g => {
233
+ wrapper.append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size', _chartUtils.BaseUtils.getLabelFontSize(label_font_size)).text(curCircleEl.getAttribute('data-text')).call(g => {
234
234
  const {
235
235
  width
236
236
  } = g.node().getBoundingClientRect();
@@ -147,8 +147,8 @@ class BarCustom extends _chartComponent.default {
147
147
 
148
148
  // Y axis
149
149
  this.chart.append('g').attr('transform', "translate(".concat(insertPadding, ",0)")).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => d)).call(g => this.drawYaxis(g, theme));
150
- const fx = d3.scaleBand().domain(new Set(organizedData.map(d => d.name))).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.1).paddingOuter(0.1);
151
- const x = d3.scaleBand().domain(new Set(data.map(d => d.y_axis_type))).range([0, fx.bandwidth()]);
150
+ const fx = d3.scaleBand().domain(new Set(organizedData.map(d => d.name))).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
151
+ const x = d3.scaleBand().domain(new Set(data.map(d => d.y_axis_type))).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
152
152
 
153
153
  // X axis
154
154
  this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
@@ -13,7 +13,6 @@ var _lodashEs = require("lodash-es");
13
13
  var d3 = _interopRequireWildcard(require("d3"));
14
14
  var _classnames = _interopRequireDefault(require("classnames"));
15
15
  var _intl = _interopRequireDefault(require("../../intl"));
16
- var _columnUtils = require("../../utils/column-utils");
17
16
  var _constants = require("../../constants");
18
17
  var _utils = require("../../utils");
19
18
  var _colorRules = require("../../constants/color-rules");
@@ -34,16 +33,14 @@ class BarGroup extends _chartComponent.default {
34
33
  const {
35
34
  y_axis_show_label,
36
35
  x_axis_show_label,
37
- y_axis_show_value,
38
- display_each_block_data,
39
- type
36
+ y_axis_show_value
40
37
  } = chart.config;
41
38
  const initConfig = {
42
39
  insertPadding: 30,
43
40
  borderRadius: 0.2,
44
41
  marginLeft: y_axis_show_label ? 20 : 0,
45
42
  marginBottom: x_axis_show_label ? 20 : 0,
46
- marginTop: y_axis_show_value || type === _constants.CHART_TYPE.BAR_STACK && display_each_block_data ? 15 : 0
43
+ marginTop: y_axis_show_value ? 15 : 0
47
44
  };
48
45
  this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
49
46
  };
@@ -56,16 +53,6 @@ class BarGroup extends _chartComponent.default {
56
53
  } = this.props;
57
54
  data = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
58
55
  if (!Array.isArray(data)) return;
59
- const {
60
- chart
61
- } = this.props;
62
- const {
63
- sort_type,
64
- type
65
- } = chart.config;
66
- if (type === _constants.CHART_TYPE.BAR_STACK && sort_type) {
67
- data = (0, _columnUtils.sortDataByGroupSum)(data, sort_type);
68
- }
69
56
  this.draw(data);
70
57
  this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
71
58
  (0, _utils.isFunction)(customRender) && customRender(this.chart);
@@ -89,7 +76,6 @@ class BarGroup extends _chartComponent.default {
89
76
  marginTop
90
77
  } = this.chartBoundingClientRect;
91
78
  const {
92
- type,
93
79
  y_axis_show_value,
94
80
  label_font_size,
95
81
  table_id,
@@ -97,8 +83,7 @@ class BarGroup extends _chartComponent.default {
97
83
  color_theme,
98
84
  y_axis_max,
99
85
  y_axis_min,
100
- y_axis_auto_range,
101
- display_each_block_data
86
+ y_axis_auto_range
102
87
  } = chart.config;
103
88
  const theme = _constants.CHART_THEME_COLOR[globalTheme];
104
89
  const column_groupby_column = this.getColumn(tables, table_id, column_groupby_column_key);
@@ -109,8 +94,8 @@ class BarGroup extends _chartComponent.default {
109
94
 
110
95
  // Y axis
111
96
  this.chart.append('g').attr('transform', "translate(".concat(insertPadding, ",0)")).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => d)).call(g => this.drawYaxis(g, theme));
112
- const fx = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.1).paddingOuter(0.1);
113
- const x = d3.scaleBand().domain(new Set(data.map(d => d.group_name))).range([0, fx.bandwidth()]);
97
+ const fx = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
98
+ const x = d3.scaleBand().domain(new Set(data.map(d => d.group_name))).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
114
99
 
115
100
  // X axis
116
101
  this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
@@ -143,33 +128,6 @@ class BarGroup extends _chartComponent.default {
143
128
  });
144
129
 
145
130
  // Add label
146
- if (type === _constants.CHART_TYPE.BAR_STACK) {
147
- if (y_axis_show_value) {
148
- this.addLabelToRectCenter({
149
- chartType: _constants.CHART_TYPE.BAR_STACK,
150
- container: parentNode,
151
- x: Number(rect.getAttribute('x')),
152
- y: Number(rect.getAttribute('y')),
153
- xWidth: x.bandwidth(),
154
- yheight: Number(rect.getAttribute('height')),
155
- theme,
156
- label_font_size,
157
- text: rect.getAttribute('data-value')
158
- });
159
- }
160
- if (display_each_block_data) {
161
- this.addLabelToRectTop({
162
- container: parentNode,
163
- xWidth: Number(x.bandwidth()),
164
- x: Number(rect.getAttribute('x')),
165
- y: Number(rect.getAttribute('y')),
166
- theme,
167
- label_font_size,
168
- text: rect.dataset.value
169
- });
170
- }
171
- return;
172
- }
173
131
  if (y_axis_show_value) {
174
132
  this.addLabelToRectTop({
175
133
  container: parentNode,
@@ -111,7 +111,7 @@ class BarStack extends _chartComponent.default {
111
111
 
112
112
  // Y axis
113
113
  this.chart.append('g').attr('transform', "translate(".concat(insertPadding, ",0)")).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => d)).call(g => this.drawYaxis(g, theme));
114
- const x = d3.scaleBand().domain(d3.group(data, d => d.name).keys()).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.1).paddingOuter(0.1);
114
+ const x = d3.scaleBand().domain(d3.group(data, d => d.name).keys()).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
115
115
 
116
116
  // X axis
117
117
  this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
@@ -155,7 +155,7 @@ class Bar extends _chartComponent.default {
155
155
  } = this.chartBoundingClientRect;
156
156
  const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, d3.max(data, d => d.value)] : [y_axis_min, y_axis_max]).range([chartHeight - insertPadding, insertPadding + marginTop]);
157
157
  this.chart.append('g').attr('transform', "translate(".concat(insertPadding, ", 0)")).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => d)).call(g => this.drawYaxis(g, theme));
158
- const x = d3.scaleBand().domain(data.map(item => item.name)).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.4).paddingOuter(0.1);
158
+ const x = d3.scaleBand().domain(data.map(item => item.name)).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
159
159
  this.chart.append('g').attr('transform', "translate(0, ".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
160
160
  g.selectAll('.domain').attr('stroke', theme.XAxisColor);
161
161
  g.selectAll('.tick line').attr('stroke', theme.XAxisColor);