Skip to content

Commit 774aae0

Browse files
committed
LCJS 4.0.1
1 parent 8357500 commit 774aae0

11 files changed

+158
-140
lines changed

.github/workflows/gh-pages-deploy.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@ name: Webpack build to GitHub Pages
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66

77
jobs:
88
build:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v2
1313

14-
- name: Use Node.js 16.x
15-
uses: actions/setup-node@v1
16-
with:
17-
node-version: '16.x'
14+
- name: Use Node.js 16.x
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: "16.x"
1818

19-
- name: Build
20-
run: |
21-
npm install
22-
npm run build
19+
- name: Build
20+
run: |
21+
npm install
22+
npm run build
2323
24-
- name: Deploy
25-
uses: peaceiris/actions-gh-pages@v3
26-
with:
27-
github_token: ${{ secrets.GITHUB_TOKEN }}
28-
publish_dir: ./dist
29-
publish_branch: gh-pages
24+
- name: Deploy
25+
uses: peaceiris/actions-gh-pages@v3
26+
with:
27+
github_token: ${{ secrets.GITHUB_TOKEN }}
28+
publish_dir: ./dist
29+
publish_branch: gh-pages

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 LightningChart Ltd.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
1-
# JavaScript OHLC Chart with Automatic Packing
1+
# JavaScript OHLC Series with Automatic Packing
22

3-
![JavaScript OHLC Chart with Automatic Packing](ohlcAutomaticPacking.png)
3+
![JavaScript OHLC Series with Automatic Packing](ohlcAutomaticPacking-darkGold.png)
44

55
This demo application belongs to the set of examples for LightningChart JS, data visualization library for JavaScript.
66

77
LightningChart JS is entirely GPU accelerated and performance optimized charting library for presenting massive amounts of data. It offers an easy way of creating sophisticated and interactive charts and adding them to your website or web application.
88

99
The demo can be used as an example or a seed project. Local execution requires the following steps:
1010

