@alphapoint/apex-chart-react 5.5.4

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/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) AlphaPoint. All rights reserved.
2
+
3
+ This software is proprietary to AlphaPoint. Use, reproduction,
4
+ modification, or distribution is permitted only under a commercial
5
+ agreement with AlphaPoint. No other rights are granted.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # apex-chart-react
2
+
3
+ This is the apex-chart as an npm package.
4
+
5
+ ## Installation:
6
+
7
+ `npm install --save apex-chart-react`
8
+
9
+ ## Usage:
10
+
11
+ ### Step 1, Import:
12
+
13
+ `import ApexChartBuilder from '@alphapoint/apex-chart-react'`
14
+
15
+ ### Step 2, Instantiate:
16
+
17
+ `const chart = new ApexChartBuilder('alphapoint', {'instrument_id': 2});`
18
+
19
+ First argument is the target element's ID.
20
+
21
+ Second argument is the config object. Pass in an object with any number of config options, defaults will be used for any unprovided options.
22
+
23
+ `'instrument_id'` is a new configuration option for apex-chart-react. Defaults to 1.
24
+
25
+ #### Passing data
26
+
27
+ ##### 1) RxJS sample:
28
+ You can pass chartDataSubject option in config object to establish connection via RxJS subject
29
+
30
+ ```
31
+ import { BehaviorSubject } from 'rxjs';
32
+
33
+ this.chartDataSubject = new BehaviorSubject(chartData);
34
+ const chartConfig = {
35
+ chartDataSubject: this.chartDataSubject,
36
+ ...
37
+ }
38
+
39
+ componentDidUpdate(prevProps) {
40
+ if (prevProps.chartData !== this.props.chartData) {
41
+ this.chartDataSubject.next(this.props.chartData);
42
+ }
43
+ }
44
+ ```
45
+ chartData in this case should contain all needed values for chart updates:
46
+
47
+ `chartData: { level1, level2, tickers, selectedInstrumentId }`
48
+
49
+ ##### 2) Manually updates sample:
50
+ In case of passing chartData to chart we should control all data changes on client side and call appropriate methods to update this data.
51
+
52
+ React usage example:
53
+
54
+ ```
55
+ componentDidMount() {
56
+ const chartConfig = {
57
+ 'instrument_id': 2,
58
+ chartData: { level2, tickers, marketPrice },
59
+ }
60
+ this.chart = new ApexChartBuilder('alphapoint', chartConfig);
61
+ }
62
+
63
+ componentDidUpdate(prevProps) {
64
+ if (prevProps.level2 !== this.props.level2) {
65
+ this.chart.UpdateLevel2Data(this.props.level2);
66
+ }
67
+ if (prevProps.tickers.tickers !== this.props.tickers.tickers) {
68
+ this.chart.UpdateTickersData(this.props.tickers.tickers);
69
+ }
70
+ if (prevProps.tickers.fetching !== this.props.tickers.fetching) {
71
+ this.chart.OnLoadingStateChange(this.props.tickers.fetching);
72
+ }
73
+ if (prevProps.marketPrice !== this.props.marketPrice) {
74
+ this.chart.UpdateMarketPrice(this.props.marketPrice);
75
+ }
76
+ }
77
+ ```
78
+
79
+ All other configuration options can be found here:
80
+ https://github.com/alphapoint/apex-chart
81
+
82
+ ### Step 3, Draw Chart:
83
+
84
+ `chart.DrawChart();`
85
+
86
+ ### Step 4, Add Styles:
87
+
88
+ you can pull in the chart's styles by adding:
89
+
90
+ `import '@alphapoint/apex-chart-react/lib/chart-style.css'`
91
+
92
+ If the chart looks squished vertically just add `#alphapoint { height: 750px }` or some similar value to your css.
93
+
94
+ ## Notes
95
+
96
+ Default source of data is `wss://api_demo2.alphapoint.com/WSGateway/`. Change by passing a different uri via the configuration by setting:
97
+ ```
98
+ 'alphapoint_api': {
99
+ 'uri': 'wss://api_demo2.alphapoint.com/WSGateway/'
100
+ }
101
+ ```
102
+
103
+ ## Authors
104
+
105
+ * **Chris Stevens** - *Conversion to NPM package* - [AlphaPoint](https://github.com/chrisstevensap)
106
+
107
+ * **Dave Brushinski** - *Initial work* - [AlphaPoint](https://github.com/dbrushinski)
108
+
109
+ See also the list of [contributors](https://github.com/alphapoint/apex-chart/contributors) who participated in this project.