sea-chart 2.0.21 → 2.0.22
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.
- package/dist/assets/css/sea-chart-d3-tooltip.css +2 -1
- package/dist/components/types-dialog/index.js +1 -1
- package/dist/view/wrapper/area-group.js +20 -20
- package/dist/view/wrapper/area.js +20 -20
- package/dist/view/wrapper/bar-compare.js +9 -7
- package/dist/view/wrapper/bar-custom-stack.js +7 -7
- package/dist/view/wrapper/bar-group.js +16 -7
- package/dist/view/wrapper/bar-stack.js +28 -15
- package/dist/view/wrapper/bar.js +23 -10
- package/dist/view/wrapper/chart-component.js +108 -21
- package/dist/view/wrapper/combination.js +504 -0
- package/dist/view/wrapper/completeness-group.js +12 -12
- package/dist/view/wrapper/completeness.js +10 -10
- package/dist/view/wrapper/horizontal-bar-group.js +21 -8
- package/dist/view/wrapper/horizontal-bar-stack.js +22 -13
- package/dist/view/wrapper/horizontal-bar.js +17 -7
- package/dist/view/wrapper/index.js +7 -0
- package/package.json +1 -1
|
@@ -69,7 +69,8 @@ class BarStack extends _chartComponent.default {
|
|
|
69
69
|
globalTheme,
|
|
70
70
|
chartColorTheme,
|
|
71
71
|
tables,
|
|
72
|
-
columnGroupbyColumn
|
|
72
|
+
columnGroupbyColumn,
|
|
73
|
+
summaryColumn
|
|
73
74
|
} = this.props;
|
|
74
75
|
const {
|
|
75
76
|
display_goal_line,
|
|
@@ -78,6 +79,7 @@ class BarStack extends _chartComponent.default {
|
|
|
78
79
|
} = chart.style_config || {};
|
|
79
80
|
const {
|
|
80
81
|
y_axis_show_value,
|
|
82
|
+
y_axis_summary_method,
|
|
81
83
|
display_each_block_data,
|
|
82
84
|
table_id,
|
|
83
85
|
column_groupby_column_key,
|
|
@@ -107,11 +109,11 @@ class BarStack extends _chartComponent.default {
|
|
|
107
109
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min, y_axis_max]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
108
110
|
|
|
109
111
|
// Y axis
|
|
110
|
-
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
|
+
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', "translate(".concat(insertPadding, ",0)")).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, d, y_axis_summary_method))).call(g => this.drawYaxis(g, theme));
|
|
111
113
|
const x = d3.scaleBand().domain(d3.group(data, d => d.name).keys()).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
112
114
|
|
|
113
115
|
// X axis
|
|
114
|
-
this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
116
|
+
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
115
117
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
116
118
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
117
119
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
@@ -120,14 +122,14 @@ class BarStack extends _chartComponent.default {
|
|
|
120
122
|
});
|
|
121
123
|
|
|
122
124
|
// Rect group
|
|
123
|
-
this.
|
|
124
|
-
this.
|
|
125
|
+
this.contentWrapper = this.chart.append('g').attr('class', 'content-wrapper');
|
|
126
|
+
this.contentWrapper.selectAll().data(series).join('g').attr('data-key', d => d.key).selectAll('rect').data(D => {
|
|
125
127
|
const data = D.map(d => {
|
|
126
128
|
d.key = D.key;
|
|
127
129
|
return d;
|
|
128
130
|
});
|
|
129
131
|
return data;
|
|
130
|
-
}).join('rect').attr('x', d => x(d.data[0])).attr('y', d => y(d[1])).attr('height', d => {
|
|
132
|
+
}).join('rect').attr('opacity', 1).attr('x', d => x(d.data[0])).attr('y', d => y(d[1])).attr('height', d => {
|
|
131
133
|
const height = y(d[0]) - y(d[1]);
|
|
132
134
|
return (0, _lodashEs.isNaN)(height) ? 0 : height;
|
|
133
135
|
}).attr('width', x.bandwidth()).attr('fill', d => this.colorMap[d.key] || _constants.CHART_STYLE_COLORS[0]).attr('data-value', d => {
|
|
@@ -202,6 +204,13 @@ class BarStack extends _chartComponent.default {
|
|
|
202
204
|
return groupRects;
|
|
203
205
|
};
|
|
204
206
|
this.showTooltip = event => {
|
|
207
|
+
const {
|
|
208
|
+
summaryColumn,
|
|
209
|
+
chart
|
|
210
|
+
} = this.props;
|
|
211
|
+
const {
|
|
212
|
+
y_axis_summary_method
|
|
213
|
+
} = chart;
|
|
205
214
|
const offsetX = d3.pointer(event)[0];
|
|
206
215
|
const offsetY = d3.pointer(event)[1];
|
|
207
216
|
const curRect = event.currentTarget;
|
|
@@ -212,7 +221,7 @@ class BarStack extends _chartComponent.default {
|
|
|
212
221
|
items: [{
|
|
213
222
|
color: this.colorMap[curGroup.getAttribute('data-key')],
|
|
214
223
|
name: curGroup.getAttribute('data-key'),
|
|
215
|
-
value: curRect.getAttribute('data-value')
|
|
224
|
+
value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(curRect.getAttribute('data-value')), y_axis_summary_method)
|
|
216
225
|
}]
|
|
217
226
|
};
|
|
218
227
|
this.setState({
|
|
@@ -241,7 +250,7 @@ class BarStack extends _chartComponent.default {
|
|
|
241
250
|
});
|
|
242
251
|
};
|
|
243
252
|
this.handleAcitveAndInActiveState = (state, event) => {
|
|
244
|
-
const allGroup = Array.from(this.
|
|
253
|
+
const allGroup = Array.from(this.contentWrapper.node().children);
|
|
245
254
|
const curGroupName = event.currentTarget.getAttribute('data-groupName');
|
|
246
255
|
this.setActiveAndInActiveState(state, allGroup, curGroupName);
|
|
247
256
|
};
|
|
@@ -250,7 +259,7 @@ class BarStack extends _chartComponent.default {
|
|
|
250
259
|
borderRadius
|
|
251
260
|
} = this.chartBoundingClientRect;
|
|
252
261
|
// Add mask rect
|
|
253
|
-
d3.select(topG).append('foreignObject').attr('x', rect.getAttribute('x')).attr('y', rect.getAttribute('y')).attr('width', xWidth).attr('height', rect.getAttribute('height')).attr('data-groupName', rect.getAttribute('data-groupName')).attr('data-value', rect.getAttribute('data-value')).on('click', (event, data) => {
|
|
262
|
+
d3.select(topG).append('foreignObject').attr('x', rect.getAttribute('x')).attr('y', rect.getAttribute('y')).attr('opacity', rect.getAttribute('opacity')).attr('width', xWidth).attr('height', rect.getAttribute('height')).attr('data-groupName', rect.getAttribute('data-groupName')).attr('data-value', rect.getAttribute('data-value')).on('click', (event, data) => {
|
|
254
263
|
this.props.toggleRecords(data);
|
|
255
264
|
}).on('mouseover', event => {
|
|
256
265
|
this.showTooltip(event);
|
|
@@ -268,10 +277,12 @@ class BarStack extends _chartComponent.default {
|
|
|
268
277
|
this.addLabelByEachStack = (data, topG, rect, x) => {
|
|
269
278
|
const {
|
|
270
279
|
globalTheme,
|
|
271
|
-
chart
|
|
280
|
+
chart,
|
|
281
|
+
summaryColumn
|
|
272
282
|
} = this.props;
|
|
273
283
|
const {
|
|
274
|
-
label_font_size
|
|
284
|
+
label_font_size,
|
|
285
|
+
y_axis_summary_method
|
|
275
286
|
} = chart.config;
|
|
276
287
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
277
288
|
const groupData = d3.group(data, d => d.name);
|
|
@@ -285,16 +296,18 @@ class BarStack extends _chartComponent.default {
|
|
|
285
296
|
y: Number(rect.getAttribute('y')),
|
|
286
297
|
theme,
|
|
287
298
|
label_font_size,
|
|
288
|
-
text: stackSum
|
|
299
|
+
text: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(stackSum), y_axis_summary_method)
|
|
289
300
|
});
|
|
290
301
|
};
|
|
291
302
|
this.handleLabelToRectCenter = (g, xWidth) => {
|
|
292
303
|
const {
|
|
293
304
|
globalTheme,
|
|
294
|
-
chart
|
|
305
|
+
chart,
|
|
306
|
+
summaryColumn
|
|
295
307
|
} = this.props;
|
|
296
308
|
const {
|
|
297
|
-
label_font_size
|
|
309
|
+
label_font_size,
|
|
310
|
+
y_axis_summary_method
|
|
298
311
|
} = chart.config;
|
|
299
312
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
300
313
|
g._parents.forEach(group => {
|
|
@@ -309,7 +322,7 @@ class BarStack extends _chartComponent.default {
|
|
|
309
322
|
yheight: Number(rect.getAttribute('height')),
|
|
310
323
|
theme,
|
|
311
324
|
label_font_size,
|
|
312
|
-
text: rect.getAttribute('data-value')
|
|
325
|
+
text: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(rect.getAttribute('data-value')), y_axis_summary_method)
|
|
313
326
|
});
|
|
314
327
|
});
|
|
315
328
|
});
|
package/dist/view/wrapper/bar.js
CHANGED
|
@@ -79,6 +79,13 @@ class Bar extends _chartComponent.default {
|
|
|
79
79
|
return color || chartBarColor;
|
|
80
80
|
};
|
|
81
81
|
this.showTooltip = (event, data, title) => {
|
|
82
|
+
const {
|
|
83
|
+
summaryColumn,
|
|
84
|
+
chart
|
|
85
|
+
} = this.props;
|
|
86
|
+
const {
|
|
87
|
+
y_axis_summary_method
|
|
88
|
+
} = chart.config;
|
|
82
89
|
const {
|
|
83
90
|
offsetX,
|
|
84
91
|
offsetY
|
|
@@ -88,7 +95,7 @@ class Bar extends _chartComponent.default {
|
|
|
88
95
|
items: [{
|
|
89
96
|
color: this.getFillColor(data),
|
|
90
97
|
name: data.name,
|
|
91
|
-
value: data.value
|
|
98
|
+
value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(data.value), y_axis_summary_method)
|
|
92
99
|
}]
|
|
93
100
|
};
|
|
94
101
|
this.setState({
|
|
@@ -127,7 +134,8 @@ class Bar extends _chartComponent.default {
|
|
|
127
134
|
const {
|
|
128
135
|
chart,
|
|
129
136
|
globalTheme,
|
|
130
|
-
tables
|
|
137
|
+
tables,
|
|
138
|
+
summaryColumn
|
|
131
139
|
} = this.props;
|
|
132
140
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
133
141
|
const {
|
|
@@ -137,6 +145,7 @@ class Bar extends _chartComponent.default {
|
|
|
137
145
|
} = chart.style_config || {};
|
|
138
146
|
const {
|
|
139
147
|
y_axis_summary_type,
|
|
148
|
+
y_axis_summary_method,
|
|
140
149
|
y_axis_summary_column_key,
|
|
141
150
|
y_axis_column_key,
|
|
142
151
|
y_axis_show_value,
|
|
@@ -154,28 +163,32 @@ class Bar extends _chartComponent.default {
|
|
|
154
163
|
marginTop
|
|
155
164
|
} = this.chartBoundingClientRect;
|
|
156
165
|
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
|
-
|
|
166
|
+
|
|
167
|
+
// Y axis
|
|
168
|
+
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', "translate(".concat(insertPadding, ", 0)")).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, d, y_axis_summary_method))).call(g => this.drawYaxis(g, theme));
|
|
158
169
|
const x = d3.scaleBand().domain(data.map(item => item.name)).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
159
|
-
|
|
170
|
+
|
|
171
|
+
// X axis
|
|
172
|
+
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', "translate(0, ".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
160
173
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
161
174
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
162
175
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
163
176
|
g.selectAll('text').attr('fill', theme.textColor);
|
|
164
177
|
this.checkTickOverlap(g);
|
|
165
178
|
});
|
|
166
|
-
const
|
|
167
|
-
|
|
179
|
+
const contentWrapper = this.chart.append('g').attr('class', 'content-wrapper');
|
|
180
|
+
contentWrapper.selectAll().data(data).join('rect').attr('opacity', 1).attr('fill', d => d3.color(this.getFillColor(d))).attr('data-x', d => x(d.name)).attr('data-y', d => y(d.value)).attr('data-width', x.bandwidth()).attr('data-value', d => d.value).attr('data-groupName', d => d.name).attr('data-slugid', d => d.slugId).attr('x', d => x(d.name)).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value)).call(g => {
|
|
168
181
|
g.nodes().forEach(path => {
|
|
169
182
|
// Add label
|
|
170
183
|
if (y_axis_show_value) {
|
|
171
184
|
this.addLabelToRectTop({
|
|
172
|
-
container:
|
|
185
|
+
container: contentWrapper.node(),
|
|
173
186
|
xWidth: Number(path.dataset.width),
|
|
174
187
|
x: Number(path.dataset.x),
|
|
175
188
|
y: Number(path.dataset.y),
|
|
176
189
|
theme,
|
|
177
190
|
label_font_size,
|
|
178
|
-
text: path.dataset.value
|
|
191
|
+
text: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(path.dataset.value), y_axis_summary_method)
|
|
179
192
|
});
|
|
180
193
|
}
|
|
181
194
|
// add rect borderRadius
|
|
@@ -192,8 +205,8 @@ class Bar extends _chartComponent.default {
|
|
|
192
205
|
this.handleAcitveAndInActiveState('inActive', event);
|
|
193
206
|
}).on('mousemove', event => {
|
|
194
207
|
this.moveTooltip(event);
|
|
195
|
-
}).on('mouseleave',
|
|
196
|
-
this.hiddenTooltip();
|
|
208
|
+
}).on('mouseleave', event => {
|
|
209
|
+
this.hiddenTooltip(event);
|
|
197
210
|
this.handleAcitveAndInActiveState('active', event);
|
|
198
211
|
});
|
|
199
212
|
if (display_goal_line && goal_label && goal_value) {
|
|
@@ -13,7 +13,6 @@ var _dtableUtils = require("dtable-utils");
|
|
|
13
13
|
var _utils = require("../../utils");
|
|
14
14
|
var _constants = require("../../constants");
|
|
15
15
|
var _intl = _interopRequireDefault(require("../../intl"));
|
|
16
|
-
var _columnUtils = require("../../utils/column-utils");
|
|
17
16
|
require("../../assets/css/sea-chart-d3-tooltip.css");
|
|
18
17
|
class ChartComponent extends _react.Component {
|
|
19
18
|
constructor(props) {
|
|
@@ -57,9 +56,10 @@ class ChartComponent extends _react.Component {
|
|
|
57
56
|
} = container.getBoundingClientRect();
|
|
58
57
|
const {
|
|
59
58
|
marginLeft = 0,
|
|
59
|
+
marginRight = 0,
|
|
60
60
|
marginBottom = 0
|
|
61
61
|
} = initConfig;
|
|
62
|
-
const width = containerWidth - marginLeft;
|
|
62
|
+
const width = containerWidth - marginLeft - marginRight;
|
|
63
63
|
const height = containerHeight - marginBottom;
|
|
64
64
|
_this.chart = d3.create('svg').attr('id', id).attr('width', width).attr('height', height).attr('viewBox', [0, 0, width, height]);
|
|
65
65
|
_this.container.appendChild(_this.chart.node());
|
|
@@ -239,7 +239,17 @@ class ChartComponent extends _react.Component {
|
|
|
239
239
|
x_axis_label_position,
|
|
240
240
|
y_axis_summary_type,
|
|
241
241
|
type,
|
|
242
|
-
title_name
|
|
242
|
+
title_name,
|
|
243
|
+
// left axis - combination chart
|
|
244
|
+
show_y_axis_left_label,
|
|
245
|
+
y_axis_left_label_position,
|
|
246
|
+
y_axis_left_summary_type,
|
|
247
|
+
y_axis_left_summary_column,
|
|
248
|
+
// right axis - combination chart
|
|
249
|
+
show_y_axis_right_label,
|
|
250
|
+
y_axis_right_label_position,
|
|
251
|
+
y_axis_right_summary_type,
|
|
252
|
+
y_axis_right_summary_column
|
|
243
253
|
} = chart.config;
|
|
244
254
|
if (y_axis_summary_column_key) {
|
|
245
255
|
y_axis_column_key = y_axis_summary_column_key;
|
|
@@ -247,6 +257,8 @@ class ChartComponent extends _react.Component {
|
|
|
247
257
|
const table = (0, _dtableUtils.getTableById)(tables, table_id);
|
|
248
258
|
let textColor;
|
|
249
259
|
this.globalTheme === _constants.THEME_NAME_MAP.DARK ? textColor = '#fff' : textColor = '#999';
|
|
260
|
+
|
|
261
|
+
// xAxis
|
|
250
262
|
const xAxisID = "chart-x-axis-label_".concat(chart.id);
|
|
251
263
|
const xLabel = chartContainer === null || chartContainer === void 0 ? void 0 : chartContainer.querySelector("#".concat(xAxisID));
|
|
252
264
|
const {
|
|
@@ -267,6 +279,8 @@ class ChartComponent extends _react.Component {
|
|
|
267
279
|
if (xLabel && !x_axis_show_label) {
|
|
268
280
|
xLabel.parentNode.removeChild(xLabel);
|
|
269
281
|
}
|
|
282
|
+
|
|
283
|
+
// yAxis
|
|
270
284
|
const yAxisID = "chart-y-axis-label_".concat(chart.id);
|
|
271
285
|
const yLabel = chartContainer.querySelector("#".concat(yAxisID));
|
|
272
286
|
const divHeight = 20;
|
|
@@ -304,6 +318,68 @@ class ChartComponent extends _react.Component {
|
|
|
304
318
|
if (yLabel && !y_axis_show_label) {
|
|
305
319
|
yLabel.parentNode.removeChild(yLabel);
|
|
306
320
|
}
|
|
321
|
+
|
|
322
|
+
// yAxis(left) - combination chart
|
|
323
|
+
const yAxisLeftID = "chart-y-axis-left-label_".concat(chart.id);
|
|
324
|
+
const yAxisLeftLabel = chartContainer.querySelector("#".concat(yAxisLeftID));
|
|
325
|
+
if (!yAxisLeftLabel && show_y_axis_left_label) {
|
|
326
|
+
const div = document.createElement('div');
|
|
327
|
+
div.id = yAxisLeftID;
|
|
328
|
+
div.className = 'chart-axis-label text-truncate';
|
|
329
|
+
if (y_axis_left_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
330
|
+
div.innerHTML = _intl.default.get('Amount');
|
|
331
|
+
} else {
|
|
332
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_left_summary_column) || {};
|
|
333
|
+
div.innerHTML = column.name || '';
|
|
334
|
+
}
|
|
335
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
336
|
+
let textAlign = 'center';
|
|
337
|
+
if (y_axis_left_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
338
|
+
if (y_axis_left_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
339
|
+
div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
|
|
340
|
+
chartContainer.appendChild(div);
|
|
341
|
+
}
|
|
342
|
+
if (yAxisLeftLabel && show_y_axis_left_label) {
|
|
343
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
344
|
+
let textAlign = 'center';
|
|
345
|
+
if (y_axis_left_label_position === 'bottom') textAlign = 'left';
|
|
346
|
+
if (y_axis_left_label_position === 'top') textAlign = 'right';
|
|
347
|
+
yAxisLeftLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
|
|
348
|
+
}
|
|
349
|
+
if (yAxisLeftLabel && !show_y_axis_left_label) {
|
|
350
|
+
yAxisLeftLabel.parentNode.removeChild(yAxisLeftLabel);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// yAxis(right) - combination chart
|
|
354
|
+
const yAxisRightID = "chart-y-axis-right-label_".concat(chart.id);
|
|
355
|
+
const yAxisRightLabel = chartContainer.querySelector("#".concat(yAxisRightID));
|
|
356
|
+
if (!yAxisRightLabel && show_y_axis_right_label) {
|
|
357
|
+
const div = document.createElement('div');
|
|
358
|
+
div.id = yAxisRightID;
|
|
359
|
+
div.className = 'chart-axis-label text-truncate';
|
|
360
|
+
if (y_axis_right_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
361
|
+
div.innerHTML = _intl.default.get('Amount');
|
|
362
|
+
} else {
|
|
363
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_right_summary_column) || {};
|
|
364
|
+
div.innerHTML = column.name || '';
|
|
365
|
+
}
|
|
366
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
367
|
+
let textAlign = 'center';
|
|
368
|
+
if (y_axis_right_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
369
|
+
if (y_axis_right_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
370
|
+
div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; right: 0; transform: translate(").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
|
|
371
|
+
chartContainer.appendChild(div);
|
|
372
|
+
}
|
|
373
|
+
if (yAxisRightLabel && show_y_axis_right_label) {
|
|
374
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
375
|
+
let textAlign = 'center';
|
|
376
|
+
if (y_axis_right_label_position === 'bottom') textAlign = 'left';
|
|
377
|
+
if (y_axis_right_label_position === 'top') textAlign = 'right';
|
|
378
|
+
yAxisRightLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; right: 0; transform: translate(").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
|
|
379
|
+
}
|
|
380
|
+
if (yAxisRightLabel && !show_y_axis_right_label) {
|
|
381
|
+
yAxisRightLabel.parentNode.removeChild(yAxisRightLabel);
|
|
382
|
+
}
|
|
307
383
|
};
|
|
308
384
|
this.renderHorizontalLabel = (chart, tables, chartContainer) => {
|
|
309
385
|
if (!this.chart || !chart) return;
|
|
@@ -599,7 +675,8 @@ class ChartComponent extends _react.Component {
|
|
|
599
675
|
legendRectWidth: 20,
|
|
600
676
|
legendRectHeight: 6,
|
|
601
677
|
r: 3,
|
|
602
|
-
legendItemPaddingTop:
|
|
678
|
+
legendItemPaddingTop: 5,
|
|
679
|
+
legendItemTextPaddingTop: 13,
|
|
603
680
|
legendItemMargin: 20,
|
|
604
681
|
legendRecTextGap: 8,
|
|
605
682
|
legendPageNavWrapperWidth: 100,
|
|
@@ -633,6 +710,7 @@ class ChartComponent extends _react.Component {
|
|
|
633
710
|
// Render Page navigator
|
|
634
711
|
if (groupsData.length > 1) {
|
|
635
712
|
const {
|
|
713
|
+
legendItemTextPaddingTop,
|
|
636
714
|
legendPageNavWrapperWidth,
|
|
637
715
|
legendItemMargin
|
|
638
716
|
} = this.legendConfig;
|
|
@@ -640,10 +718,10 @@ class ChartComponent extends _react.Component {
|
|
|
640
718
|
const pageNavigator = legendWrapper.append('g').attr('class', 'legend-flip-page');
|
|
641
719
|
|
|
642
720
|
// count
|
|
643
|
-
pageNavigator.append('text').attr('class', 'legend-count').attr('
|
|
721
|
+
pageNavigator.append('text').attr('class', 'legend-count').attr('x', 15).attr('y', legendItemTextPaddingTop).attr('fill', theme.legendTextColor).attr('font-size', theme.legendFontSize).text("".concat(curCount + 1, "/").concat(groupsData.length));
|
|
644
722
|
|
|
645
723
|
// prev page
|
|
646
|
-
pageNavigator.append('polygon').attr('class', 'legend-prev-page').attr('points', this.calcEquilateralTriangle(5,
|
|
724
|
+
pageNavigator.append('polygon').attr('class', 'legend-prev-page').attr('points', this.calcEquilateralTriangle(5, 8, 12)).attr('fill', theme.legendPageNavigatorMarkerColor).attr('opacity', curCount === 0 ? 0.45 : 1).attr('style', 'cursor: pointer;').on('click', event => {
|
|
647
725
|
if (curCount > 0) {
|
|
648
726
|
curCount--;
|
|
649
727
|
this.renderLegend({
|
|
@@ -657,7 +735,7 @@ class ChartComponent extends _react.Component {
|
|
|
657
735
|
});
|
|
658
736
|
|
|
659
737
|
// next page
|
|
660
|
-
pageNavigator.append('polygon').attr('class', 'legend-next-page').attr('points', this.calcEquilateralTriangle(45,
|
|
738
|
+
pageNavigator.append('polygon').attr('class', 'legend-next-page').attr('points', this.calcEquilateralTriangle(45, 8, 12, 'bottom')).attr('fill', theme.legendPageNavigatorMarkerColor).attr('opacity', curCount === groupsData.length - 1 ? 0.45 : 1).attr('style', 'cursor: pointer;').on('click', event => {
|
|
661
739
|
if (curCount < groupsData.length - 1) {
|
|
662
740
|
curCount++;
|
|
663
741
|
this.renderLegend({
|
|
@@ -705,6 +783,7 @@ class ChartComponent extends _react.Component {
|
|
|
705
783
|
} = _ref2;
|
|
706
784
|
const {
|
|
707
785
|
legendItemPaddingTop,
|
|
786
|
+
legendItemTextPaddingTop,
|
|
708
787
|
legendRectWidth,
|
|
709
788
|
legendRectHeight,
|
|
710
789
|
r,
|
|
@@ -741,7 +820,7 @@ class ChartComponent extends _react.Component {
|
|
|
741
820
|
// Add text
|
|
742
821
|
g.nodes().forEach(rect => {
|
|
743
822
|
const parentNode = rect.parentNode;
|
|
744
|
-
d3.select(parentNode).append('text').attr('x', legendRectWidth + legendRecTextGap).attr('fill', theme.legendTextColor).attr('font-size', theme.legendFontSize).text(this.formatterLegendName(rect.dataset.text)).attr('data-text', rect.dataset.text).attr('
|
|
823
|
+
d3.select(parentNode).append('text').attr('x', legendRectWidth + legendRecTextGap).attr('fill', theme.legendTextColor).attr('font-size', theme.legendFontSize).text(this.formatterLegendName(rect.dataset.text)).attr('data-text', rect.dataset.text).attr('y', legendItemTextPaddingTop);
|
|
745
824
|
});
|
|
746
825
|
const legendItems = Array.from(legendWrapper.node().children).filter(item => item.getAttribute('class') !== 'legend-flip-page');
|
|
747
826
|
const {
|
|
@@ -1122,6 +1201,12 @@ class ChartComponent extends _react.Component {
|
|
|
1122
1201
|
this.isShowYAxisLabel = chart => {
|
|
1123
1202
|
return !!(chart && chart.config && chart.config.y_axis_show_label);
|
|
1124
1203
|
};
|
|
1204
|
+
this.isShowYAxisLeftLabel = chart => {
|
|
1205
|
+
return !!(chart && chart.config && chart.config.show_y_axis_left_label);
|
|
1206
|
+
};
|
|
1207
|
+
this.isShowYAxisRightLabel = chart => {
|
|
1208
|
+
return !!(chart && chart.config && chart.config.show_y_axis_right_label);
|
|
1209
|
+
};
|
|
1125
1210
|
this.getThemeColors = function () {
|
|
1126
1211
|
let themeColors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
1127
1212
|
let theme = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -1132,11 +1217,10 @@ class ChartComponent extends _react.Component {
|
|
|
1132
1217
|
return themeColors || _constants.CHART_THEME_COLOR[_constants.THEME_NAME_MAP.LIGHT];
|
|
1133
1218
|
};
|
|
1134
1219
|
this.setDispalyGoalLine = (goal_label, goal_value, insertPadding, yScale) => {
|
|
1135
|
-
var _this$chart$node;
|
|
1136
1220
|
const {
|
|
1137
1221
|
width: chartWidth
|
|
1138
1222
|
} = this.chartBoundingClientRect;
|
|
1139
|
-
const annotationWrapper = this.chart.append('g').attr('class', "annotation-wrapper
|
|
1223
|
+
const annotationWrapper = this.chart.append('g').attr('class', "annotation-wrapper");
|
|
1140
1224
|
annotationWrapper.append('line').attr('stroke', '#aaa').attr('x1', insertPadding).attr('y1', yScale(goal_value)).attr('x2', chartWidth - insertPadding).attr('y2', yScale(goal_value)).attr('stroke-dasharray', '8,3').call(g => {
|
|
1141
1225
|
annotationWrapper.append('text').attr('x', chartWidth - insertPadding - 30).attr('y', yScale(goal_value) - 10).attr('fill', '#666').text(goal_label);
|
|
1142
1226
|
});
|
|
@@ -1207,9 +1291,9 @@ class ChartComponent extends _react.Component {
|
|
|
1207
1291
|
this.setActiveAndInActiveState = (state, allGroup, curGroupName, chartType) => {
|
|
1208
1292
|
if (state === 'active') {
|
|
1209
1293
|
allGroup.forEach(g => {
|
|
1210
|
-
const rects = Array.from(g.children);
|
|
1294
|
+
const rects = Array.from(g.children).filter(item => item.tagName !== 'text');
|
|
1211
1295
|
rects.forEach(item => {
|
|
1212
|
-
d3.select(item).transition().duration(
|
|
1296
|
+
d3.select(item).transition().duration(this.transitionDuration).attr('opacity', 1);
|
|
1213
1297
|
if ([_constants.CHART_TYPE.PIE, _constants.CHART_TYPE.RING].includes(chartType)) {
|
|
1214
1298
|
d3.select(item).attr('stroke-width', 2);
|
|
1215
1299
|
}
|
|
@@ -1218,10 +1302,10 @@ class ChartComponent extends _react.Component {
|
|
|
1218
1302
|
}
|
|
1219
1303
|
if (state === 'inActive') {
|
|
1220
1304
|
allGroup.forEach(g => {
|
|
1221
|
-
const rects = Array.from(g.children);
|
|
1305
|
+
const rects = Array.from(g.children).filter(item => item.tagName !== 'text');
|
|
1222
1306
|
rects.forEach(item => {
|
|
1223
1307
|
if (item.getAttribute('data-groupName') !== curGroupName) {
|
|
1224
|
-
d3.selectAll([item]).transition().duration(
|
|
1308
|
+
d3.selectAll([item]).transition().duration(this.transitionDuration).attr('opacity', 0.3);
|
|
1225
1309
|
} else {
|
|
1226
1310
|
if ([_constants.CHART_TYPE.PIE, _constants.CHART_TYPE.RING].includes(chartType)) {
|
|
1227
1311
|
d3.select(item).attr('stroke-width', 0.5);
|
|
@@ -1252,29 +1336,30 @@ class ChartComponent extends _react.Component {
|
|
|
1252
1336
|
clipRect.attr('rx', borderRadiusVal);
|
|
1253
1337
|
clipRect.attr('height', Number(rect.getAttribute('height')) + borderRadiusVal);
|
|
1254
1338
|
}
|
|
1255
|
-
const clipPath = d3.select(parentNode).append('clipPath').attr('id', rectId);
|
|
1339
|
+
const clipPath = d3.select(parentNode).append('clipPath').attr('opacity', 1).attr('id', rectId);
|
|
1256
1340
|
clipPath.node().appendChild(clipRect.node());
|
|
1257
1341
|
d3.select(rect).attr('clip-path', "url(#".concat(rectId, ")"));
|
|
1258
1342
|
};
|
|
1259
|
-
this.drawYaxis = (g, theme)
|
|
1343
|
+
this.drawYaxis = function (g, theme) {
|
|
1344
|
+
let rightAxisOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
1260
1345
|
const {
|
|
1261
1346
|
width: chartWidth,
|
|
1262
1347
|
insertPadding
|
|
1263
|
-
} =
|
|
1348
|
+
} = _this.chartBoundingClientRect;
|
|
1264
1349
|
// remove domain
|
|
1265
1350
|
g.select('.domain').remove();
|
|
1266
1351
|
|
|
1267
1352
|
// add text
|
|
1268
1353
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
1269
1354
|
g.selectAll('text').attr('fill', theme.textColor);
|
|
1270
|
-
|
|
1355
|
+
_this.checkTextOverflow(g.selectAll('text').nodes());
|
|
1271
1356
|
|
|
1272
1357
|
// line
|
|
1273
1358
|
g.selectAll('line').node() && g.selectAll('line').node().remove(); // delete the first line
|
|
1274
|
-
g.selectAll('.tick line').clone().attr('x2', chartWidth - insertPadding * 2 -
|
|
1359
|
+
g.selectAll('.tick line').clone().attr('x2', chartWidth - insertPadding * 2 - _this.horizontalOverflowOffset - rightAxisOffset).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
|
|
1275
1360
|
|
|
1276
1361
|
// update g translateX
|
|
1277
|
-
g.attr('transform', "translate(".concat(insertPadding +
|
|
1362
|
+
g.attr('transform', "translate(".concat(insertPadding + _this.horizontalOverflowOffset, ", 0)"));
|
|
1278
1363
|
};
|
|
1279
1364
|
this.checkTextOverflow = allTextEl => {
|
|
1280
1365
|
const {
|
|
@@ -1288,7 +1373,7 @@ class ChartComponent extends _react.Component {
|
|
|
1288
1373
|
});
|
|
1289
1374
|
const maxTextWidth = Math.max(...allTextWidth);
|
|
1290
1375
|
this.horizontalOverflowOffset = 0;
|
|
1291
|
-
if (maxTextWidth > insertPadding) {
|
|
1376
|
+
if (maxTextWidth + 3 > insertPadding) {
|
|
1292
1377
|
// horizontal overflow
|
|
1293
1378
|
const offset = maxTextWidth + 3 - insertPadding; // 3 is text and line default spacing
|
|
1294
1379
|
this.horizontalOverflowOffset = offset;
|
|
@@ -1443,6 +1528,8 @@ class ChartComponent extends _react.Component {
|
|
|
1443
1528
|
};
|
|
1444
1529
|
this.initLabelStroke(props === null || props === void 0 ? void 0 : props.globalTheme);
|
|
1445
1530
|
this.chartBoundingClientRect = {};
|
|
1531
|
+
this.transitionDuration = 500;
|
|
1532
|
+
this.areaTransitionDuration = 200;
|
|
1446
1533
|
}
|
|
1447
1534
|
componentDidUpdate(prevProps) {
|
|
1448
1535
|
if (prevProps.globalTheme !== this.props.globalTheme) {
|