Skip to content

Commit a15e587

Browse files
committed
1 parent 01c1fb1 commit a15e587

File tree

5 files changed

+271
-271
lines changed

5 files changed

+271
-271
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
node_modules
2-
dist
1+
node_modules
2+
dist
33
package-lock.json

README.md

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,82 @@
1-
# JavaScript 3D Scatter Chart
2-
3-
![JavaScript 3D Scatter Chart](3dScatter.png)
4-
5-
This demo application belongs to the set of examples for LightningChart JS, data visualization library for JavaScript.
6-
7-
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.
8-
9-
The demo can be used as an example or a seed project. Local execution requires the following steps:
10-
11-
- Make sure that relevant version of [Node.js](https://nodejs.org/en/download/) is installed
12-
- Open the project folder in a terminal:
13-
14-
npm install # fetches dependencies
15-
npm start # builds an application and starts the development server
16-
17-
- The application is available at *http://localhost:8080* in your browser, webpack-dev-server provides hot reload functionality.
18-
19-
20-
## Description
21-
22-
*Also known as a Scatter Graph, Scatter Series, Point Graph, Scatter diagram or Scattergram*
23-
24-
This example shows a simple 3D Point Graph with points drawn using 3D PointSeries for a visual representation of the data points 'markers'. The point graph is a type of chart or mathematical diagram drawn on a Cartesian coordinate system and represents the relationship between two variables.
25-
26-
This type of series does not contain the visual representation of lines for the connection of data points but only data 'markers'.
27-
28-
The chart can be created with few simple lines of code:
29-
30-
```javascript
31-
// Create a new ChartXY.
32-
const chart3D = lightningChart().Chart3D()
33-
34-
// Add a line series using default X, Y and Z axes.
35-
const series = chart3D.addPointSeries()
36-
```
37-
38-
The series accepts points in format `{ x: number, y: number, z:number }`. Any number of points can be added with a single call.
39-
40-
```javascript
41-
// Single point.
42-
series.add({ x: 50, y: 60, z: 40 })
43-
44-
// Multiple points at once.
45-
series.add([
46-
{ x: 55, y: 60, z:40 },
47-
{ x: 60, y: 62, z:40 },
48-
{ x: 65, y: 65, z:50 }
49-
])
50-
```
51-
52-
53-
## API Links
54-
1+
# JavaScript 3D Scatter Chart
2+
3+
![JavaScript 3D Scatter Chart](3dScatter.png)
4+
5+
This demo application belongs to the set of examples for LightningChart JS, data visualization library for JavaScript.
6+
7+
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.
8+
9+
The demo can be used as an example or a seed project. Local execution requires the following steps:
10+
11+
- Make sure that relevant version of [Node.js](https://nodejs.org/en/download/) is installed
12+
- Open the project folder in a terminal:
13+
14+
npm install # fetches dependencies
15+
npm start # builds an application and starts the development server
16+
17+
- The application is available at *http://localhost:8080* in your browser, webpack-dev-server provides hot reload functionality.
18+
19+
20+
## Description
21+
22+
*Also known as a Scatter Graph, Scatter Series, Point Graph, Scatter diagram or Scattergram*
23+
24+
This example shows a simple 3D Point Graph with points drawn using 3D PointSeries for a visual representation of the data points 'markers'. The point graph is a type of chart or mathematical diagram drawn on a Cartesian coordinate system and represents the relationship between two variables.
25+
26+
This type of series does not contain the visual representation of lines for the connection of data points but only data 'markers'.
27+
28+
The chart can be created with few simple lines of code:
29+
30+
```javascript
31+
// Create a new ChartXY.
32+
const chart3D = lightningChart().Chart3D()
33+
34+
// Add a line series using default X, Y and Z axes.
35+
const series = chart3D.addPointSeries()
36+
```
37+
38+
The series accepts points in format `{ x: number, y: number, z:number }`. Any number of points can be added with a single call.
39+
40+
```javascript
41+
// Single point.
42+
series.add({ x: 50, y: 60, z: 40 })
43+
44+
// Multiple points at once.
45+
series.add([
46+
{ x: 55, y: 60, z:40 },
47+
{ x: 60, y: 62, z:40 },
48+
{ x: 65, y: 65, z:50 }
49+
])
50+
```
51+
52+
53+
## API Links
54+
5555
* [3D chart]
5656
* [3D point series]
57-
58-
59-
## Support
60-
61-
If you notice an error in the example code, please open an issue on [GitHub][0] repository of the entire example.
62-
63-
Official [API documentation][1] can be found on [Arction][2] website.
64-
65-
If the docs and other materials do not solve your problem as well as implementation help is needed, ask on [StackOverflow][3] (tagged lightningchart).
66-
67-
If you think you found a bug in the LightningChart JavaScript library, please contact support@arction.com.
68-
69-
Direct developer email support can be purchased through a [Support Plan][4] or by contacting sales@arction.com.
70-
71-
[0]: https://github.com/Arction/
72-
[1]: https://www.arction.com/lightningchart-js-api-documentation/
73-
[2]: https://www.arction.com
74-
[3]: https://stackoverflow.com/questions/tagged/lightningchart
75-
[4]: https://www.arction.com/support-services/
76-
77-
© Arction Ltd 2009-2020. All rights reserved.
78-
79-
57+
58+
59+
## Support
60+
61+
If you notice an error in the example code, please open an issue on [GitHub][0] repository of the entire example.
62+
63+
Official [API documentation][1] can be found on [Arction][2] website.
64+
65+
If the docs and other materials do not solve your problem as well as implementation help is needed, ask on [StackOverflow][3] (tagged lightningchart).
66+
67+
If you think you found a bug in the LightningChart JavaScript library, please contact support@arction.com.
68+
69+
Direct developer email support can be purchased through a [Support Plan][4] or by contacting sales@arction.com.
70+
71+
[0]: https://github.com/Arction/
72+
[1]: https://www.arction.com/lightningchart-js-api-documentation/
73+
[2]: https://www.arction.com
74+
[3]: https://stackoverflow.com/questions/tagged/lightningchart
75+
[4]: https://www.arction.com/support-services/
76+
77+
© Arction Ltd 2009-2020. All rights reserved.
78+
79+
8080
[3D chart]: https://www.arction.com/lightningchart-js-api-documentation/v3.1.0/classes/chart3d.html
8181
[3D point series]: https://www.arction.com/lightningchart-js-api-documentation/v3.1.0/classes/pointseries3d.html
82-
82+

package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
{
2-
"version": "1.0.1",
3-
"scripts": {
4-
"build": "webpack --mode production",
5-
"start": "webpack-dev-server"
6-
},
7-
"license": "Custom",
8-
"private": true,
9-
"main": "./src/index.js",
10-
"devDependencies": {
11-
"copy-webpack-plugin": "^6.0.2",
12-
"html-webpack-plugin": "^3.2.0",
13-
"webpack-cli": "^3.3.10",
14-
"webpack-dev-server": "^3.9.0"
15-
},
16-
"dependencies": {
17-
"@arction/lcjs": "^3.2.0",
18-
"@arction/xydata": "^1.4.0",
19-
"clean-webpack-plugin": "^3.0.0",
20-
"webpack": "^4.41.2",
21-
"webpack-stream": "^5.2.1"
22-
}
23-
}
1+
{
2+
"version": "1.0.1",
3+
"scripts": {
4+
"build": "webpack --mode production",
5+
"start": "webpack-dev-server"
6+
},
7+
"license": "Custom",
8+
"private": true,
9+
"main": "./src/index.js",
10+
"devDependencies": {
11+
"copy-webpack-plugin": "^6.0.2",
12+
"html-webpack-plugin": "^3.2.0",
13+
"webpack-cli": "^3.3.10",
14+
"webpack-dev-server": "^3.9.0"
15+
},
16+
"dependencies": {
17+
"@arction/lcjs": "^3.2.0",
18+
"@arction/xydata": "^1.4.0",
19+
"clean-webpack-plugin": "^3.0.0",
20+
"webpack": "^4.41.2",
21+
"webpack-stream": "^5.2.1"
22+
}
23+
}

src/index.js

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,91 @@
1-
/*
2-
* LightningChartJS example that showcases PointSeries in a 3D Chart.
3-
*/
4-
// Import LightningChartJS
5-
const lcjs = require('@arction/lcjs')
6-
7-
// Extract required parts from LightningChartJS.
8-
const {
9-
lightningChart,
10-
SolidFill,
11-
ColorRGBA,
12-
PointStyle3D,
13-
Themes
14-
} = lcjs
15-
16-
// Extract required parts from xyData.
17-
const {
18-
createWaterDropDataGenerator
19-
} = require('@arction/xydata')
20-
21-
// Initiate chart
22-
const chart3D = lightningChart().Chart3D({
23-
// theme: Themes.darkGold
24-
})
25-
.setTitle('3D Scatter Chart')
26-
27-
// Set Axis titles
28-
chart3D.getDefaultAxisX().setTitle('Axis X')
29-
chart3D.getDefaultAxisY().setTitle('Axis Y')
30-
chart3D.getDefaultAxisZ().setTitle('Axis Z')
31-
32-
// Create Point Series for rendering max Y coords.
33-
const pointSeriesMaxCoords = chart3D.addPointSeries()
34-
.setPointStyle(new PointStyle3D.Triangulated({
35-
fillStyle: new SolidFill({ color: ColorRGBA(224, 152, 0) }),
36-
size: 10,
37-
shape: 'sphere'
38-
}))
39-
.setName('Max coords')
40-
41-
// Create another Point Series for rendering other Y coords than Max.
42-
const pointSeriesOtherCoords = chart3D.addPointSeries()
43-
.setPointStyle(new PointStyle3D.Triangulated({
44-
fillStyle: new SolidFill({ color: ColorRGBA(255, 0, 0) }),
45-
size: 5,
46-
shape: 'cube'
47-
}))
48-
.setName('Below Max')
49-
50-
// Add LegendBox to chart.
51-
chart3D.addLegendBox()
52-
// Dispose example UI elements automatically if they take too much space. This is to avoid bad UI on mobile / etc. devices.
53-
.setAutoDispose({
54-
type: 'max-width',
55-
maxWidth: 0.30,
56-
})
57-
.add(chart3D)
58-
59-
// Generate heatmap data for depicting amount of scattered points along the XZ plane.
60-
let totalPointsAmount = 0
61-
const rows = 40
62-
const columns = 60
63-
createWaterDropDataGenerator()
64-
.setRows( rows )
65-
.setColumns( columns )
66-
.generate()
67-
.then( data => {
68-
// 'data' is a number Matrix number[][], that can be read as data[row][column].
69-
for ( let row = 0; row < rows; row ++ ) {
70-
for ( let column = 0; column < columns; column ++ ) {
71-
const value = data[row][column]
72-
// Generate 'value' amount of points along this XZ coordinate,
73-
// with the Y coordinate range based on 'value'.
74-
const pointsAmount = Math.ceil( value / 100 )
75-
const yMin = 0
76-
const yMax = value
77-
for ( let iPoint = 0; iPoint < pointsAmount; iPoint ++ ) {
78-
const y = yMin + Math.random() * (yMax - yMin)
79-
pointSeriesOtherCoords.add({ x: row, z: column, y })
80-
totalPointsAmount ++
81-
}
82-
pointSeriesMaxCoords.add({ x: row, z: column, y: yMax })
83-
totalPointsAmount ++
84-
}
85-
}
86-
87-
chart3D.setTitle(chart3D.getTitle() + ` (${totalPointsAmount} data points)`)
88-
// Set explicit Y Axis interval.
89-
chart3D.getDefaultAxisY().setInterval(0, 150, 2000, true)
90-
})
91-
1+
/*
2+
* LightningChartJS example that showcases PointSeries in a 3D Chart.
3+
*/
4+
// Import LightningChartJS
5+
const lcjs = require('@arction/lcjs')
6+
7+
// Extract required parts from LightningChartJS.
8+
const {
9+
lightningChart,
10+
SolidFill,
11+
ColorRGBA,
12+
PointStyle3D,
13+
Themes
14+
} = lcjs
15+
16+
// Extract required parts from xyData.
17+
const {
18+
createWaterDropDataGenerator
19+
} = require('@arction/xydata')
20+
21+
// Initiate chart
22+
const chart3D = lightningChart().Chart3D({
23+
// theme: Themes.darkGold
24+
})
25+
.setTitle('3D Scatter Chart')
26+
27+
// Set Axis titles
28+
chart3D.getDefaultAxisX().setTitle('Axis X')
29+
chart3D.getDefaultAxisY().setTitle('Axis Y')
30+
chart3D.getDefaultAxisZ().setTitle('Axis Z')
31+
32+
// Create Point Series for rendering max Y coords.
33+
const pointSeriesMaxCoords = chart3D.addPointSeries()
34+
.setPointStyle(new PointStyle3D.Triangulated({
35+
fillStyle: new SolidFill({ color: ColorRGBA(224, 152, 0) }),
36+
size: 10,
37+
shape: 'sphere'
38+
}))
39+
.setName('Max coords')
40+
41+
// Create another Point Series for rendering other Y coords than Max.
42+
const pointSeriesOtherCoords = chart3D.addPointSeries()
43+
.setPointStyle(new PointStyle3D.Triangulated({
44+
fillStyle: new SolidFill({ color: ColorRGBA(255, 0, 0) }),
45+
size: 5,
46+
shape: 'cube'
47+
}))
48+
.setName('Below Max')
49+
50+
// Add LegendBox to chart.
51+
chart3D.addLegendBox()
52+
// Dispose example UI elements automatically if they take too much space. This is to avoid bad UI on mobile / etc. devices.
53+
.setAutoDispose({
54+
type: 'max-width',
55+
maxWidth: 0.30,
56+
})
57+
.add(chart3D)
58+
59+
// Generate heatmap data for depicting amount of scattered points along the XZ plane.
60+
let totalPointsAmount = 0
61+
const rows = 40
62+
const columns = 60
63+
createWaterDropDataGenerator()
64+
.setRows( rows )
65+
.setColumns( columns )
66+
.generate()
67+
.then( data => {
68+
// 'data' is a number Matrix number[][], that can be read as data[row][column].
69+
for ( let row = 0; row < rows; row ++ ) {
70+
for ( let column = 0; column < columns; column ++ ) {
71+
const value = data[row][column]
72+
// Generate 'value' amount of points along this XZ coordinate,
73+
// with the Y coordinate range based on 'value'.
74+
const pointsAmount = Math.ceil( value / 100 )
75+
const yMin = 0
76+
const yMax = value
77+
for ( let iPoint = 0; iPoint < pointsAmount; iPoint ++ ) {
78+
const y = yMin + Math.random() * (yMax - yMin)
79+
pointSeriesOtherCoords.add({ x: row, z: column, y })
80+
totalPointsAmount ++
81+
}
82+
pointSeriesMaxCoords.add({ x: row, z: column, y: yMax })
83+
totalPointsAmount ++
84+
}
85+
}
86+
87+
chart3D.setTitle(chart3D.getTitle() + ` (${totalPointsAmount} data points)`)
88+
// Set explicit Y Axis interval.
89+
chart3D.getDefaultAxisY().setInterval(0, 150, 2000, true)
90+
})
91+

0 commit comments

Comments
 (0)