sea-chart 0.0.4-beta → 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 CHANGED
@@ -80,24 +80,7 @@ class SeaChartAPI {
80
80
  this.instance = new SeaChartAPI(config);
81
81
  return this.instance;
82
82
  }
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
- }
83
+ async init() {
101
84
  const accessTokenRes = await this.getDTableAccessToken();
102
85
  const {
103
86
  app_name,
package/dist/context.js CHANGED
@@ -3,18 +3,20 @@ import CollaboratorManager from './utils/collaborator-manager';
3
3
  import { ChartDataSQL } from './utils';
4
4
  class Context {
5
5
  constructor() {
6
- this.queryResult = _ref => {
6
+ this.queryChartResult = _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
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);
18
20
  });
19
21
  }
20
22
  const table = getTableById(tables, chart.config.table_id);
@@ -38,7 +40,6 @@ class Context {
38
40
  };
39
41
  this.api = null;
40
42
  this.settings = {};
41
- this.hasInit = false;
42
43
  this.collaborators = [];
43
44
  this.collaboratorManager = null;
44
45
  }
@@ -50,7 +51,6 @@ class Context {
50
51
  collaborators,
51
52
  collaboratorManager
52
53
  } = props;
53
- if (this.hasInit) return;
54
54
  if (!config) {
55
55
  throw new Error('Props config is required');
56
56
  }
@@ -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
+ }
@@ -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,24 +9,13 @@ 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: classnames('sea-chart-editor', {
26
- 'd-flex': !settingsTargetNode
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 = {
18
+ isStatisticalData: true,
32
19
  canvasStyle: {},
33
20
  tables: [],
34
21
  chart: {
@@ -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, isChartData) => {
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) => {
1412
1412
  const error_message = 'There_are_some_problems_with_the_filters';
1413
1413
  return callback && callback(error_message, '', null);
1414
1414
  }
1415
- context.queryResult({
1415
+ context.queryChartResult({
1416
1416
  chart,
1417
1417
  tables,
1418
1418
  onSuccess: res => {
@@ -1422,24 +1422,26 @@ ChartUtils.calculateChart = (chart, tables, callback) => {
1422
1422
  error_message
1423
1423
  } = res.data;
1424
1424
  if (success) {
1425
- const tipMessage = 'There_are_no_statistic_results_yet';
1426
- if (!Array.isArray(sqlRows) || sqlRows.length === 0) {
1427
- callback && callback('', tipMessage, null);
1428
- return;
1429
- }
1430
- const chartResult = _class.sqlResult2JavaScript(newChart, sqlRows, chartSQLMap, columnMap, tables);
1431
- if (_class.imEmptyChartResult(chartResult)) {
1432
- callback && callback('', tipMessage, null);
1425
+ if (isChartData) {
1426
+ const tipMessage = 'There_are_no_statistic_results_yet';
1427
+ if (!Array.isArray(sqlRows) || sqlRows.length === 0) {
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
+ });
1433
1443
  return;
1434
1444
  }
1435
- callback && callback('', '', {
1436
- ...chartResult,
1437
- groupbyColumn,
1438
- columnGroupbyColumn,
1439
- summaryColumn,
1440
- chartTableColumns
1441
- });
1442
- return;
1443
1445
  }
1444
1446
  callback && callback(error_message, '', null);
1445
1447
  },
@@ -52,7 +52,8 @@ 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
55
+ chart,
56
+ isStatisticalData
56
57
  } = _this.props;
57
58
  const {
58
59
  data
@@ -61,7 +62,7 @@ class View extends React.PureComponent {
61
62
  ChartUtils.calculateStaticChart(tables, chart, data, _this.callback);
62
63
  return;
63
64
  }
64
- ChartUtils.calculateChart(chart, tables, _this.callback);
65
+ ChartUtils.calculateChart(chart, tables, _this.callback, isStatisticalData);
65
66
  };
66
67
  this.state = {
67
68
  isCalculated: false,
@@ -69,7 +70,6 @@ class View extends React.PureComponent {
69
70
  errorMessage: '',
70
71
  tipMessage: ''
71
72
  };
72
- console.log(props);
73
73
  context.init(props);
74
74
  }
75
75
  componentDidMount() {
@@ -156,6 +156,7 @@ class View extends React.PureComponent {
156
156
  }
157
157
  }
158
158
  View.defaultProps = {
159
+ isStatisticalData: true,
159
160
  canvasStyle: {},
160
161
  tables: [],
161
162
  chart: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.4-beta",
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",