sea-chart 0.0.3 → 0.0.4-beta
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/api/index.js +18 -1
- package/dist/context.js +8 -1
- package/dist/editor/index.js +0 -1
- package/dist/index.js +3 -2
- package/dist/settings/table-settings/data-settings.js +1 -1
- package/dist/utils/chart-utils.js +23 -23
- package/dist/view/index.js +2 -4
- package/package.json +1 -1
package/dist/api/index.js
CHANGED
|
@@ -80,7 +80,24 @@ class SeaChartAPI {
|
|
|
80
80
|
this.instance = new SeaChartAPI(config);
|
|
81
81
|
return this.instance;
|
|
82
82
|
}
|
|
83
|
-
async init() {
|
|
83
|
+
async init(config) {
|
|
84
|
+
if (config && typeof config === 'object') {
|
|
85
|
+
const {
|
|
86
|
+
appName,
|
|
87
|
+
accessToken,
|
|
88
|
+
dtableUuid,
|
|
89
|
+
dtableServer,
|
|
90
|
+
dtableSocket,
|
|
91
|
+
dtableDb
|
|
92
|
+
} = config;
|
|
93
|
+
this.appName = appName;
|
|
94
|
+
this.accessToken = accessToken;
|
|
95
|
+
this.dtableUuid = dtableUuid;
|
|
96
|
+
this.dtableServer = dtableServer.replace(/\/+$/, '') + '/';
|
|
97
|
+
this.dtableSocket = dtableSocket.replace(/\/+$/, '') + '/';
|
|
98
|
+
this.dtableDB = dtableDb.replace(/\/+$/, '') + '/';
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
84
101
|
const accessTokenRes = await this.getDTableAccessToken();
|
|
85
102
|
const {
|
|
86
103
|
app_name,
|
package/dist/context.js
CHANGED
|
@@ -3,13 +3,20 @@ import CollaboratorManager from './utils/collaborator-manager';
|
|
|
3
3
|
import { ChartDataSQL } from './utils';
|
|
4
4
|
class Context {
|
|
5
5
|
constructor() {
|
|
6
|
-
this.
|
|
6
|
+
this.queryResult = _ref => {
|
|
7
7
|
let {
|
|
8
8
|
chart,
|
|
9
9
|
tables,
|
|
10
10
|
onSuccess,
|
|
11
11
|
onFail
|
|
12
12
|
} = _ref;
|
|
13
|
+
if (this.api.queryResult) {
|
|
14
|
+
return this.api.queryResult({
|
|
15
|
+
chart,
|
|
16
|
+
onSuccess,
|
|
17
|
+
onFail
|
|
18
|
+
});
|
|
19
|
+
}
|
|
13
20
|
const table = getTableById(tables, chart.config.table_id);
|
|
14
21
|
const chartDataSQL = new ChartDataSQL({
|
|
15
22
|
table,
|
package/dist/editor/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import SeaChartAPI from './api';
|
|
2
|
-
import { CHART_TYPES } from './constants/type';
|
|
2
|
+
import { CHART_TYPE, CHART_TYPES } from './constants/type';
|
|
3
|
+
import { ChartModel } from './model';
|
|
3
4
|
import View from './view';
|
|
4
5
|
import Editor from './editor';
|
|
5
6
|
import Settings, { StyleSettings } from './settings';
|
|
6
7
|
import { ChartDataSQL } from './utils';
|
|
7
8
|
import Context from './context';
|
|
8
9
|
export default View;
|
|
9
|
-
export { SeaChartAPI, CHART_TYPES, View, Editor, Settings, StyleSettings, Context, ChartDataSQL };
|
|
10
|
+
export { SeaChartAPI, CHART_TYPE, CHART_TYPES, View, Editor, Settings, StyleSettings, Context, ChartModel, ChartDataSQL };
|
|
@@ -1376,7 +1376,7 @@ ChartUtils.convertConfig = config => {
|
|
|
1376
1376
|
ChartUtils.imEmptyChartResult = chartResult => {
|
|
1377
1377
|
return !chartResult || !chartResult.result && chartResult.result !== 0 || Array.isArray(chartResult.result) && chartResult.result.length === 0;
|
|
1378
1378
|
};
|
|
1379
|
-
ChartUtils.calculateChart = (chart, tables, callback
|
|
1379
|
+
ChartUtils.calculateChart = (chart, tables, callback) => {
|
|
1380
1380
|
if (!_class.isValidExistChart(tables, chart)) {
|
|
1381
1381
|
const tip_message = 'Please_complete_the_chart_configuration_first';
|
|
1382
1382
|
return callback && callback('', tip_message, null);
|
|
@@ -1412,7 +1412,7 @@ ChartUtils.calculateChart = (chart, tables, callback, isChartData) => {
|
|
|
1412
1412
|
const error_message = 'There_are_some_problems_with_the_filters';
|
|
1413
1413
|
return callback && callback(error_message, '', null);
|
|
1414
1414
|
}
|
|
1415
|
-
context.
|
|
1415
|
+
context.queryResult({
|
|
1416
1416
|
chart,
|
|
1417
1417
|
tables,
|
|
1418
1418
|
onSuccess: res => {
|
|
@@ -1422,26 +1422,24 @@ ChartUtils.calculateChart = (chart, tables, callback, isChartData) => {
|
|
|
1422
1422
|
error_message
|
|
1423
1423
|
} = res.data;
|
|
1424
1424
|
if (success) {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
callback && callback('', tipMessage, null);
|
|
1429
|
-
return;
|
|
1430
|
-
}
|
|
1431
|
-
const chartResult = _class.sqlResult2JavaScript(newChart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1432
|
-
if (_class.imEmptyChartResult(chartResult)) {
|
|
1433
|
-
callback && callback('', tipMessage, null);
|
|
1434
|
-
return;
|
|
1435
|
-
}
|
|
1436
|
-
callback && callback('', '', {
|
|
1437
|
-
...chartResult,
|
|
1438
|
-
groupbyColumn,
|
|
1439
|
-
columnGroupbyColumn,
|
|
1440
|
-
summaryColumn,
|
|
1441
|
-
chartTableColumns
|
|
1442
|
-
});
|
|
1425
|
+
const tipMessage = 'There_are_no_statistic_results_yet';
|
|
1426
|
+
if (!Array.isArray(sqlRows) || sqlRows.length === 0) {
|
|
1427
|
+
callback && callback('', tipMessage, null);
|
|
1443
1428
|
return;
|
|
1444
1429
|
}
|
|
1430
|
+
const chartResult = _class.sqlResult2JavaScript(newChart, sqlRows, chartSQLMap, columnMap, tables);
|
|
1431
|
+
if (_class.imEmptyChartResult(chartResult)) {
|
|
1432
|
+
callback && callback('', tipMessage, null);
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
callback && callback('', '', {
|
|
1436
|
+
...chartResult,
|
|
1437
|
+
groupbyColumn,
|
|
1438
|
+
columnGroupbyColumn,
|
|
1439
|
+
summaryColumn,
|
|
1440
|
+
chartTableColumns
|
|
1441
|
+
});
|
|
1442
|
+
return;
|
|
1445
1443
|
}
|
|
1446
1444
|
callback && callback(error_message, '', null);
|
|
1447
1445
|
},
|
|
@@ -1568,11 +1566,13 @@ ChartUtils.isChartEqual = (preChartElement, curChartElement) => {
|
|
|
1568
1566
|
return shallowEqual(preChartElement.config, curChartElement.config);
|
|
1569
1567
|
};
|
|
1570
1568
|
ChartUtils.isChartStyleChange = (preChartElement, curChartElement) => {
|
|
1569
|
+
var _preChartElement$heig, _curChartElement$heig;
|
|
1571
1570
|
const elementType = preChartElement.config.type;
|
|
1572
1571
|
if (elementType !== curChartElement.config.type) return false;
|
|
1573
|
-
|
|
1574
|
-
if (preChartElement.
|
|
1575
|
-
if (preChartElement.
|
|
1572
|
+
// used for app
|
|
1573
|
+
if ((preChartElement === null || preChartElement === void 0 ? void 0 : (_preChartElement$heig = preChartElement.height) === null || _preChartElement$heig === void 0 ? void 0 : _preChartElement$heig.value) !== (curChartElement === null || curChartElement === void 0 ? void 0 : (_curChartElement$heig = curChartElement.height) === null || _curChartElement$heig === void 0 ? void 0 : _curChartElement$heig.value)) return true;
|
|
1574
|
+
if ((preChartElement === null || preChartElement === void 0 ? void 0 : preChartElement.left_in_unit) !== (curChartElement === null || curChartElement === void 0 ? void 0 : curChartElement.left_in_unit)) return true;
|
|
1575
|
+
if ((preChartElement === null || preChartElement === void 0 ? void 0 : preChartElement.width_in_unit) !== (curChartElement === null || curChartElement === void 0 ? void 0 : curChartElement.width_in_unit)) return true;
|
|
1576
1576
|
if (!ObjectUtils.isSameObject(preChartElement.style_config, curChartElement.style_config)) return true;
|
|
1577
1577
|
return !CHART_STYLE_SETTING_KEYS.every(key => preChartElement.config[key] === curChartElement.config[key]);
|
|
1578
1578
|
};
|
package/dist/view/index.js
CHANGED
|
@@ -52,8 +52,7 @@ class View extends React.PureComponent {
|
|
|
52
52
|
let isNeedRequestData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
53
53
|
const {
|
|
54
54
|
tables,
|
|
55
|
-
chart
|
|
56
|
-
isStatisticalData
|
|
55
|
+
chart
|
|
57
56
|
} = _this.props;
|
|
58
57
|
const {
|
|
59
58
|
data
|
|
@@ -62,7 +61,7 @@ class View extends React.PureComponent {
|
|
|
62
61
|
ChartUtils.calculateStaticChart(tables, chart, data, _this.callback);
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
|
-
ChartUtils.calculateChart(chart, tables, _this.callback
|
|
64
|
+
ChartUtils.calculateChart(chart, tables, _this.callback);
|
|
66
65
|
};
|
|
67
66
|
this.state = {
|
|
68
67
|
isCalculated: false,
|
|
@@ -157,7 +156,6 @@ class View extends React.PureComponent {
|
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
View.defaultProps = {
|
|
160
|
-
isStatisticalData: true,
|
|
161
159
|
canvasStyle: {},
|
|
162
160
|
tables: [],
|
|
163
161
|
chart: {
|