sea-chart 2.0.16 → 2.0.18
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/utils/chart-utils/base-utils.js +30 -0
- package/dist/view/wrapper/area-group.js +6 -4
- package/dist/view/wrapper/area.js +2 -2
- package/dist/view/wrapper/bar-compare.js +4 -4
- package/dist/view/wrapper/bar-custom-stack.js +10 -2
- package/dist/view/wrapper/bar-group.js +12 -51
- package/dist/view/wrapper/bar-stack.js +15 -17
- package/dist/view/wrapper/bar.js +1 -1
- package/dist/view/wrapper/chart-component.js +14 -13
- package/dist/view/wrapper/completeness-group.js +12 -8
- package/dist/view/wrapper/completeness.js +1 -1
- package/dist/view/wrapper/horizontal-bar-group.js +8 -5
- package/dist/view/wrapper/horizontal-bar-stack.js +11 -7
- package/dist/view/wrapper/horizontal-bar.js +1 -1
- package/dist/view/wrapper/line-group.js +5 -3
- package/dist/view/wrapper/line.js +1 -1
- package/dist/view/wrapper/pie.js +1 -1
- package/dist/view/wrapper/ring.js +1 -1
- package/package.json +1 -1
|
@@ -1780,4 +1780,34 @@ BaseUtils.isCollaboratorColumnOrMultipleColumn = columnMap => {
|
|
|
1780
1780
|
}
|
|
1781
1781
|
return false;
|
|
1782
1782
|
};
|
|
1783
|
+
BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
1784
|
+
let chart = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
1785
|
+
config: {}
|
|
1786
|
+
};
|
|
1787
|
+
const {
|
|
1788
|
+
column_groupby_multiple_numeric_column
|
|
1789
|
+
} = chart.config;
|
|
1790
|
+
if (!column_groupby_multiple_numeric_column) {
|
|
1791
|
+
if (groupColumn) {
|
|
1792
|
+
if ([_dtableUtils.CellType.SINGLE_SELECT].includes(groupColumn.type)) {
|
|
1793
|
+
data.forEach(item => {
|
|
1794
|
+
const option = groupColumn.data.options.find(option => option.name === item[groupKey]);
|
|
1795
|
+
if (option !== null && option !== void 0 && option.id) {
|
|
1796
|
+
item['group_name_id'] = option.id;
|
|
1797
|
+
item['oldName'] = item.name;
|
|
1798
|
+
item.name = item['group_name_id'];
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
_BaseUtils.sortCharts(data, groupColumn, 'name');
|
|
1802
|
+
data.forEach(item => {
|
|
1803
|
+
item.name = item['oldName'];
|
|
1804
|
+
});
|
|
1805
|
+
return data;
|
|
1806
|
+
}
|
|
1807
|
+
_BaseUtils.sortCharts(data, groupColumn, groupKey);
|
|
1808
|
+
}
|
|
1809
|
+
return data;
|
|
1810
|
+
}
|
|
1811
|
+
return data;
|
|
1812
|
+
};
|
|
1783
1813
|
var _default = exports.default = BaseUtils;
|
|
@@ -88,7 +88,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
88
88
|
marginTop
|
|
89
89
|
} = this.chartBoundingClientRect;
|
|
90
90
|
const useSingleSelectColumnColor = (columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === _dtableUtils.CellType.SINGLE_SELECT && color_theme === _colorRules.SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
91
|
-
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme);
|
|
91
|
+
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme, 'group_name', columnGroupbyColumn, chart);
|
|
92
92
|
const tooltipTitle = this.getTitle(tables, table_id, y_axis_summary_type, y_axis_column_key || y_axis_summary_column_key);
|
|
93
93
|
|
|
94
94
|
// Y axis
|
|
@@ -98,7 +98,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
98
98
|
|
|
99
99
|
// X axis
|
|
100
100
|
const xDomain = data.map(item => item.name);
|
|
101
|
-
const x = d3.scaleBand().domain(xDomain).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.
|
|
101
|
+
const x = d3.scaleBand().domain(xDomain).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
102
102
|
this.ticksWrapper = this.chart.append('g').attr('transform', "translate(0, ".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
103
103
|
this.ticksAddName(g);
|
|
104
104
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
@@ -155,7 +155,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
155
155
|
// circle label
|
|
156
156
|
if (y_axis_show_value) {
|
|
157
157
|
const curCircleEl = g.node();
|
|
158
|
-
rectsWrapper.append('text').attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(curCircleEl.getAttribute('data-text')).call(g => {
|
|
158
|
+
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 => {
|
|
159
159
|
const {
|
|
160
160
|
width
|
|
161
161
|
} = g.node().getBoundingClientRect();
|
|
@@ -204,7 +204,9 @@ class AreaGroup extends _chartComponent.default {
|
|
|
204
204
|
legendName: 'group_name',
|
|
205
205
|
theme,
|
|
206
206
|
legendPosition: 'top-right',
|
|
207
|
-
data
|
|
207
|
+
data,
|
|
208
|
+
groupColumn: this.props.columnGroupbyColumn,
|
|
209
|
+
chart
|
|
208
210
|
});
|
|
209
211
|
};
|
|
210
212
|
this.updateCircleAndTickStyle = _ref4 => {
|
|
@@ -91,7 +91,7 @@ class Area extends _chartComponent.default {
|
|
|
91
91
|
|
|
92
92
|
// X axis
|
|
93
93
|
const xDomain = data.map(item => item.name);
|
|
94
|
-
const x = d3.scaleBand().domain(xDomain).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.
|
|
94
|
+
const x = d3.scaleBand().domain(xDomain).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
95
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
96
|
this.ticksAddName(g);
|
|
97
97
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
@@ -130,7 +130,7 @@ class Area extends _chartComponent.default {
|
|
|
130
130
|
// circle label
|
|
131
131
|
if (y_axis_show_value) {
|
|
132
132
|
const curCircleEl = g.node();
|
|
133
|
-
rectsWrapper.append('text').attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(curCircleEl.getAttribute('data-text')).call(g => {
|
|
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
134
|
const {
|
|
135
135
|
width
|
|
136
136
|
} = g.node().getBoundingClientRect();
|
|
@@ -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.
|
|
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.
|
|
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();
|
|
@@ -71,6 +71,14 @@ class BarCustom extends _chartComponent.default {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
|
+
|
|
75
|
+
// sort Data
|
|
76
|
+
Object.keys(dataMap).forEach(key => {
|
|
77
|
+
const item = dataMap[key];
|
|
78
|
+
Object.keys(item).forEach(itemKey => {
|
|
79
|
+
item[itemKey].reverse();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
74
82
|
const stacksData = this.handleStacks(dataMap);
|
|
75
83
|
return stacksData;
|
|
76
84
|
};
|
|
@@ -147,8 +155,8 @@ class BarCustom extends _chartComponent.default {
|
|
|
147
155
|
|
|
148
156
|
// Y axis
|
|
149
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));
|
|
150
|
-
const fx = d3.scaleBand().domain(new Set(organizedData.map(d => d.name))).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.
|
|
151
|
-
const x = d3.scaleBand().domain(new Set(data.map(d => d.y_axis_type))).range([0, fx.bandwidth()]);
|
|
158
|
+
const fx = d3.scaleBand().domain(new Set(organizedData.map(d => d.name))).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
159
|
+
const x = d3.scaleBand().domain(new Set(data.map(d => d.y_axis_type))).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
152
160
|
|
|
153
161
|
// X axis
|
|
154
162
|
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
|
|
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);
|
|
@@ -75,7 +62,8 @@ class BarGroup extends _chartComponent.default {
|
|
|
75
62
|
chart,
|
|
76
63
|
globalTheme,
|
|
77
64
|
chartColorTheme,
|
|
78
|
-
tables
|
|
65
|
+
tables,
|
|
66
|
+
columnGroupbyColumn
|
|
79
67
|
} = this.props;
|
|
80
68
|
const {
|
|
81
69
|
display_goal_line,
|
|
@@ -89,7 +77,6 @@ class BarGroup extends _chartComponent.default {
|
|
|
89
77
|
marginTop
|
|
90
78
|
} = this.chartBoundingClientRect;
|
|
91
79
|
const {
|
|
92
|
-
type,
|
|
93
80
|
y_axis_show_value,
|
|
94
81
|
label_font_size,
|
|
95
82
|
table_id,
|
|
@@ -97,20 +84,20 @@ class BarGroup extends _chartComponent.default {
|
|
|
97
84
|
color_theme,
|
|
98
85
|
y_axis_max,
|
|
99
86
|
y_axis_min,
|
|
100
|
-
y_axis_auto_range
|
|
101
|
-
display_each_block_data
|
|
87
|
+
y_axis_auto_range
|
|
102
88
|
} = chart.config;
|
|
103
89
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
104
90
|
const column_groupby_column = this.getColumn(tables, table_id, column_groupby_column_key);
|
|
105
91
|
const useSingleSelectColumnColor = (column_groupby_column === null || column_groupby_column === void 0 ? void 0 : column_groupby_column.type) === _dtableUtils.CellType.SINGLE_SELECT && color_theme === _colorRules.SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
106
|
-
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme); // use single select column color
|
|
92
|
+
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme, 'group_name', columnGroupbyColumn, chart); // use single select column color
|
|
107
93
|
|
|
108
94
|
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]);
|
|
109
95
|
|
|
110
96
|
// Y axis
|
|
111
97
|
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.
|
|
113
|
-
const
|
|
98
|
+
const fx = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
99
|
+
const sortedData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), 'group_name', columnGroupbyColumn, chart);
|
|
100
|
+
const x = d3.scaleBand().domain(new Set(sortedData.map(d => d.group_name))).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
114
101
|
|
|
115
102
|
// X axis
|
|
116
103
|
this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
@@ -122,7 +109,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
122
109
|
});
|
|
123
110
|
|
|
124
111
|
// Rect group
|
|
125
|
-
this.chart.append('g').selectAll().data(d3.group(
|
|
112
|
+
this.chart.append('g').selectAll().data(d3.group(sortedData, d => d.name)).join('g').attr('transform', _ref => {
|
|
126
113
|
let [name, dum] = _ref;
|
|
127
114
|
// Each group is horizontally centered
|
|
128
115
|
const offset = (fx.bandwidth() - dum.length * x.bandwidth()) / 2;
|
|
@@ -143,33 +130,6 @@ class BarGroup extends _chartComponent.default {
|
|
|
143
130
|
});
|
|
144
131
|
|
|
145
132
|
// 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
133
|
if (y_axis_show_value) {
|
|
174
134
|
this.addLabelToRectTop({
|
|
175
135
|
container: parentNode,
|
|
@@ -201,7 +161,8 @@ class BarGroup extends _chartComponent.default {
|
|
|
201
161
|
theme,
|
|
202
162
|
legendPosition: 'top-right',
|
|
203
163
|
data,
|
|
204
|
-
groupColumn: this.props.columnGroupbyColumn
|
|
164
|
+
groupColumn: this.props.columnGroupbyColumn,
|
|
165
|
+
chart
|
|
205
166
|
});
|
|
206
167
|
};
|
|
207
168
|
this.showTooltip = event => {
|
|
@@ -47,23 +47,18 @@ class BarStack extends _chartComponent.default {
|
|
|
47
47
|
};
|
|
48
48
|
this.drawChart = () => {
|
|
49
49
|
const {
|
|
50
|
-
customRender
|
|
50
|
+
customRender,
|
|
51
|
+
chart
|
|
51
52
|
} = this.props;
|
|
53
|
+
const {
|
|
54
|
+
sort_type
|
|
55
|
+
} = chart.config;
|
|
52
56
|
let {
|
|
53
57
|
result: data
|
|
54
58
|
} = this.props;
|
|
55
59
|
data = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
|
|
56
60
|
if (!Array.isArray(data)) return;
|
|
57
|
-
|
|
58
|
-
chart
|
|
59
|
-
} = this.props;
|
|
60
|
-
const {
|
|
61
|
-
sort_type,
|
|
62
|
-
type
|
|
63
|
-
} = chart.config;
|
|
64
|
-
if (type === _constants.CHART_TYPE.BAR_STACK && sort_type) {
|
|
65
|
-
data = (0, _columnUtils.sortDataByGroupSum)(data, sort_type);
|
|
66
|
-
}
|
|
61
|
+
sort_type && (data = (0, _columnUtils.sortDataByGroupSum)(data, sort_type));
|
|
67
62
|
this.draw(data);
|
|
68
63
|
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
69
64
|
(0, _utils.isFunction)(customRender) && customRender(this.chart);
|
|
@@ -73,7 +68,8 @@ class BarStack extends _chartComponent.default {
|
|
|
73
68
|
chart,
|
|
74
69
|
globalTheme,
|
|
75
70
|
chartColorTheme,
|
|
76
|
-
tables
|
|
71
|
+
tables,
|
|
72
|
+
columnGroupbyColumn
|
|
77
73
|
} = this.props;
|
|
78
74
|
const {
|
|
79
75
|
display_goal_line,
|
|
@@ -94,24 +90,25 @@ class BarStack extends _chartComponent.default {
|
|
|
94
90
|
const column_groupby_column = this.getColumn(tables, table_id, column_groupby_column_key);
|
|
95
91
|
const useSingleSelectColumnColor = (column_groupby_column === null || column_groupby_column === void 0 ? void 0 : column_groupby_column.type) === _dtableUtils.CellType.SINGLE_SELECT && color_theme === _colorRules.SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
96
92
|
// use single select column color
|
|
97
|
-
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme);
|
|
93
|
+
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme, 'group_name', columnGroupbyColumn, chart);
|
|
98
94
|
const {
|
|
99
95
|
width: chartWidth,
|
|
100
96
|
height: chartHeight,
|
|
101
97
|
insertPadding,
|
|
102
98
|
marginTop
|
|
103
99
|
} = this.chartBoundingClientRect;
|
|
104
|
-
const
|
|
100
|
+
const sortedData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), 'group_name', columnGroupbyColumn, chart).reverse();
|
|
101
|
+
const series = d3.stack().keys(d3.union(sortedData.map(d => d.group_name))).value((_ref, key) => {
|
|
105
102
|
var _group$get;
|
|
106
103
|
let [_, group] = _ref;
|
|
107
104
|
return (_group$get = group.get(String(key))) === null || _group$get === void 0 ? void 0 : _group$get.value;
|
|
108
|
-
})(d3.index(
|
|
105
|
+
})(d3.index(sortedData, d => d.name, d => d.group_name));
|
|
109
106
|
const niceEnd = d3.nice(0, d3.max(series, d => d3.max(d, d => d[1])), 5)[1];
|
|
110
107
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min, y_axis_max]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
111
108
|
|
|
112
109
|
// Y axis
|
|
113
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));
|
|
114
|
-
const x = d3.scaleBand().domain(d3.group(data, d => d.name).keys()).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.
|
|
111
|
+
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
112
|
|
|
116
113
|
// X axis
|
|
117
114
|
this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
@@ -187,7 +184,8 @@ class BarStack extends _chartComponent.default {
|
|
|
187
184
|
theme,
|
|
188
185
|
legendPosition: 'top-right',
|
|
189
186
|
data,
|
|
190
|
-
groupColumn: this.props.columnGroupbyColumn
|
|
187
|
+
groupColumn: this.props.columnGroupbyColumn,
|
|
188
|
+
chart
|
|
191
189
|
});
|
|
192
190
|
};
|
|
193
191
|
// Horizontal stacking processing position vertical stacking
|
package/dist/view/wrapper/bar.js
CHANGED
|
@@ -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.
|
|
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);
|
|
@@ -258,11 +258,11 @@ class ChartComponent extends _react.Component {
|
|
|
258
258
|
div.className = 'chart-axis-label';
|
|
259
259
|
const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
|
|
260
260
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
261
|
-
div.setAttribute('style', "color:".concat(textColor, "; width: ").concat(containerWidth, "px; text-align: ").concat(x_axis_label_position, "; position: absolute"));
|
|
261
|
+
div.setAttribute('style', "color:".concat(textColor, "; width: ").concat(containerWidth, "px; text-align: ").concat(x_axis_label_position, "; position: absolute; bottom: 0;"));
|
|
262
262
|
chartContainer.appendChild(div);
|
|
263
263
|
}
|
|
264
264
|
if (xLabel && x_axis_show_label) {
|
|
265
|
-
xLabel.setAttribute('style', "color:".concat(textColor, "; width: ").concat(containerWidth, "px; text-align: ").concat(x_axis_label_position, "; position: absolute"));
|
|
265
|
+
xLabel.setAttribute('style', "color:".concat(textColor, "; width: ").concat(containerWidth, "px; text-align: ").concat(x_axis_label_position, "; position: absolute; bottom: 0;"));
|
|
266
266
|
}
|
|
267
267
|
if (xLabel && !x_axis_show_label) {
|
|
268
268
|
xLabel.parentNode.removeChild(xLabel);
|
|
@@ -592,11 +592,10 @@ class ChartComponent extends _react.Component {
|
|
|
592
592
|
legendPosition = 'top-left',
|
|
593
593
|
data,
|
|
594
594
|
colorScale,
|
|
595
|
-
groupColumn
|
|
595
|
+
groupColumn,
|
|
596
|
+
chart
|
|
596
597
|
} = _ref;
|
|
597
598
|
if (!this.chart) return;
|
|
598
|
-
data.forEach(item => item[legendName] = String(item[legendName]));
|
|
599
|
-
const legendData = (0, _lodashEs.cloneDeep)(data);
|
|
600
599
|
this.legendConfig = {
|
|
601
600
|
legendRectWidth: 20,
|
|
602
601
|
legendRectHeight: 6,
|
|
@@ -611,10 +610,9 @@ class ChartComponent extends _react.Component {
|
|
|
611
610
|
theme
|
|
612
611
|
};
|
|
613
612
|
|
|
614
|
-
// sort legend data
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
613
|
+
// sort legend data and format data
|
|
614
|
+
data.forEach(item => item[legendName] = String(item[legendName]));
|
|
615
|
+
const legendData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), legendName, groupColumn, chart);
|
|
618
616
|
const {
|
|
619
617
|
width: chartWidth,
|
|
620
618
|
insertPadding,
|
|
@@ -949,13 +947,16 @@ class ChartComponent extends _react.Component {
|
|
|
949
947
|
};
|
|
950
948
|
this.setColorMap = function (data, chartColorTheme) {
|
|
951
949
|
let groupName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'group_name';
|
|
950
|
+
let groupColumn = arguments.length > 3 ? arguments[3] : undefined;
|
|
951
|
+
let chart = arguments.length > 4 ? arguments[4] : undefined;
|
|
952
|
+
const newData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), groupName, groupColumn, chart);
|
|
952
953
|
let currentIdx = 0;
|
|
953
954
|
const defaultColors = _constants.CHART_STYLE_COLORS;
|
|
954
955
|
let colors = defaultColors;
|
|
955
956
|
if (chartColorTheme) {
|
|
956
957
|
colors = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors;
|
|
957
958
|
}
|
|
958
|
-
const colorMap =
|
|
959
|
+
const colorMap = newData.reduce((acc, cur) => {
|
|
959
960
|
if (cur[groupName] && !acc[cur[groupName]]) {
|
|
960
961
|
acc[cur[groupName]] = colors[currentIdx++ % colors.length];
|
|
961
962
|
}
|
|
@@ -1143,7 +1144,7 @@ class ChartComponent extends _react.Component {
|
|
|
1143
1144
|
label_font_size,
|
|
1144
1145
|
text
|
|
1145
1146
|
} = _ref6;
|
|
1146
|
-
d3.select(container).append('text').attr('y', Number(y) - 10).attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1147
|
+
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('y', Number(y) - 10).attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1147
1148
|
const {
|
|
1148
1149
|
width
|
|
1149
1150
|
} = g.node().getBoundingClientRect();
|
|
@@ -1161,7 +1162,7 @@ class ChartComponent extends _react.Component {
|
|
|
1161
1162
|
label_font_size,
|
|
1162
1163
|
text
|
|
1163
1164
|
} = _ref7;
|
|
1164
|
-
d3.select(container).append('text').attr('x', Number(x) + Number(xWidth) + 10).attr('y', Number(y)).attr('fill', theme.labelColor).attr('dominant-baseline', 'hanging').attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1165
|
+
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('x', Number(x) + Number(xWidth) + 10).attr('y', Number(y)).attr('fill', theme.labelColor).attr('dominant-baseline', 'hanging').attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1165
1166
|
if (g.node()) {
|
|
1166
1167
|
var _g$node;
|
|
1167
1168
|
const {
|
|
@@ -1183,7 +1184,7 @@ class ChartComponent extends _react.Component {
|
|
|
1183
1184
|
label_font_size,
|
|
1184
1185
|
text
|
|
1185
1186
|
} = _ref8;
|
|
1186
|
-
d3.select(container).append('text').attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1187
|
+
d3.select(container).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(text).call(g => {
|
|
1187
1188
|
const {
|
|
1188
1189
|
width,
|
|
1189
1190
|
height
|
|
@@ -50,7 +50,8 @@ class Completeness extends _chartComponent.default {
|
|
|
50
50
|
const {
|
|
51
51
|
chart,
|
|
52
52
|
globalTheme,
|
|
53
|
-
chartColorTheme
|
|
53
|
+
chartColorTheme,
|
|
54
|
+
columnGroupbyColumn
|
|
54
55
|
} = this.props;
|
|
55
56
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
56
57
|
const {
|
|
@@ -69,12 +70,12 @@ class Completeness extends _chartComponent.default {
|
|
|
69
70
|
} = this.chartBoundingClientRect;
|
|
70
71
|
this.markLastForCompleteness(data);
|
|
71
72
|
const colors = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors;
|
|
72
|
-
this.setColorMap(data, chartColorTheme, 'groupby');
|
|
73
|
-
const newSeries = this.getGroupSeries(data);
|
|
73
|
+
this.setColorMap(data, chartColorTheme, 'groupby', columnGroupbyColumn, chart);
|
|
74
|
+
const newSeries = this.getGroupSeries(data, columnGroupbyColumn, chart);
|
|
74
75
|
|
|
75
76
|
// Y axis
|
|
76
|
-
const fy = d3.scaleBand().domain(newSeries.map(item => item[0])).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.
|
|
77
|
-
const y = d3.scaleBand().domain(new Set(data.map(d => d.groupby))).range([0, fy.bandwidth()]);
|
|
77
|
+
const fy = d3.scaleBand().domain(newSeries.map(item => item[0])).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
78
|
+
const y = d3.scaleBand().domain(new Set(data.map(d => d.groupby))).range([0, fy.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
78
79
|
const yAxis = this.chart.append('g').call(d3.axisLeft(fy).tickSizeOuter(0).tickPadding(0).tickSizeInner(5)).call(g => {
|
|
79
80
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
80
81
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
@@ -177,7 +178,9 @@ class Completeness extends _chartComponent.default {
|
|
|
177
178
|
legendName: 'groupby',
|
|
178
179
|
theme,
|
|
179
180
|
legendPosition: 'top-right',
|
|
180
|
-
data
|
|
181
|
+
data,
|
|
182
|
+
groupColumn: columnGroupbyColumn,
|
|
183
|
+
chart
|
|
181
184
|
});
|
|
182
185
|
};
|
|
183
186
|
this.handleAcitveAndInActiveState = (state, event) => {
|
|
@@ -250,8 +253,9 @@ class Completeness extends _chartComponent.default {
|
|
|
250
253
|
toolTipPosition: null
|
|
251
254
|
});
|
|
252
255
|
};
|
|
253
|
-
this.getGroupSeries = data => {
|
|
254
|
-
const
|
|
256
|
+
this.getGroupSeries = (data, columnGroupbyColumn, chart) => {
|
|
257
|
+
const sortedData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), 'groupby', columnGroupbyColumn, chart);
|
|
258
|
+
const groups = d3.groups(sortedData, d => d.name);
|
|
255
259
|
groups.forEach((item, index) => {
|
|
256
260
|
const itemData = (0, _lodashEs.cloneDeep)(item[1]);
|
|
257
261
|
|
|
@@ -76,7 +76,7 @@ class Completeness extends _chartComponent.default {
|
|
|
76
76
|
const newSeries = this.handleSeries(series, data);
|
|
77
77
|
|
|
78
78
|
// Y axis
|
|
79
|
-
const y = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.
|
|
79
|
+
const y = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
80
80
|
const yAxis = this.chart.append('g').call(d3.axisLeft(y).tickSizeOuter(0).tickPadding(0).tickSizeInner(5)).call(g => {
|
|
81
81
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
82
82
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
@@ -69,7 +69,8 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
69
69
|
chart,
|
|
70
70
|
globalTheme,
|
|
71
71
|
chartColorTheme,
|
|
72
|
-
tables
|
|
72
|
+
tables,
|
|
73
|
+
columnGroupbyColumn
|
|
73
74
|
} = this.props;
|
|
74
75
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
75
76
|
const {
|
|
@@ -91,8 +92,9 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
91
92
|
const groupByColumn = this.getColumn(tables, table_id, column_groupby_column_key);
|
|
92
93
|
const useSingleSelectColumnColor = (groupByColumn === null || groupByColumn === void 0 ? void 0 : groupByColumn.type) === _dtableUtils.CellType.SINGLE_SELECT && color_theme === _colorRules.SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
93
94
|
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme);
|
|
94
|
-
const fy = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.1);
|
|
95
|
-
const
|
|
95
|
+
const fy = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
96
|
+
const sortedData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), 'group_name', columnGroupbyColumn, chart);
|
|
97
|
+
const y = d3.scaleBand().domain(new Set(sortedData.map(d => d.group_name))).range([0, fy.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
96
98
|
const yAxis = this.chart.append('g').call(d3.axisLeft(fy).tickSizeOuter(0).tickPadding(0).tickSizeInner(5)).call(g => {
|
|
97
99
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
98
100
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
@@ -117,7 +119,7 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
117
119
|
|
|
118
120
|
// Rect group
|
|
119
121
|
const rectsWrapper = this.chart.append('g').attr('class', "rects-wrapper-".concat(chart === null || chart === void 0 ? void 0 : chart.id)).attr('transform', "translate(".concat(Number(yAxis.node().getAttribute('data-axisWidth')), ", 0)"));
|
|
120
|
-
rectsWrapper.selectAll().data(d3.group(
|
|
122
|
+
rectsWrapper.selectAll().data(d3.group(sortedData, d => d.name)).join('g').attr('transform', _ref => {
|
|
121
123
|
let [name, dum] = _ref;
|
|
122
124
|
const offset = (fy.bandwidth() - dum.length * y.bandwidth()) / 2;
|
|
123
125
|
return "translate(0, ".concat(fy(name) + offset, ")");
|
|
@@ -170,7 +172,8 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
170
172
|
theme,
|
|
171
173
|
legendPosition: 'top-left',
|
|
172
174
|
data,
|
|
173
|
-
groupColumn: this.props.columnGroupbyColumn
|
|
175
|
+
groupColumn: this.props.columnGroupbyColumn,
|
|
176
|
+
chart
|
|
174
177
|
});
|
|
175
178
|
};
|
|
176
179
|
this.handleAcitveAndInActiveState = (state, event) => {
|
|
@@ -67,7 +67,8 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
67
67
|
chart,
|
|
68
68
|
globalTheme,
|
|
69
69
|
chartColorTheme,
|
|
70
|
-
tables
|
|
70
|
+
tables,
|
|
71
|
+
columnGroupbyColumn
|
|
71
72
|
} = this.props;
|
|
72
73
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
73
74
|
const {
|
|
@@ -87,14 +88,15 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
87
88
|
} = this.chartBoundingClientRect;
|
|
88
89
|
const groupByColumn = this.getColumn(tables, table_id, column_groupby_column_key);
|
|
89
90
|
const useSingleSelectColumnColor = (groupByColumn === null || groupByColumn === void 0 ? void 0 : groupByColumn.type) === _dtableUtils.CellType.SINGLE_SELECT && color_theme === _colorRules.SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
90
|
-
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme);
|
|
91
|
-
const
|
|
91
|
+
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme, 'group_name', columnGroupbyColumn, chart);
|
|
92
|
+
const sortedData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), 'group_name', columnGroupbyColumn, chart);
|
|
93
|
+
const series = d3.stack().keys(d3.union(sortedData.map(d => d.group_name))).value((_ref, key) => {
|
|
92
94
|
var _group$get;
|
|
93
95
|
let [_, group] = _ref;
|
|
94
96
|
return ((_group$get = group.get(String(key))) === null || _group$get === void 0 ? void 0 : _group$get.value) || 0;
|
|
95
|
-
})(d3.index(
|
|
96
|
-
const newSeries = this.handleSeries(series,
|
|
97
|
-
const y = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.
|
|
97
|
+
})(d3.index(sortedData, d => d.name, d => d.group_name));
|
|
98
|
+
const newSeries = this.handleSeries(series, sortedData);
|
|
99
|
+
const y = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
98
100
|
|
|
99
101
|
// Y axis
|
|
100
102
|
const yAxis = this.chart.append('g').call(d3.axisLeft(y).tickSizeOuter(0).tickPadding(0).tickSizeInner(5)).call(g => {
|
|
@@ -174,7 +176,9 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
174
176
|
legendName: 'group_name',
|
|
175
177
|
theme,
|
|
176
178
|
legendPosition: 'top-right',
|
|
177
|
-
data
|
|
179
|
+
data,
|
|
180
|
+
groupColumn: this.props.columnGroupbyColumn,
|
|
181
|
+
chart
|
|
178
182
|
});
|
|
179
183
|
};
|
|
180
184
|
this.handleAcitveAndInActiveState = (state, event) => {
|
|
@@ -88,7 +88,7 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
88
88
|
const colorRules = color_option === _constants.TYPE_COLOR_USING.USE_RULES && horizontal_axis_label_color_rules && (0, _colorUtils.getConvertedColorRules)(horizontal_axis_label_color_rules);
|
|
89
89
|
const tooltipTitle = this.getTitle(tables, table_id, horizontal_axis_summary_type, horizontal_axis_column_key);
|
|
90
90
|
data.reverse();
|
|
91
|
-
const y = d3.scaleBand().domain(data.map(item => item.name)).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.
|
|
91
|
+
const y = d3.scaleBand().domain(data.map(item => item.name)).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
92
92
|
const yAxis = this.chart.append('g').call(d3.axisLeft(y).tickSizeOuter(0).tickPadding(0).tickSizeInner(5)).call(g => {
|
|
93
93
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
94
94
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
@@ -152,7 +152,7 @@ class LineGroup extends _chartComponent.default {
|
|
|
152
152
|
marginTop
|
|
153
153
|
} = this.chartBoundingClientRect;
|
|
154
154
|
const useSingleSelectColumnColor = (columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === _dtableUtils.CellType.SINGLE_SELECT && color_theme === _colorRules.SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
155
|
-
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme);
|
|
155
|
+
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme, 'group_name', columnGroupbyColumn, chart);
|
|
156
156
|
|
|
157
157
|
// Y axis
|
|
158
158
|
const niceEnd = d3.nice(0, d3.max(data, d => d.value), 5)[1];
|
|
@@ -209,7 +209,7 @@ class LineGroup extends _chartComponent.default {
|
|
|
209
209
|
// circle label
|
|
210
210
|
if (y_axis_show_value) {
|
|
211
211
|
const curCircleEl = g.node();
|
|
212
|
-
rectsWrapper.append('text').attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(curCircleEl.getAttribute('data-text')).call(g => {
|
|
212
|
+
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 => {
|
|
213
213
|
const {
|
|
214
214
|
width
|
|
215
215
|
} = g.node().getBoundingClientRect();
|
|
@@ -256,7 +256,9 @@ class LineGroup extends _chartComponent.default {
|
|
|
256
256
|
legendName: 'group_name',
|
|
257
257
|
theme,
|
|
258
258
|
legendPosition: 'top-right',
|
|
259
|
-
data
|
|
259
|
+
data,
|
|
260
|
+
groupColumn: this.props.columnGroupbyColumn,
|
|
261
|
+
chart
|
|
260
262
|
});
|
|
261
263
|
};
|
|
262
264
|
this.updateCircleAndTickStyle = _ref2 => {
|
|
@@ -177,7 +177,7 @@ class Line extends _chartComponent.default {
|
|
|
177
177
|
// circle label
|
|
178
178
|
if (y_axis_show_value) {
|
|
179
179
|
const curCircleEl = g.node();
|
|
180
|
-
rectsWrapper.append('text').attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(curCircleEl.getAttribute('data-text')).call(g => {
|
|
180
|
+
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 => {
|
|
181
181
|
const {
|
|
182
182
|
width
|
|
183
183
|
} = g.node().getBoundingClientRect();
|
package/dist/view/wrapper/pie.js
CHANGED
|
@@ -102,7 +102,7 @@ class Pie extends _chartComponent.default {
|
|
|
102
102
|
if (display_label) {
|
|
103
103
|
const labelRadius = this.isInnerLabel ? arc.outerRadius()() * 0.7 : arc.outerRadius()() * 1.2;
|
|
104
104
|
const arcLabel = d3.arc().innerRadius(labelRadius).outerRadius(labelRadius);
|
|
105
|
-
this.chart.append('g').attr('transform', "translate(".concat(left + offsetX, ", ").concat(top + offsetY, ")")).attr('text-anchor', 'middle').selectAll().data(arcs).join('text').attr('transform', d => "translate(".concat(arcLabel.centroid(d), ")")).text(d => {
|
|
105
|
+
this.chart.append('g').attr('transform', "translate(".concat(left + offsetX, ", ").concat(top + offsetY, ")")).attr('text-anchor', 'middle').selectAll().data(arcs).join('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('transform', d => "translate(".concat(arcLabel.centroid(d), ")")).text(d => {
|
|
106
106
|
const {
|
|
107
107
|
value,
|
|
108
108
|
percent
|
|
@@ -108,7 +108,7 @@ class Ring extends _chartComponent.default {
|
|
|
108
108
|
if (display_label) {
|
|
109
109
|
const labelRadius = this.isInnerLabel ? arc.outerRadius()() * 1.2 : arc.outerRadius()() * 1.65;
|
|
110
110
|
const arcLabel = d3.arc().innerRadius(labelRadius).outerRadius(labelRadius);
|
|
111
|
-
this.chart.append('g').attr('transform', "translate(".concat(left + offsetX, ", ").concat(top + offsetY, ")")).attr('text-anchor', 'middle').selectAll().data(arcs).join('text').attr('class', 'label').attr('transform', d => "translate(".concat(arcLabel.centroid(d), ")")).text(d => {
|
|
111
|
+
this.chart.append('g').attr('transform', "translate(".concat(left + offsetX, ", ").concat(top + offsetY, ")")).attr('text-anchor', 'middle').selectAll().data(arcs).join('text').attr('class', 'label').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('transform', d => "translate(".concat(arcLabel.centroid(d), ")")).text(d => {
|
|
112
112
|
const {
|
|
113
113
|
value,
|
|
114
114
|
percent
|