dtable-statistic 4.1.5 → 4.1.6
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/es/assets/css/dashboard.css +4 -0
- package/es/custom-g2.js +2 -0
- package/es/stat-view/map.js +19 -19
- package/es/stat-view/world-map.js +27 -22
- package/es/utils/common-utils.js +3 -2
- package/package.json +1 -1
package/es/custom-g2.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// register theme
|
|
2
2
|
import * as CanvasEngine from '@antv/g-canvas/esm/index';
|
|
3
|
+
// import * as SvgEngine from '@antv/g-svg/esm/index';
|
|
3
4
|
import Area from '@antv/g2/esm/geometry/area';
|
|
4
5
|
import Edge from '@antv/g2/esm/geometry/edge';
|
|
5
6
|
import HeatMap from '@antv/g2/esm/geometry/heatmap';
|
|
@@ -96,6 +97,7 @@ export { getRectWithCornerRadius } from '@antv/g2/esm/geometry/shape/interval/ut
|
|
|
96
97
|
|
|
97
98
|
// register G renderer
|
|
98
99
|
registerEngine('canvas', CanvasEngine);
|
|
100
|
+
// registerEngine('svg', SvgEngine);
|
|
99
101
|
|
|
100
102
|
// register internal G2 geometry
|
|
101
103
|
registerGeometry('Polygon', Polygon);
|
package/es/stat-view/map.js
CHANGED
|
@@ -34,10 +34,6 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
34
34
|
isCalculatingData: false
|
|
35
35
|
});
|
|
36
36
|
_this.updateStatisticData(_this.fixData(statData));
|
|
37
|
-
if (_this.props.isPreview) {
|
|
38
|
-
var canvasSize = _this.getCanvasSize();
|
|
39
|
-
_this.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
40
|
-
}
|
|
41
37
|
});
|
|
42
38
|
};
|
|
43
39
|
_this.rerenderChart = function () {
|
|
@@ -246,22 +242,24 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
246
242
|
_this.statisticView.interaction('element-active');
|
|
247
243
|
_this.statisticView.render();
|
|
248
244
|
};
|
|
249
|
-
_this.
|
|
245
|
+
_this.getSize = function () {
|
|
250
246
|
var statItem = _this.props.statItem;
|
|
251
247
|
var map_level = statItem.map_level,
|
|
252
248
|
map_location = statItem.map_location;
|
|
253
|
-
var
|
|
254
|
-
var
|
|
249
|
+
var containerWidth = _this.container.clientWidth - 40; // 40: padding
|
|
250
|
+
var containerHeight = _this.container.clientHeight - 40;
|
|
255
251
|
var _getRegionScaleOffset = getRegionScaleOffsets(map_level, map_location),
|
|
256
252
|
scale_w = _getRegionScaleOffset.scale_w,
|
|
257
253
|
scale_h = _getRegionScaleOffset.scale_h;
|
|
258
|
-
var h =
|
|
254
|
+
var h = containerHeight;
|
|
259
255
|
var w = h * (scale_w / scale_h);
|
|
260
|
-
if (w >
|
|
261
|
-
w =
|
|
256
|
+
if (w > containerWidth) {
|
|
257
|
+
w = containerWidth;
|
|
262
258
|
h = w * (scale_h / scale_w);
|
|
263
259
|
}
|
|
264
260
|
return {
|
|
261
|
+
containerWidth: containerWidth,
|
|
262
|
+
containerHeight: containerHeight,
|
|
265
263
|
w: w,
|
|
266
264
|
h: h
|
|
267
265
|
};
|
|
@@ -269,13 +267,19 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
269
267
|
_this.initStatisticContext = function (geolocation) {
|
|
270
268
|
_this.mapData = geolocation;
|
|
271
269
|
if (!_this.container) return;
|
|
270
|
+
|
|
272
271
|
// create chart
|
|
273
|
-
var
|
|
272
|
+
var _this$getSize = _this.getSize(),
|
|
273
|
+
containerWidth = _this$getSize.containerWidth,
|
|
274
|
+
containerHeight = _this$getSize.containerHeight,
|
|
275
|
+
mapWidth = _this$getSize.w;
|
|
276
|
+
var horizontalPadding = (containerWidth - mapWidth) / 4;
|
|
277
|
+
var leftPadding = horizontalPadding < 20 ? 20 : horizontalPadding;
|
|
274
278
|
_this.chart = new Chart({
|
|
275
279
|
container: _this.container,
|
|
276
|
-
width:
|
|
277
|
-
height:
|
|
278
|
-
padding: [
|
|
280
|
+
width: containerWidth,
|
|
281
|
+
height: containerHeight,
|
|
282
|
+
padding: [0, horizontalPadding, 0, leftPadding]
|
|
279
283
|
});
|
|
280
284
|
_this.chart.on('element:click', function (e) {
|
|
281
285
|
var statItem = _this.props.statItem;
|
|
@@ -401,10 +405,6 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
401
405
|
}
|
|
402
406
|
} else {
|
|
403
407
|
this.updateStatisticData(this.fixData(this.calculateData));
|
|
404
|
-
if (this.props.isPreview) {
|
|
405
|
-
var canvasSize = this.getCanvasSize();
|
|
406
|
-
this.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
407
|
-
}
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
}, {
|
|
@@ -424,7 +424,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
424
424
|
ref: function ref(_ref) {
|
|
425
425
|
return _this4.container = _ref;
|
|
426
426
|
},
|
|
427
|
-
className: "statistic-chart-container d-flex justify-content-around align-items-center w-100 h-100"
|
|
427
|
+
className: "statistic-chart-container map d-flex justify-content-around align-items-center w-100 h-100"
|
|
428
428
|
}));
|
|
429
429
|
}
|
|
430
430
|
}]);
|
|
@@ -20,6 +20,11 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
20
20
|
var _this;
|
|
21
21
|
_classCallCheck(this, WorldMap);
|
|
22
22
|
_this = _super.call(this, props);
|
|
23
|
+
_this.rerenderChart = function () {
|
|
24
|
+
if (!_this.chart) return;
|
|
25
|
+
_this.chart.destroy();
|
|
26
|
+
_this.initStatisticContext(_this.geoData);
|
|
27
|
+
};
|
|
23
28
|
_this.fixData = function (statisticData) {
|
|
24
29
|
if (!statisticData) return [];
|
|
25
30
|
var statisticNewData = [];
|
|
@@ -225,16 +230,18 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
225
230
|
}
|
|
226
231
|
_this.chart.render();
|
|
227
232
|
};
|
|
228
|
-
_this.
|
|
229
|
-
var
|
|
230
|
-
var
|
|
231
|
-
var h =
|
|
233
|
+
_this.getSize = function () {
|
|
234
|
+
var containerWidth = _this.container.clientWidth - 40; // 40: padding
|
|
235
|
+
var containerHeight = _this.container.clientHeight - 40;
|
|
236
|
+
var h = containerHeight;
|
|
232
237
|
var w = h * (WIDTH / HEIGHT);
|
|
233
|
-
if (w >
|
|
234
|
-
w =
|
|
238
|
+
if (w > containerWidth) {
|
|
239
|
+
w = containerWidth;
|
|
235
240
|
h = w * (HEIGHT / WIDTH);
|
|
236
241
|
}
|
|
237
242
|
return {
|
|
243
|
+
containerWidth: containerWidth,
|
|
244
|
+
containerHeight: containerHeight,
|
|
238
245
|
w: w,
|
|
239
246
|
h: h
|
|
240
247
|
};
|
|
@@ -246,13 +253,19 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
246
253
|
_this.countryMap.set(item.properties.name_cn, item.properties.name);
|
|
247
254
|
});
|
|
248
255
|
if (!_this.container) return;
|
|
256
|
+
|
|
249
257
|
// create chart
|
|
250
|
-
var
|
|
258
|
+
var _this$getSize = _this.getSize(),
|
|
259
|
+
containerWidth = _this$getSize.containerWidth,
|
|
260
|
+
containerHeight = _this$getSize.containerHeight,
|
|
261
|
+
mapWidth = _this$getSize.w;
|
|
262
|
+
var horizontalPadding = (containerWidth - mapWidth) / 4;
|
|
263
|
+
var leftPadding = horizontalPadding < 20 ? 20 : horizontalPadding;
|
|
251
264
|
_this.chart = new Chart({
|
|
252
265
|
container: _this.container,
|
|
253
|
-
width:
|
|
254
|
-
height:
|
|
255
|
-
padding: [
|
|
266
|
+
width: containerWidth,
|
|
267
|
+
height: containerHeight,
|
|
268
|
+
padding: [0, horizontalPadding, 0, leftPadding]
|
|
256
269
|
});
|
|
257
270
|
_this.chart.on('element:click', function (e) {
|
|
258
271
|
var statItem = _this.props.statItem;
|
|
@@ -371,28 +384,20 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
371
384
|
isCalculatingData: true
|
|
372
385
|
});
|
|
373
386
|
if (this.container) {
|
|
374
|
-
|
|
375
|
-
this.chart.destroy();
|
|
376
|
-
this.initStatisticContext(this.geoData);
|
|
377
|
-
}
|
|
387
|
+
this.rerenderChart();
|
|
378
388
|
chartCalculator.calculate(statItem).then(function (calculation) {
|
|
379
389
|
_this3.setState({
|
|
380
390
|
isCalculatingData: false
|
|
381
391
|
});
|
|
382
392
|
_this3.calculateData = calculation;
|
|
383
393
|
_this3.updateStatisticData(_this3.fixData(calculation));
|
|
384
|
-
if (_this3.props.isPreview) {
|
|
385
|
-
var canvasSize = _this3.getCanvasSize();
|
|
386
|
-
_this3.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
387
|
-
}
|
|
388
394
|
});
|
|
389
395
|
}
|
|
390
396
|
} else {
|
|
391
|
-
this.updateStatisticData(this.fixData(this.calculateData));
|
|
392
397
|
if (this.props.isPreview) {
|
|
393
|
-
|
|
394
|
-
this.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
398
|
+
this.rerenderChart();
|
|
395
399
|
}
|
|
400
|
+
this.updateStatisticData(this.fixData(this.calculateData));
|
|
396
401
|
}
|
|
397
402
|
}
|
|
398
403
|
}, {
|
|
@@ -412,7 +417,7 @@ var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
412
417
|
ref: function ref(_ref) {
|
|
413
418
|
return _this4.container = _ref;
|
|
414
419
|
},
|
|
415
|
-
className: "statistic-chart-container d-flex justify-content-around align-items-center w-100 h-100"
|
|
420
|
+
className: "statistic-chart-container map d-flex justify-content-around align-items-center w-100 h-100"
|
|
416
421
|
}));
|
|
417
422
|
}
|
|
418
423
|
}]);
|
package/es/utils/common-utils.js
CHANGED
|
@@ -220,8 +220,9 @@ var getPieColor = function getPieColor(color_option, column, index, data, curren
|
|
|
220
220
|
return selectedItem.color || '#dbdbdb';
|
|
221
221
|
}
|
|
222
222
|
} else {
|
|
223
|
-
var
|
|
224
|
-
|
|
223
|
+
var sIndex = String(index);
|
|
224
|
+
var colorIndex = sIndex.charAt(sIndex.length - 1);
|
|
225
|
+
return colors[colorIndex];
|
|
225
226
|
}
|
|
226
227
|
};
|
|
227
228
|
export function formatPieChartData(data, statItem, table, currentTheme) {
|