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
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
transform: translate(-9999px, -9999px);
|
|
4
4
|
transition: transform 0.2s;
|
|
5
5
|
background-color: rgb(255, 255, 255);
|
|
6
|
-
box-shadow: rgba(
|
|
6
|
+
box-shadow: rgba(196, 175, 175, 0.1) 0px 0px 1px 1px;
|
|
7
7
|
border-radius: 3px;
|
|
8
8
|
color: rgb(89, 89, 89);
|
|
9
9
|
font-size: 12px;
|
|
10
10
|
padding: 8px 16px;
|
|
11
11
|
min-width: 178px;
|
|
12
12
|
border: 1px solid rgb(226, 226, 226);
|
|
13
|
+
pointer-events: none;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
.sea-chart-d3-tooltip-title {
|
|
@@ -69,7 +69,7 @@ const TypesDialog = _ref => {
|
|
|
69
69
|
}, [onChange, selectedType, onToggle]);
|
|
70
70
|
const handleFilterTypes = (0, _react.useCallback)(() => {
|
|
71
71
|
if (hideTypeToggle) {
|
|
72
|
-
const newChartTypes = _constants.CHART_TYPES.filter(item => ['Histogram', 'Bar_chart', 'Line_chart', 'Area', 'Pie_chart', 'Scatter_chart'].includes(item.name));
|
|
72
|
+
const newChartTypes = _constants.CHART_TYPES.filter(item => ['Histogram', 'Bar_chart', 'Line_chart', 'Area', 'Pie_chart', 'Scatter_chart', 'Combination_chart'].includes(item.name));
|
|
73
73
|
return newChartTypes;
|
|
74
74
|
}
|
|
75
75
|
return _constants.CHART_TYPES;
|
|
@@ -96,12 +96,12 @@ class AreaGroup extends _chartComponent.default {
|
|
|
96
96
|
// Y axis
|
|
97
97
|
const niceEnd = d3.nice(0, d3.max(data, d => d.value), 5)[1];
|
|
98
98
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min || 0, y_axis_max || niceEnd]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
99
|
-
this.chart.append('g').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));
|
|
99
|
+
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));
|
|
100
100
|
|
|
101
101
|
// X axis
|
|
102
102
|
const xDomain = data.map(item => item.name);
|
|
103
103
|
const x = d3.scaleBand().domain(xDomain).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
104
|
-
this.chart.append('g').attr('transform', "translate(0, ".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
104
|
+
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 => {
|
|
105
105
|
this.ticksAddName(g);
|
|
106
106
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
107
107
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
@@ -109,7 +109,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
109
109
|
g.selectAll('text').attr('fill', theme.textColor);
|
|
110
110
|
this.checkTickOverlap(g);
|
|
111
111
|
});
|
|
112
|
-
const
|
|
112
|
+
const contentWrapper = this.chart.append('g').attr('class', 'content-wrapper');
|
|
113
113
|
const circleDatas = [];
|
|
114
114
|
const groupData = d3.groups(data, d => d === null || d === void 0 ? void 0 : d.group_name);
|
|
115
115
|
|
|
@@ -129,7 +129,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
129
129
|
circleData[index]['value'] = d.value;
|
|
130
130
|
return yVal;
|
|
131
131
|
}).curve(line_type === _constants.CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
|
|
132
|
-
|
|
132
|
+
contentWrapper.append('path').attr('opacity', 1).attr('fill', 'none').attr('class', 'line').attr('stroke', this.colorMap[group_name]).attr('stroke-width', 2).attr('d', () => line(data));
|
|
133
133
|
circleDatas.push({
|
|
134
134
|
group_name,
|
|
135
135
|
circleData
|
|
@@ -143,7 +143,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
143
143
|
const xVal = x(d.name) + x.bandwidth() / 2;
|
|
144
144
|
return xVal;
|
|
145
145
|
}).y0(y(0)).y1(d => y(d.value)).curve(line_type === _constants.CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
|
|
146
|
-
|
|
146
|
+
contentWrapper.append('path').attr('class', 'area').attr('fill', this.colorMap[group_name]).attr('d', () => area(data)).attr('opacity', '0.3');
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
// circle
|
|
@@ -154,11 +154,11 @@ class AreaGroup extends _chartComponent.default {
|
|
|
154
154
|
} = _ref3;
|
|
155
155
|
circleData.forEach(item => {
|
|
156
156
|
if (Object.keys(item).length !== 0) {
|
|
157
|
-
|
|
157
|
+
contentWrapper.append('circle').attr('cx', item.x).attr('cy', item.y).attr('r', 3).attr('fill', this.colorMap[group_name]).attr('opacity', y_axis_show_value ? 1 : 0).attr('data-text', item.value).attr('data-name', item.name).call(g => {
|
|
158
158
|
// circle label
|
|
159
159
|
if (y_axis_show_value) {
|
|
160
160
|
const curCircleEl = g.node();
|
|
161
|
-
|
|
161
|
+
contentWrapper.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(_utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(curCircleEl.getAttribute('data-text')), y_axis_summary_method)).call(g => {
|
|
162
162
|
const {
|
|
163
163
|
width
|
|
164
164
|
} = g.node().getBoundingClientRect();
|
|
@@ -178,7 +178,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
178
178
|
event,
|
|
179
179
|
state: 'zoomIn',
|
|
180
180
|
circleDatas,
|
|
181
|
-
|
|
181
|
+
contentWrapper,
|
|
182
182
|
eventState: 'over',
|
|
183
183
|
tooltipTitle
|
|
184
184
|
});
|
|
@@ -187,7 +187,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
187
187
|
event,
|
|
188
188
|
state: 'zoomIn',
|
|
189
189
|
circleDatas,
|
|
190
|
-
|
|
190
|
+
contentWrapper,
|
|
191
191
|
eventState: 'move',
|
|
192
192
|
tooltipTitle
|
|
193
193
|
});
|
|
@@ -196,7 +196,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
196
196
|
event,
|
|
197
197
|
state: 'zoomOut',
|
|
198
198
|
circleDatas,
|
|
199
|
-
|
|
199
|
+
contentWrapper,
|
|
200
200
|
eventState: 'leave',
|
|
201
201
|
tooltipTitle
|
|
202
202
|
});
|
|
@@ -214,12 +214,12 @@ class AreaGroup extends _chartComponent.default {
|
|
|
214
214
|
});
|
|
215
215
|
};
|
|
216
216
|
this.updateCircleAndTickStyle = _ref4 => {
|
|
217
|
-
var
|
|
217
|
+
var _contentWrapper$selec;
|
|
218
218
|
let {
|
|
219
219
|
event,
|
|
220
220
|
state,
|
|
221
221
|
circleDatas,
|
|
222
|
-
|
|
222
|
+
contentWrapper,
|
|
223
223
|
eventState,
|
|
224
224
|
tooltipTitle
|
|
225
225
|
} = _ref4;
|
|
@@ -239,7 +239,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
239
239
|
});
|
|
240
240
|
const minDistanceItem = this.getMinDistanceItem(offsetX, circleData);
|
|
241
241
|
const tooltipItems = circleData.filter(item => item.name && item.name === minDistanceItem.name);
|
|
242
|
-
const circleList = (
|
|
242
|
+
const circleList = (_contentWrapper$selec = contentWrapper.selectAll('circle')) === null || _contentWrapper$selec === void 0 ? void 0 : _contentWrapper$selec.nodes();
|
|
243
243
|
if (state === 'zoomIn') {
|
|
244
244
|
// circle
|
|
245
245
|
circleList.forEach(circle => {
|
|
@@ -252,12 +252,12 @@ class AreaGroup extends _chartComponent.default {
|
|
|
252
252
|
d3.select(circle).attr('r', 3);
|
|
253
253
|
}
|
|
254
254
|
});
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
contentWrapper.selectAll('.area').transition().duration(this.areaTransitionDuration).attr('opacity', 0.1);
|
|
256
|
+
contentWrapper.selectAll('.line').transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
|
|
257
257
|
// line
|
|
258
258
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
259
|
-
this.clearOldVerticalAnnotation(
|
|
260
|
-
this.addVerticalAnnotation(
|
|
259
|
+
this.clearOldVerticalAnnotation(contentWrapper);
|
|
260
|
+
this.addVerticalAnnotation(contentWrapper, minDistanceItem, theme);
|
|
261
261
|
} else {
|
|
262
262
|
// circle
|
|
263
263
|
circleList.forEach(circle => {
|
|
@@ -268,10 +268,10 @@ class AreaGroup extends _chartComponent.default {
|
|
|
268
268
|
}
|
|
269
269
|
d3.select(circle).attr('r', 3);
|
|
270
270
|
});
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
contentWrapper.selectAll('.area').transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
|
|
272
|
+
contentWrapper.selectAll('.line').transition().duration(this.areaTransitionDuration).attr('opacity', 1);
|
|
273
273
|
// line
|
|
274
|
-
this.clearOldVerticalAnnotation(
|
|
274
|
+
this.clearOldVerticalAnnotation(contentWrapper);
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
// tooltip
|
|
@@ -89,12 +89,12 @@ class Area extends _chartComponent.default {
|
|
|
89
89
|
// Y axis
|
|
90
90
|
const niceEnd = d3.nice(0, d3.max(data, d => d.value), 5)[1];
|
|
91
91
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min || 0, y_axis_max || niceEnd]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
92
|
-
this.chart.append('g').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));
|
|
92
|
+
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));
|
|
93
93
|
|
|
94
94
|
// X axis
|
|
95
95
|
const xDomain = data.map(item => item.name);
|
|
96
96
|
const x = d3.scaleBand().domain(xDomain).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
97
|
-
this.chart.append('g').attr('transform', "translate(0, ".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
97
|
+
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 => {
|
|
98
98
|
this.ticksAddName(g);
|
|
99
99
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
100
100
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
@@ -102,7 +102,7 @@ class Area extends _chartComponent.default {
|
|
|
102
102
|
g.selectAll('text').attr('fill', theme.textColor);
|
|
103
103
|
this.checkTickOverlap(g);
|
|
104
104
|
});
|
|
105
|
-
const
|
|
105
|
+
const contentWrapper = this.chart.append('g').attr('class', 'content-wrapper');
|
|
106
106
|
|
|
107
107
|
// Line
|
|
108
108
|
const circleData = xDomain.map(() => ({}));
|
|
@@ -117,22 +117,22 @@ class Area extends _chartComponent.default {
|
|
|
117
117
|
circleData[index]['value'] = d.value;
|
|
118
118
|
return yVal;
|
|
119
119
|
}).curve(line_type === _constants.CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
|
|
120
|
-
this.Line =
|
|
120
|
+
this.Line = contentWrapper.append('path').attr('opacity', 1).attr('fill', 'none').attr('stroke', this.getAreaColor()).attr('stroke-width', 2).attr('d', () => line(data));
|
|
121
121
|
|
|
122
122
|
// Area
|
|
123
123
|
const area = d3.area().x(d => {
|
|
124
124
|
const xVal = x(d.name) + x.bandwidth() / 2;
|
|
125
125
|
return xVal;
|
|
126
126
|
}).y0(y(0)).y1(d => y(d.value)).curve(line_type === _constants.CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
|
|
127
|
-
this.Area =
|
|
127
|
+
this.Area = contentWrapper.append('path').attr('fill', this.getAreaColor()).attr('d', () => area(data)).attr('opacity', '0.3');
|
|
128
128
|
|
|
129
129
|
// circle
|
|
130
130
|
circleData.forEach(item => {
|
|
131
|
-
|
|
131
|
+
contentWrapper.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 => {
|
|
132
132
|
// circle label
|
|
133
133
|
if (y_axis_show_value) {
|
|
134
134
|
const curCircleEl = g.node();
|
|
135
|
-
|
|
135
|
+
contentWrapper.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(_utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(curCircleEl.getAttribute('data-text')), y_axis_summary_method)).call(g => {
|
|
136
136
|
const {
|
|
137
137
|
width
|
|
138
138
|
} = g.node().getBoundingClientRect();
|
|
@@ -150,7 +150,7 @@ class Area extends _chartComponent.default {
|
|
|
150
150
|
event,
|
|
151
151
|
state: 'zoomIn',
|
|
152
152
|
circleData,
|
|
153
|
-
|
|
153
|
+
contentWrapper,
|
|
154
154
|
eventState: 'over',
|
|
155
155
|
tooltipTitle
|
|
156
156
|
});
|
|
@@ -159,7 +159,7 @@ class Area extends _chartComponent.default {
|
|
|
159
159
|
event,
|
|
160
160
|
state: 'zoomIn',
|
|
161
161
|
circleData,
|
|
162
|
-
|
|
162
|
+
contentWrapper,
|
|
163
163
|
eventState: 'move',
|
|
164
164
|
tooltipTitle
|
|
165
165
|
});
|
|
@@ -168,7 +168,7 @@ class Area extends _chartComponent.default {
|
|
|
168
168
|
event,
|
|
169
169
|
state: 'zoomOut',
|
|
170
170
|
circleData,
|
|
171
|
-
|
|
171
|
+
contentWrapper,
|
|
172
172
|
eventState: 'leave',
|
|
173
173
|
tooltipTitle
|
|
174
174
|
});
|
|
@@ -178,12 +178,12 @@ class Area extends _chartComponent.default {
|
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
180
|
this.updateCircleAndTickStyle = _ref => {
|
|
181
|
-
var
|
|
181
|
+
var _contentWrapper$selec;
|
|
182
182
|
let {
|
|
183
183
|
event,
|
|
184
184
|
state,
|
|
185
185
|
circleData,
|
|
186
|
-
|
|
186
|
+
contentWrapper,
|
|
187
187
|
eventState,
|
|
188
188
|
tooltipTitle
|
|
189
189
|
} = _ref;
|
|
@@ -198,7 +198,7 @@ class Area extends _chartComponent.default {
|
|
|
198
198
|
offsetX
|
|
199
199
|
} = event;
|
|
200
200
|
const minDistanceItem = this.getMinDistanceItem(offsetX, circleData);
|
|
201
|
-
const circleList = (
|
|
201
|
+
const circleList = (_contentWrapper$selec = contentWrapper.selectAll('circle')) === null || _contentWrapper$selec === void 0 ? void 0 : _contentWrapper$selec.nodes();
|
|
202
202
|
if (state === 'zoomIn') {
|
|
203
203
|
// circle
|
|
204
204
|
circleList.forEach(circle => {
|
|
@@ -211,12 +211,12 @@ class Area extends _chartComponent.default {
|
|
|
211
211
|
d3.select(circle).attr('r', 3);
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
|
-
this.Area.transition().duration(
|
|
215
|
-
this.Line.transition().duration(
|
|
214
|
+
this.Area.transition().duration(this.areaTransitionDuration).attr('opacity', 0.1);
|
|
215
|
+
this.Line.transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
|
|
216
216
|
// line
|
|
217
217
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
218
|
-
this.clearOldVerticalAnnotation(
|
|
219
|
-
this.addVerticalAnnotation(
|
|
218
|
+
this.clearOldVerticalAnnotation(contentWrapper);
|
|
219
|
+
this.addVerticalAnnotation(contentWrapper, minDistanceItem, theme);
|
|
220
220
|
} else {
|
|
221
221
|
// circle
|
|
222
222
|
circleList.forEach(circle => {
|
|
@@ -227,10 +227,10 @@ class Area extends _chartComponent.default {
|
|
|
227
227
|
}
|
|
228
228
|
d3.select(circle).attr('r', 3);
|
|
229
229
|
});
|
|
230
|
-
this.Area.transition().duration(
|
|
231
|
-
this.Line.transition().duration(
|
|
230
|
+
this.Area.transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
|
|
231
|
+
this.Line.transition().duration(this.areaTransitionDuration).attr('opacity', 1);
|
|
232
232
|
// line
|
|
233
|
-
this.clearOldVerticalAnnotation(
|
|
233
|
+
this.clearOldVerticalAnnotation(contentWrapper);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
// tooltip
|
|
@@ -48,14 +48,16 @@ class BarCompare extends _chartComponent.default {
|
|
|
48
48
|
const {
|
|
49
49
|
chart,
|
|
50
50
|
globalTheme,
|
|
51
|
-
chartColorTheme
|
|
51
|
+
chartColorTheme,
|
|
52
|
+
columnGroupbyColumn
|
|
52
53
|
} = this.props;
|
|
53
54
|
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
54
55
|
const {
|
|
55
56
|
display_increase,
|
|
56
57
|
y_axis_auto_range = true,
|
|
57
58
|
y_axis_min,
|
|
58
|
-
y_axis_max
|
|
59
|
+
y_axis_max,
|
|
60
|
+
y_axis_summary_method
|
|
59
61
|
} = chart.config;
|
|
60
62
|
const {
|
|
61
63
|
width: chartWidth,
|
|
@@ -66,13 +68,13 @@ class BarCompare extends _chartComponent.default {
|
|
|
66
68
|
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]);
|
|
67
69
|
|
|
68
70
|
// Y axis
|
|
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));
|
|
71
|
+
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 => _chartUtils.BaseUtils.getSummaryValueDisplayString(columnGroupbyColumn, d, y_axis_summary_method))).call(g => this.drawYaxis(g, theme));
|
|
70
72
|
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
73
|
const color = d3.scaleOrdinal().domain(d3.group(data, d => d.group_name).keys()).range(_chartUtils.BaseUtils.getCurrentTheme(chartColorTheme).colors).unknown('#ccc');
|
|
72
74
|
const x = d3.scaleBand().domain(d3.group(data, d => d.group_name).keys()).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
73
75
|
|
|
74
76
|
// X axis
|
|
75
|
-
this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
77
|
+
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
76
78
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
77
79
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
78
80
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
@@ -81,7 +83,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
81
83
|
});
|
|
82
84
|
|
|
83
85
|
// Rect group
|
|
84
|
-
this.chart.append('g').attr('class',
|
|
86
|
+
this.chart.append('g').attr('class', 'content-wrapper').selectAll().data(() => d3.group(data, d => d.name)).join('g').attr('transform', _ref => {
|
|
85
87
|
let [name, dum] = _ref;
|
|
86
88
|
// Each group is horizontally centered
|
|
87
89
|
const offset = (fx.bandwidth() - dum.length * x.bandwidth()) / 2;
|
|
@@ -91,7 +93,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
91
93
|
.selectAll().data(_ref2 => {
|
|
92
94
|
let [a, d] = _ref2;
|
|
93
95
|
return d;
|
|
94
|
-
}).join('rect').attr('x', (d, index) => index * x.bandwidth()).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value) === 0 ? 0 : y(0) - y(d.value)).attr('fill', d => color(d.group_name)).attr('data-value', d => d.value).attr('data-groupName', d => d.name).attr('data-slugid', d => d.slugId).call(g => {
|
|
96
|
+
}).join('rect').attr('opacity', 1).attr('x', (d, index) => index * x.bandwidth()).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value) === 0 ? 0 : y(0) - y(d.value)).attr('fill', d => color(d.group_name)).attr('data-value', d => d.value).attr('data-groupName', d => d.name).attr('data-slugid', d => d.slugId).call(g => {
|
|
95
97
|
g.nodes().forEach(rect => {
|
|
96
98
|
const parentNode = rect.parentNode;
|
|
97
99
|
// add rect borderRadius
|
|
@@ -219,7 +221,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
219
221
|
circleData[index]['value'] = d.formatValue;
|
|
220
222
|
return y;
|
|
221
223
|
}).curve(d3.curveBumpX);
|
|
222
|
-
const wrapper = this.chart.append('g').attr('class',
|
|
224
|
+
const wrapper = this.chart.append('g').attr('class', 'increase-line-wrapper');
|
|
223
225
|
|
|
224
226
|
// line
|
|
225
227
|
wrapper.append('path').attr('fill', 'none').attr('stroke', increase_line_color || '#fbd44a').attr('stroke-width', 2).attr('d', () => line(increaseData));
|
|
@@ -154,12 +154,12 @@ class BarCustom extends _chartComponent.default {
|
|
|
154
154
|
const y = d3.scaleLinear().domain([0, niceEnd]).range([chartHeight - insertPadding, insertPadding]);
|
|
155
155
|
|
|
156
156
|
// Y axis
|
|
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));
|
|
157
|
+
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 => d)).call(g => this.drawYaxis(g, theme));
|
|
158
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
159
|
const x = d3.scaleBand().domain(new Set(data.map(d => d.y_axis_type))).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
160
160
|
|
|
161
161
|
// X axis
|
|
162
|
-
this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
162
|
+
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
163
163
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
164
164
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
165
165
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
@@ -168,7 +168,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
168
168
|
});
|
|
169
169
|
|
|
170
170
|
// Rect group
|
|
171
|
-
this.chart.append('g').attr('class',
|
|
171
|
+
this.chart.append('g').attr('class', 'content-wrapper').selectAll().data(organizedData).join('g').attr('transform', d => {
|
|
172
172
|
const {
|
|
173
173
|
name
|
|
174
174
|
} = d;
|
|
@@ -178,7 +178,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
178
178
|
name
|
|
179
179
|
} = d;
|
|
180
180
|
return fx(name);
|
|
181
|
-
}).selectAll().data(d => d.stacks).join('g').attr('class', 'stackGroup').attr('data-slugid', d => d.slugid).selectAll().data(d => d.series).join('rect').attr('class', 'stack').attr('x', d => x(d.stackKey)).attr('y', d => y(d[0][1])).attr('width', x.bandwidth()).attr('height', d => {
|
|
181
|
+
}).selectAll().data(d => d.stacks).join('g').attr('class', 'stackGroup').attr('data-slugid', d => d.slugid).selectAll().data(d => d.series).join('rect').attr('class', 'stack').attr('opacity', 1).attr('x', d => x(d.stackKey)).attr('y', d => y(d[0][1])).attr('width', x.bandwidth()).attr('height', d => {
|
|
182
182
|
const height = y(d[0][0]) - y(d[0][1]);
|
|
183
183
|
return isNaN(height) ? 0 : height;
|
|
184
184
|
}).attr('fill', d => color(d.key)).attr('data-value', d => d.stackData.value).attr('data-rectId', d => d.stackData.slugId).attr('data-groupName', d => d.stackData.group_name).attr('data-title', d => d.stackData.name).call(g => {
|
|
@@ -246,7 +246,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
246
246
|
borderRadius
|
|
247
247
|
} = this.chartBoundingClientRect;
|
|
248
248
|
// Add mask rect
|
|
249
|
-
d3.select(topG).append('foreignObject').attr('class', 'stack-wrapper').attr('x', rect.getAttribute('x')).attr('data-x', topG.parentNode.getAttribute('data-transform')).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')).attr('data-title', rect.getAttribute('data-title')).attr('data-rectId', rect.getAttribute('data-rectId')).on('click', (event, data) => {
|
|
249
|
+
d3.select(topG).append('foreignObject').attr('class', 'stack-wrapper').attr('opacity', rect.getAttribute('opacity')).attr('x', rect.getAttribute('x')).attr('data-x', topG.parentNode.getAttribute('data-transform')).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')).attr('data-title', rect.getAttribute('data-title')).attr('data-rectId', rect.getAttribute('data-rectId')).on('click', (event, data) => {
|
|
250
250
|
this.props.toggleRecords(data);
|
|
251
251
|
}).on('mouseover', event => {
|
|
252
252
|
this.showTooltip(event, colorScale, true);
|
|
@@ -271,7 +271,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
271
271
|
const isDiv = rect.getAttribute('class') === 'stack-wrapper';
|
|
272
272
|
const curRect = isDiv ? rect.children[0] : rect;
|
|
273
273
|
if (curRect.getAttribute('class') === 'stack') {
|
|
274
|
-
isDiv ? curRect.
|
|
274
|
+
isDiv ? d3.select(curRect.parentNode).transition().duration(this.transitionDuration).attr('opacity', 1) : d3.select(curRect).transition().duration(this.transitionDuration).attr('opacity', 1);
|
|
275
275
|
}
|
|
276
276
|
});
|
|
277
277
|
});
|
|
@@ -285,7 +285,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
285
285
|
const isDiv = rect.getAttribute('class') === 'stack-wrapper';
|
|
286
286
|
const curRect = isDiv ? rect.children[0] : rect;
|
|
287
287
|
if (curRect.getAttribute('class') === 'stack' && curRect.getAttribute('data-rectId') !== curRectId) {
|
|
288
|
-
isDiv ? curRect.
|
|
288
|
+
isDiv ? d3.select(curRect.parentNode).transition().duration(this.transitionDuration).attr('opacity', 0.3) : d3.select(curRect).transition().duration(this.transitionDuration).attr('opacity', 0.3);
|
|
289
289
|
}
|
|
290
290
|
});
|
|
291
291
|
});
|
|
@@ -63,7 +63,8 @@ class BarGroup extends _chartComponent.default {
|
|
|
63
63
|
globalTheme,
|
|
64
64
|
chartColorTheme,
|
|
65
65
|
tables,
|
|
66
|
-
columnGroupbyColumn
|
|
66
|
+
columnGroupbyColumn,
|
|
67
|
+
summaryColumn
|
|
67
68
|
} = this.props;
|
|
68
69
|
const {
|
|
69
70
|
display_goal_line,
|
|
@@ -78,6 +79,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
78
79
|
} = this.chartBoundingClientRect;
|
|
79
80
|
const {
|
|
80
81
|
y_axis_show_value,
|
|
82
|
+
y_axis_summary_method,
|
|
81
83
|
label_font_size,
|
|
82
84
|
table_id,
|
|
83
85
|
column_groupby_column_key,
|
|
@@ -94,13 +96,13 @@ class BarGroup extends _chartComponent.default {
|
|
|
94
96
|
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]);
|
|
95
97
|
|
|
96
98
|
// Y axis
|
|
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));
|
|
99
|
+
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));
|
|
98
100
|
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
101
|
const sortedData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), 'group_name', columnGroupbyColumn, chart);
|
|
100
102
|
const x = d3.scaleBand().domain(new Set(sortedData.map(d => d.group_name))).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
101
103
|
|
|
102
104
|
// X axis
|
|
103
|
-
this.chart.append('g').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
105
|
+
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', "translate(0,".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
104
106
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
105
107
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
106
108
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
@@ -109,7 +111,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
109
111
|
});
|
|
110
112
|
|
|
111
113
|
// Rect group
|
|
112
|
-
this.chart.append('g').selectAll().data(d3.group(sortedData, d => d.name)).join('g').attr('transform', _ref => {
|
|
114
|
+
this.chart.append('g').attr('class', 'content-wrapper').selectAll().data(d3.group(sortedData, d => d.name)).join('g').attr('transform', _ref => {
|
|
113
115
|
let [name, dum] = _ref;
|
|
114
116
|
// Each group is horizontally centered
|
|
115
117
|
const offset = (fx.bandwidth() - dum.length * x.bandwidth()) / 2;
|
|
@@ -119,7 +121,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
119
121
|
.selectAll().data(_ref2 => {
|
|
120
122
|
let [_, d] = _ref2;
|
|
121
123
|
return d;
|
|
122
|
-
}).join('rect').attr('x', (d, index) => index * x.bandwidth()).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value)).attr('fill', d => this.colorMap[d.group_name] || _constants.CHART_STYLE_COLORS[0]).attr('data-value', d => d.value).attr('data-groupName', d => d.name).attr('data-slugid', d => d.slugId).call(g => {
|
|
124
|
+
}).join('rect').attr('opacity', 1).attr('x', (d, index) => index * x.bandwidth()).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value)).attr('fill', d => this.colorMap[d.group_name] || _constants.CHART_STYLE_COLORS[0]).attr('data-value', d => d.value).attr('data-groupName', d => d.name).attr('data-slugid', d => d.slugId).call(g => {
|
|
123
125
|
g.nodes().forEach(rect => {
|
|
124
126
|
const parentNode = rect.parentNode;
|
|
125
127
|
// add rect borderRadius
|
|
@@ -138,7 +140,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
138
140
|
y: Number(rect.getAttribute('y')),
|
|
139
141
|
theme,
|
|
140
142
|
label_font_size,
|
|
141
|
-
text: rect.dataset.value
|
|
143
|
+
text: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(rect.dataset.value), y_axis_summary_method)
|
|
142
144
|
});
|
|
143
145
|
}
|
|
144
146
|
});
|
|
@@ -166,6 +168,13 @@ class BarGroup extends _chartComponent.default {
|
|
|
166
168
|
});
|
|
167
169
|
};
|
|
168
170
|
this.showTooltip = event => {
|
|
171
|
+
const {
|
|
172
|
+
summaryColumn,
|
|
173
|
+
chart
|
|
174
|
+
} = this.props;
|
|
175
|
+
const {
|
|
176
|
+
y_axis_summary_method
|
|
177
|
+
} = chart.config;
|
|
169
178
|
const {
|
|
170
179
|
offsetX,
|
|
171
180
|
offsetY
|
|
@@ -178,7 +187,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
178
187
|
return {
|
|
179
188
|
color: this.colorMap[item.group_name],
|
|
180
189
|
name: item.group_name,
|
|
181
|
-
value: item.value
|
|
190
|
+
value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(item.value), y_axis_summary_method)
|
|
182
191
|
};
|
|
183
192
|
})
|
|
184
193
|
};
|