Skip to content

Commit e769b69

Browse files
author
Niilo Keinänen
committed
Merge branch '8-re-add-support-for-lcjs-headless-with-lcjs-v5-x' into 'master'
Resolve "Re-add support for lcjs-headless with LCJS v5.x" Closes #8 See merge request arction/lcjs/lcjs-headless!3
2 parents c52e09d + 3d6a43f commit e769b69

File tree

12 files changed

+3167
-94
lines changed

12 files changed

+3167
-94
lines changed

.npmrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
registry=https://registry.npmjs.org/
1+
registry=https://registry.npmjs.org/
2+
@lightningchart:registry=https://registry.npmjs.org/

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Change Log
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
56
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
67

78
## [Unreleased] - yyyy-mm-dd
9+
810
### Added
911

1012
### Changed
@@ -15,31 +17,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1517

1618
### Security
1719

20+
## [2.0.0] - 2024-08-06
21+
22+
### Changed
23+
24+
- Re-added compatibility with later (v6.0.0^) LightningChart JS versions
25+
- Using headless requires a deployment license always. Developer licenses are not supported.
26+
- NPM organization changed from `@arction` to `@lightningchart`
27+
1828
## [1.6.0] - 2023-02-07
29+
1930
### Added
2031

2132
- Support for LightningChart JS 4.0.0+.
2233

2334
## [1.5.0] - 2021-12-01
35+
2436
### Added
2537

2638
- Support for LightningChart JS 3.3.0+ and ImageFill.
2739

2840
## [1.4.0] - 2021-07-28
41+
2942
### Added
3043

3144
- Support for LightningChart JS 3.1.0+ and Map Charts.
3245

3346
## [1.3.0] - 2021-05-05
47+
3448
### Added
3549

3650
- Support for LightningChart JS 3.0.0+
51+
3752
## [1.1.0] - 2020-12-01
53+
3854
### Added
3955

4056
- Support for LightningChart JS 2.1.0+
4157

4258
## [1.0.0] - 2020-04-28
59+
4360
### Added
4461