11-
- Make sure that relevant version of [Node.js](https://nodejs.org/en/download/) is installed
12-
- Open the project folder in a terminal:
11+
- Make sure that relevant version of [Node.js](https://nodejs.org/en/download/) is installed
12+
- Open the project folder in a terminal:
1313

14-
npm install # fetches dependencies
15-
npm start # builds an application and starts the development server
14+
npm install # fetches dependencies
15+
npm start # builds an application and starts the development server
1616

17-
- The application is available at *http://localhost:8080* in your browser, webpack-dev-server provides hot reload functionality.
17+
- The application is available at _http://localhost:8080_ in your browser, webpack-dev-server provides hot reload functionality.
1818

1919

2020
## Description
2121

2222
This example shows real-time OHLC-packing using a variant of OHLC-series.
2323

24+
## LightningChart JS OHLC Series with Automatic Packing
25+
26+
LightningChart JS includes a variant of the OHLC series which allows inputting close prices only which results in the corresponding OHLC data being automatically calculated.
27+
2428
```javascript
2529
const chart = lightningChart().ChartXY()
2630
const series = chart.addOHLCSeries(
2731
// Specify the type of OHLC-series for adding points
28-
{ seriesConstructor: OHLCSeriesTypes.AutomaticPacking }
32+
{ seriesConstructor: OHLCSeriesTypes.AutomaticPacking },
2933
)
3034
```
3135

@@ -38,16 +42,16 @@ series.add({ x: 50, y: 60 })
3842
// Multiple points at once.
3943
series.add([
4044
{ x: 55, y: 60 },
41-
{ x: 60, y: 62},
42-
{ x: 65, y: 65}
45+
{ x: 60, y: 62 },
46+
{ x: 65, y: 65 },
4347
])
4448
```
4549

4650
## Packing logic
4751

48-
Supplied points are packed by columns, within which the Y-values are mapped to open, high, low and close -values, which are used to draw *OHLCFigures*.
52+
Supplied points are packed by columns, within which the Y-values are mapped to open, high, low and close -values, which are used to draw _OHLCFigures_.
4953

50-
[//]: # "IMPORTANT: The assets will not show before README.md is built - relative path is different!"
54+
[//]: # 'IMPORTANT: The assets will not show before README.md is built - relative path is different!'
5155

5256
![](./assets/ohlcPacking.png)
5357

@@ -65,26 +69,26 @@ Supplied points are packed by columns, within which the Y-values are mapped to o
6569

6670
If you notice an error in the example code, please open an issue on [GitHub][0] repository of the entire example.
6771

68-
Official [API documentation][1] can be found on [Arction][2] website.
72+
Official [API documentation][1] can be found on [LightningChart][2] website.
6973

7074
If the docs and other materials do not solve your problem as well as implementation help is needed, ask on [StackOverflow][3] (tagged lightningchart).
7175

72-
If you think you found a bug in the LightningChart JavaScript library, please contact support@arction.com.
76+
If you think you found a bug in the LightningChart JavaScript library, please contact support@lightningchart.com.
7377

74-
Direct developer email support can be purchased through a [Support Plan][4] or by contacting sales@arction.com.
78+
Direct developer email support can be purchased through a [Support Plan][4] or by contacting sales@lightningchart.com.
7579

7680
[0]: https://github.com/Arction/
77-
[1]: https://www.arction.com/lightningchart-js-api-documentation/
78-
[2]: https://www.arction.com
81+
[1]: https://lightningchart.com/lightningchart-js-api-documentation/
82+
[2]: https://lightningchart.com
7983
[3]: https://stackoverflow.com/questions/tagged/lightningchart
80-
[4]: https://www.arction.com/support-services/
84+
[4]: https://lightningchart.com/support-services/
8185

82-
© Arction Ltd 2009-2020. All rights reserved.
86+
© LightningChart Ltd 2009-2022. All rights reserved.
8387

8488

85-
[XY cartesian chart]: https://www.arction.com/lightningchart-js-api-documentation/v3.4.0/classes/chartxy.html
86-
[Axis tick strategies]: https://www.arction.com/lightningchart-js-api-documentation/v3.4.0/globals.html#axistickstrategies
87-
[Freeform line series]: https://www.arction.com/lightningchart-js-api-documentation/v3.4.0/classes/lineseries.html
88-
[OHLC series]: https://www.arction.com/lightningchart-js-api-documentation/v3.4.0/classes/chartxy.html#addohlcseries
89-
[OHLC series types]: https://www.arction.com/lightningchart-js-api-documentation/v3.4.0/globals.html#ohlcseriestypes
89+
[XY cartesian chart]: https://lightningchart.com/lightningchart-js-api-documentation/v4.0.0/classes/ChartXY.html
90+
[Axis tick strategies]: https://lightningchart.com/lightningchart-js-api-documentation/v4.0.0/variables/AxisTickStrategies.html
91+
[Freeform line series]: https://lightningchart.com/lightningchart-js-api-documentation/v4.0.0/classes/LineSeries.html
92+
[OHLC series]: https://lightningchart.com/lightningchart-js-api-documentation/v4.0.0/classes/ChartXY.html#addOHLCSeries
93+
[OHLC series types]: https://lightningchart.com/lightningchart-js-api-documentation/v4.0.0/variables/OHLCSeriesTypes.html
9094

ohlcAutomaticPacking-cyberSpace.png

405 KB
Loading

ohlcAutomaticPacking-darkGold.png

233 KB
Loading

ohlcAutomaticPacking-light.png

152 KB
Loading

ohlcAutomaticPacking-lightNature.png

114 KB
Loading
454 KB
Loading

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"build": "webpack --mode production",
55
"start": "webpack serve"
66
},
7-
"license": "Custom",
7+
"license": "MIT",
88
"private": true,
99
"main": "./src/index.js",
1010
"devDependencies": {
@@ -17,7 +17,7 @@
1717
"webpack-stream": "^7.0.0"
1818
},
1919
"dependencies": {
20-
"@arction/lcjs": "^3.4.0",
20+
"@arction/lcjs": "^4.0.1",
2121
"@arction/xydata": "^1.4.0"
2222
},
2323
"lightningChart": {

src/index.js

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,14 @@
44
// Import LightningChartJS
55
const lcjs = require('@arction/lcjs')
66

7+
// Import xydata
8+
const xydata = require('@arction/xydata')
9+
710
// Extract required parts from LightningChartJS.
8-
const {
9-
lightningChart,
10-
AxisTickStrategies,
11-
AxisScrollStrategies,
12-
OHLCSeriesTypes,
13-
emptyLine,
14-
Themes
15-
} = lcjs
11+
const { lightningChart, AxisTickStrategies, AxisScrollStrategies, OHLCSeriesTypes, emptyLine, Themes } = lcjs
1612

1713
// Import data-generator from 'xydata'-library.
18-
const {
19-
createProgressiveTraceGenerator
20-
} = require('@arction/xydata')
14+
const { createProgressiveTraceGenerator } = xydata
2115

2216
// Decide on an origin for DateTime axis ( cur time - 5 minutes ).
2317
const fiveMinutesInMs = 5 * 60 * 1000
@@ -28,48 +22,40 @@ const chart = lightningChart().ChartXY({
2822
// theme: Themes.darkGold
2923
})
3024
// Use DateTime X-axis using previously defined origin.
31-
chart
32-
.getDefaultAxisX()
33-
.setTickStrategy(
34-
AxisTickStrategies.DateTime,
35-
(tickStrategy) => tickStrategy.setDateOrigin(dateOrigin)
36-
)
25+
chart.getDefaultAxisX().setTickStrategy(AxisTickStrategies.DateTime, (tickStrategy) => tickStrategy.setDateOrigin(dateOrigin))
3726

3827
// Set chart title and modify the padding of the chart.
39-
chart
40-
.setTitle('Realtime OHLC and line')
41-
.setPadding({
42-
right: 42
43-
})
28+
chart.setTitle('Realtime OHLC and line').setPadding({
29+
right: 42,
30+
})
4431
// Modify AutoCursor to only show TickMarker and Gridline over X Axis.
45-
chart.setAutoCursor(cursor => {
46-
cursor.disposeTickMarkerY()
32+
chart.setAutoCursor((cursor) => {
33+
cursor.setTickMarkerYVisible(false)
4734
cursor.setGridStrokeYStyle(emptyLine)
4835
})
4936

5037
// Configure X-axis to be progressive.
51-
chart.getDefaultAxisX()
38+
chart
39+
.getDefaultAxisX()
5240
.setScrollStrategy(AxisScrollStrategies.progressive)
5341
// View fits 5 minutes.
54-
.setInterval(0, fiveMinutesInMs)
42+
.setInterval({ start: 0, end: fiveMinutesInMs, stopAxisAfter: false })
5543

5644
// Show title 'USD' on Y axis.
57-
chart.getDefaultAxisY()
58-
.setTitle('USD')
45+
chart.getDefaultAxisY().setTitle('USD')
5946

6047
// Add underlying line series.
61-
const lineSeries = chart.addLineSeries()
48+
const lineSeries = chart
49+
.addLineSeries()
6250
.setCursorEnabled(false)
63-
.setStrokeStyle((strokeStyle) => strokeStyle
64-
.setFillStyle(fill => fill.setA(70))
65-
.setThickness(1)
66-
)
51+
.setStrokeStyle((strokeStyle) => strokeStyle.setFillStyle((fill) => fill.setA(70)).setThickness(1))
6752

6853
// Add OHLC series with automatic packing (so we can feed it XY-points just like for the line series).
69-
const ohlcSeriesAutoPacking = chart.addOHLCSeries(
70-
// Specify type of OHLC-series for adding points
71-
{ seriesConstructor: OHLCSeriesTypes.AutomaticPacking }
72-
)
54+
const ohlcSeriesAutoPacking = chart
55+
.addOHLCSeries(
56+
// Specify type of OHLC-series for adding points
57+
{ seriesConstructor: OHLCSeriesTypes.AutomaticPacking },
58+
)
7359
// Set packing resolution to 100 ms so we can zoom to full resolution.
7460
.setPackingResolution(100)
7561

@@ -85,10 +71,13 @@ createProgressiveTraceGenerator()
8571
.setNumberOfPoints(10000)
8672
.generate()
8773
.toPromise()
88-
.then((data) => data.map((p) => ({
89-
// Resolution = 100 ms.
90-
x: p.x * 100, y: p.y
91-
})))
74+
.then((data) =>
75+
data.map((p) => ({
76+
// Resolution = 100 ms.
77+
x: p.x * 100,
78+
y: p.y,
79+
})),
80+
)
9281
.then((data) => {
9382
// Add 5 minutes worth of points immediately ( to simulate previous data ).
9483
add(data.splice(0, Math.round(5 * 60 * 10)))

0 commit comments

Comments
 (0)