sea-chart 0.0.4 → 0.0.5
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 +1 -18
- package/dist/context.js +10 -3
- package/dist/editor/index.css +23 -0
- package/dist/editor/index.js +2 -16
- package/dist/index.js +3 -2
- package/dist/settings/table-settings/data-settings.js +1 -1
- package/dist/utils/chart-utils.js +6 -4
- package/dist/view/index.js +0 -1
- package/package.json +2 -1
package/dist/api/index.js
CHANGED
|
@@ -80,24 +80,7 @@ class SeaChartAPI {
|
|
|
80
80
|
this.instance = new SeaChartAPI(config);
|
|
81
81
|
return this.instance;
|
|
82
82
|
}
|
|
83
|
-
async init(
|
|
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
|
-
}
|
|
83
|
+
async init() {
|
|
101
84
|
const accessTokenRes = await this.getDTableAccessToken();
|
|
102
85
|
const {
|
|
103
86
|
app_name,
|
package/dist/context.js
CHANGED
|
@@ -3,13 +3,22 @@ import CollaboratorManager from './utils/collaborator-manager';
|
|
|
3
3
|
import { ChartDataSQL } from './utils';
|
|
4
4
|
class Context {
|
|
5
5
|
constructor() {
|
|
6
|
-
this.
|
|
6
|
+
this.queryChartResult = _ref => {
|
|
7
7
|
let {
|
|
8
8
|
chart,
|
|
9
9
|
tables,
|
|
10
10
|
onSuccess,
|
|
11
11
|
onFail
|
|
12
12
|
} = _ref;
|
|
13
|
+
// used custom api to get chart result data
|
|
14
|
+
if (this.api.queryChartResult) {
|
|
15
|
+
const chartId = chart.id;
|
|
16
|
+
return this.api.queryChartResult(chartId).then(res => {
|
|
17
|
+
onSuccess && onSuccess(res);
|
|
18
|
+
}).catch(error => {
|
|
19
|
+
onFail && onFail(error);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
13
22
|
const table = getTableById(tables, chart.config.table_id);
|
|
14
23
|
const chartDataSQL = new ChartDataSQL({
|
|
15
24
|
table,
|
|
@@ -31,7 +40,6 @@ class Context {
|
|
|
31
40
|
};
|
|
32
41
|
this.api = null;
|
|
33
42
|
this.settings = {};
|
|
34
|
-
this.hasInit = false;
|
|
35
43
|
this.collaborators = [];
|
|
36
44
|
this.collaboratorManager = null;
|
|
37
45
|
}
|
|
@@ -43,7 +51,6 @@ class Context {
|
|
|
43
51
|
collaborators,
|
|
44
52
|
collaboratorManager
|
|
45
53
|
} = props;
|
|
46
|
-
if (this.hasInit) return;
|
|
47
54
|
if (!config) {
|
|
48
55
|
throw new Error('Props config is required');
|
|
49
56
|
}
|
package/dist/editor/index.css
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.sea-chart-editor {
|
|
2
|
+
flex: 1;
|
|
3
|
+
display: flex;
|
|
4
|
+
min-height: 0;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.sea-chart-editor .sea-chart-formatter {
|
|
9
|
+
flex: 1;
|
|
10
|
+
display: flex;
|
|
11
|
+
min-height: 0;
|
|
12
|
+
min-width: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.sea-chart-editor .sea-chart-settings {
|
|
16
|
+
width: 300px;
|
|
17
|
+
height: 100%;
|
|
18
|
+
background-color: #fff;
|
|
19
|
+
margin-left: 16px;
|
|
20
|
+
border-top: 1px solid #e4e4e4;
|
|
21
|
+
border-left: 1px solid #e4e4e4;
|
|
22
|
+
border-right: 1px solid #e4e4e4;
|
|
23
|
+
}
|
package/dist/editor/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import classnames from 'classnames';
|
|
4
2
|
import context from '../context';
|
|
5
3
|
import View from '../view';
|
|
6
4
|
import Settings from '../settings';
|
|
@@ -11,21 +9,9 @@ class Editor extends React.PureComponent {
|
|
|
11
9
|
context.init(props);
|
|
12
10
|
}
|
|
13
11
|
render() {
|
|
14
|
-
const {
|
|
15
|
-
settingsTarget
|
|
16
|
-
} = this.props;
|
|
17
|
-
let settingsTargetNode = '';
|
|
18
|
-
if (settingsTarget) {
|
|
19
|
-
settingsTargetNode = document.getElementById(settingsTarget);
|
|
20
|
-
if (settingsTargetNode) {
|
|
21
|
-
ReactDOM.render( /*#__PURE__*/React.createElement(Settings, this.props), settingsTargetNode);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
12
|
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
-
className:
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
}, /*#__PURE__*/React.createElement(View, this.props), !settingsTargetNode && /*#__PURE__*/React.createElement(Settings, this.props));
|
|
13
|
+
className: "sea-chart-editor"
|
|
14
|
+
}, /*#__PURE__*/React.createElement(View, this.props), /*#__PURE__*/React.createElement(Settings, this.props));
|
|
29
15
|
}
|
|
30
16
|
}
|
|
31
17
|
Editor.defaultProps = {
|
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 };
|
|
@@ -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.queryChartResult({
|
|
1416
1416
|
chart,
|
|
1417
1417
|
tables,
|
|
1418
1418
|
onSuccess: res => {
|
|
@@ -1568,11 +1568,13 @@ ChartUtils.isChartEqual = (preChartElement, curChartElement) => {
|
|
|
1568
1568
|
return shallowEqual(preChartElement.config, curChartElement.config);
|
|
1569
1569
|
};
|
|
1570
1570
|
ChartUtils.isChartStyleChange = (preChartElement, curChartElement) => {
|
|
1571
|
+
var _preChartElement$heig, _curChartElement$heig;
|
|
1571
1572
|
const elementType = preChartElement.config.type;
|
|
1572
1573
|
if (elementType !== curChartElement.config.type) return false;
|
|
1573
|
-
|
|
1574
|
-
if (preChartElement.
|
|
1575
|
-
if (preChartElement.
|
|
1574
|
+
// used for app
|
|
1575
|
+
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;
|
|
1576
|
+
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;
|
|
1577
|
+
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
1578
|
if (!ObjectUtils.isSameObject(preChartElement.style_config, curChartElement.style_config)) return true;
|
|
1577
1579
|
return !CHART_STYLE_SETTING_KEYS.every(key => preChartElement.config[key] === curChartElement.config[key]);
|
|
1578
1580
|
};
|
package/dist/view/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sea-chart",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@antv/data-set": "0.11.8",
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
"raf": "3.4.0",
|
|
127
127
|
"react": "17.0.0",
|
|
128
128
|
"react-app-polyfill": "^1.0.4",
|
|
129
|
+
"react-cookies": "0.1.1",
|
|
129
130
|
"react-dev-utils": "^12.0.1",
|
|
130
131
|
"react-dom": "17.0.0",
|
|
131
132
|
"react-hot-loader": "4.13.1",
|