4562
- Initial release

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020 Arction Ltd.
1+
Copyright (c) 2024 LightningChart Ltd.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 74 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This package uses [JSDOM][jsdom], [node-canvas][node-canvas] and [headless-gl][g
2626

2727
### Linux
2828

29-
Only Ubuntu is currently officially supported. `@arction/lcjs-headless` most likely works on other distributions but might require extra work.
29+
Only Ubuntu is currently officially supported. `@lightningchart/lcjs-headless` most likely works on other distributions but might require extra work.
3030

3131
#### Ubuntu
3232

@@ -54,45 +54,57 @@ See [headless-gl system dependencies][gl-dependencies] for more details.
5454

5555
## Getting Started
5656

57-
Install both `@arction/lcjs-headless` and `@arction/lcjs` from npm.
57+
Install both `@lightningchart/lcjs-headless` and `@lightningchart/lcjs` from npm.
5858

59-
`npm install @arction/lcjs-headless @arction/lcjs`
59+
`npm install @lightningchart/lcjs-headless @lightningchart/lcjs`
6060

61-
When creating a new chart make sure to import the `lightningChart()` function from `@arction/lcjs-headless` instead of `@arction/lcjs`. Other LightningChart JS related imports can be imported from `@arction/lcjs`.
61+
When creating a new chart make sure to import the `lightningChart()` function from `@lightningchart/lcjs-headless` instead of `@lightningchart/lcjs`. Other LightningChart JS related imports can be imported from `@lightningchart/lcjs`.
6262

6363
To render a chart to a buffer, call `chart.engine.renderFrame(width, height)`. This function will provide you a buffer containing a single image.
6464

6565
```js
66-
import { lightningChart } from '@arction/lcjs-headless'
66+
import { lightningChart } from "@lightningchart/lcjs-headless";
6767

68-
const lc = lightningChart()
69-
const chart = lc.ChartXY()
68+
const lc = lightningChart({
69+
license: "my-deployment-license-key",
70+
licenseInformation: "my-deployment-license-information",
71+
});
72+
const chart = lc.ChartXY();
7073

71-
chart.engine.renderFrame(1280, 720)
74+
chart.engine.renderFrame(1280, 720);
7275
```
7376

74-
The `@arction/lcjs-headless` package provides a couple of helper functions to make the use of LightningChart JS in Node JS environment easier. You can render an image directly to a `sharp` or `pngjs` objects with `renderToSharp` and `renderToPNG` helper functions.
77+
The `@lightningchart/lcjs-headless` package provides a couple of helper functions to make the use of LightningChart JS in Node JS environment easier. You can render an image directly to a `sharp` or `pngjs` objects with `renderToSharp` and `renderToPNG` helper functions.
7578

7679
```js
77-
import { lightningChart, renderToSharp } from '@arction/lcjs-headless'
80+
import { lightningChart, renderToSharp } from "@lightningchart/lcjs-headless";
7881

79-
const lc = lightningChart()
80-
const chart = lc.ChartXY()
82+
const lc = lightningChart({
83+
license: "my-deployment-license-key",
84+
licenseInformation: "my-deployment-license-information",
85+
});
86+
const chart = lc.ChartXY();
8187

82-
renderToSharp(chart, 1920, 1080).toFile('out.png')
88+
renderToSharp(chart, 1920, 1080).toFile("out.png");
8389
```
8490

8591
```js
86-
const fs = require('fs')
87-
const { PNG } = require('pngjs')
88-
const { lightningChart, renderToPNG } = require('@arction/lcjs-headless')
89-
90-
const lc = lightningChart()
91-
const chart = lc.ChartXY()
92-
93-
const chartOutput = renderToPNG(chart, 1920, 1080)
94-
const outputBuff = PNG.sync.write(chartOutput)
95-
fs.writeFileSync('./chartOutput.png', outputBuff)
92+
const fs = require("fs");
93+
const { PNG } = require("pngjs");
94+
const {
95+
lightningChart,
96+
renderToPNG,
97+
} = require("@lightningchart/lcjs-headless");
98+
99+
const lc = lightningChart({
100+
license: "my-deployment-license-key",
101+
licenseInformation: "my-deployment-license-information",
102+
});
103+
const chart = lc.ChartXY();
104+
105+
const chartOutput = renderToPNG(chart, 1920, 1080);
106+
const outputBuff = PNG.sync.write(chartOutput);
107+
fs.writeFileSync("./chartOutput.png", outputBuff);
96108
```
97109

98110
### Local Resources
@@ -101,8 +113,17 @@ When using Map Chart with in Node JS you need to provide the path to the LCJS re
101113

102114
```js
103115
const lcjs = lightningChart({
104-
resourcesBaseUrl: `fs:${path.resolve(__dirname, 'node_modules', '@arction', 'lcjs', 'dist', 'resources')}`
105-
})
116+
license: "my-deployment-license-key",
117+
licenseInformation: "my-deployment-license-information",
118+
resourcesBaseUrl: `fs:${path.resolve(
119+
__dirname,
120+
"node_modules",
121+
"@lightningchart",
122+
"lcjs",
123+
"dist",
124+
"resources"
125+
)}`,
126+
});
106127
```
107128

108129
### Headless in Linux machine
@@ -126,13 +147,16 @@ There is a few helper methods available that are exported by this package.
126147
- Prepares the frame to a "sharp" object, which allows the use of `sharp` to manipulate the image further or export it to a many different image formats.
127148

128149
```js
129-
import { lightningChart, renderToSharp } from '@arction/lcjs-headless'
150+
import { lightningChart, renderToSharp } from "@lightningchart/lcjs-headless";
130151

131-
const lc = lightningChart()
152+
const lc = lightningChart({
153+
license: "my-deployment-license-key",
154+
licenseInformation: "my-deployment-license-information",
155+
});
132156

133-
const chart = lc.ChartXY()
157+
const chart = lc.ChartXY();
134158

135-
renderToSharp(chart, 1920, 1080).toFile('out.png')
159+
renderToSharp(chart, 1920, 1080).toFile("out.png");
136160
```
137161

138162
> Note: There is a known issue with using `sharp` on Windows. https://sharp.pixelplumbing.com/install#canvas-and-windows
@@ -144,11 +168,11 @@ renderToSharp(chart, 1920, 1080).toFile('out.png')
144168
- Prepares the frame to a PNG image which can then be written to disk.
145169

146170
```js
147-
const fs = require('fs')
148-
const { PNG } = require('pngjs')
149-
const chartOutput = renderToPNG(chart, 1920, 1080)
150-
const outputBuff = PNG.sync.write(chartOutput)
151-
fs.writeFileSync('./chartOutput.png', outputBuff)
171+
const fs = require("fs");
172+
const { PNG } = require("pngjs");
173+
const chartOutput = renderToPNG(chart, 1920, 1080);
174+
const outputBuff = PNG.sync.write(chartOutput);
175+
fs.writeFileSync("./chartOutput.png", outputBuff);
152176
```
153177

154178
### `renderToBase64`
@@ -177,15 +201,18 @@ If the font is not a system font, then it needs to be registered before it can b
177201
This function is re-exported by this package from the `node-canvas` package.
178202

179203
```js
180-
import { lightningChart, registerFont } from '@arction/lcjs-headless'
204+
import { lightningChart, registerFont } from "@lightningchart/lcjs-headless";
181205
// Register Open Sans font from a font file
182-
registerFont('OpenSans-Regular.ttf', { family: 'Open Sans' })
206+
registerFont("OpenSans-Regular.ttf", { family: "Open Sans" });
183207

184208
// Create a chart
185-
const lc = lightningChart()
186-
const chart = lc.ChartXY()
209+
const lc = lightningChart({
210+
license: "my-deployment-license-key",
211+
licenseInformation: "my-deployment-license-information",
212+
});
213+
const chart = lc.ChartXY();
187214
// Use the registered font
188-
chart.setTitleFont((f) => f.setFamily('Open Sans'))
215+
chart.setTitleFont((f) => f.setFamily("Open Sans"));
189216
```
190217

191218
## Anti-aliasing
@@ -195,15 +222,18 @@ Anti-aliasing that is normally available in browsers is not available when using
195222
The `devicePixelRatio` option when creating a chart can be used to render the chart with higher resolution while scaling all elements so that when the image is downsampled to the target resolution it's displayed correctly but with the benefits of using higher resolution. Rendering at higher resolution is more work so the rendering is slower.
196223

197224
```js
198-
import { lightningChart, renderToSharp } from '@arction/lcjs-headless'
225+
import { lightningChart, renderToSharp } from "@lightningchart/lcjs-headless";
199226

200227
// Create a chart
201-
const lc = lightningChart()
228+
const lc = lightningChart({
229+
license: "my-deployment-license-key",
230+
licenseInformation: "my-deployment-license-information",
231+
});
202232
// Create the chart with a devicePixelRatio 3 to render at higher resolution for downsampling
203-
const chart = lc.ChartXY({ devicePixelRatio: 3 })
233+
const chart = lc.ChartXY({ devicePixelRatio: 3 });
204234
// render the chart to a sharp object
205235
// the renderToSharp has built in support for downsampling by providing the pixelRatio as the fourth parameter
206-
renderToSharp(chart, 1920, 1080, false, 3).toFile('out.png')
236+
renderToSharp(chart, 1920, 1080, false, 3).toFile("out.png");
207237
```
208238

209239
Only the `renderToSharp` helper has a built in scaling to downsample the image.
@@ -219,7 +249,7 @@ Make sure to install `fontconfig` package.
219249

220250
If the font is not a system font, you will need to register the font file with `registerFont` function.
221251

222-
[lcjs]: https://www.arction.com/lightningchart-js/
252+
[lcjs]: https://www.lightningchart.com/js-charts/
223253
[gl]: https://github.com/stackgl/headless-gl
224254
[jsdom]: https://github.com/jsdom/jsdom
225255
[node-canvas]: https://github.com/Automattic/node-canvas

0 commit comments

Comments
 (0)