diff --git a/.github/workflows/gh-pages-deploy.yml b/.github/workflows/gh-pages-deploy.yml new file mode 100644 index 0000000..b35d82b --- /dev/null +++ b/.github/workflows/gh-pages-deploy.yml @@ -0,0 +1,31 @@ +name: GitHub Pages + +on: + push: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js 16.x + uses: actions/setup-node@v1 + with: + node-version: "16.x" + + - name: Build + env: + LCJS_LICENSE: ${{ secrets.LCJS_DEPLOY_LICENSE }} + run: | + npm install + npm run build + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist + publish_branch: gh-pages diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4175924 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +dist + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f9b2960 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 LightningChart Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9e0fa8c --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# Parallel Coordinate Chart with Value Thresholds + +![Parallel Coordinate Chart with Value Thresholds](parallelCoordChartThresholds-darkGold.png) + +This demo application belongs to the set of examples for LightningChart JS, data visualization library for JavaScript. + +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. + +The demo can be used as an example or a seed project. Local execution requires the following steps: + +- Make sure that relevant version of [Node.js](https://nodejs.org/en/download/) is installed +- Open the project folder in a terminal: + + npm install # fetches dependencies + npm start # builds an application and starts the development server + +- The application is available at _http://localhost:8080_ in your browser, webpack-dev-server provides hot reload functionality. + + +## Description + +A common use case is to display value thresholds on different axes. +E.g. which value range is _bad_ and which is _good_. + +This example shows how this can be done by styling the Axis line style with a `PalettedFill`. + +## API Links + + + +## Support + +If you notice an error in the example code, please open an issue on [GitHub][0] repository of the entire example. + +Official [API documentation][1] can be found on [LightningChart][2] website. + +If the docs and other materials do not solve your problem as well as implementation help is needed, ask on [StackOverflow][3] (tagged lightningchart). + +If you think you found a bug in the LightningChart JavaScript library, please contact sales@lightningchart.com. + +Direct developer email support can be purchased through a [Support Plan][4] or by contacting sales@lightningchart.com. + +[0]: https://github.com/Arction/ +[1]: https://lightningchart.com/lightningchart-js-api-documentation/ +[2]: https://lightningchart.com +[3]: https://stackoverflow.com/questions/tagged/lightningchart +[4]: https://lightningchart.com/support-services/ + +© LightningChart Ltd 2009-2022. All rights reserved. + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..fd75a87 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "version": "2.0.0", + "scripts": { + "build": "webpack --mode production", + "start": "webpack serve" + }, + "license": "MIT", + "private": true, + "main": "./src/index.js", + "devDependencies": { + "clean-webpack-plugin": "^4.0.0", + "copy-webpack-plugin": "^10.0.0", + "html-webpack-plugin": "^5.5.0", + "webpack": "^5.64.4", + "webpack-cli": "^4.9.1", + "webpack-dev-server": "^4.6.0", + "webpack-stream": "^7.0.0" + }, + "dependencies": { + "@lightningchart/lcjs": "^6.0.0", + "@lightningchart/xydata": "^1.4.0" + }, + "lightningChart": { + "eID": "1704" + } +} diff --git a/parallelCoordChartThresholds-cyberSpace.png b/parallelCoordChartThresholds-cyberSpace.png new file mode 100644 index 0000000..a35c8ee Binary files /dev/null and b/parallelCoordChartThresholds-cyberSpace.png differ diff --git a/parallelCoordChartThresholds-darkGold.png b/parallelCoordChartThresholds-darkGold.png new file mode 100644 index 0000000..45062c6 Binary files /dev/null and b/parallelCoordChartThresholds-darkGold.png differ diff --git a/parallelCoordChartThresholds-light.png b/parallelCoordChartThresholds-light.png new file mode 100644 index 0000000..7acdc6a Binary files /dev/null and b/parallelCoordChartThresholds-light.png differ diff --git a/parallelCoordChartThresholds-lightNature.png b/parallelCoordChartThresholds-lightNature.png new file mode 100644 index 0000000..1c59885 Binary files /dev/null and b/parallelCoordChartThresholds-lightNature.png differ diff --git a/parallelCoordChartThresholds-turquoiseHexagon.png b/parallelCoordChartThresholds-turquoiseHexagon.png new file mode 100644 index 0000000..ae7c229 Binary files /dev/null and b/parallelCoordChartThresholds-turquoiseHexagon.png differ diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..3a4fae2 --- /dev/null +++ b/src/index.js @@ -0,0 +1,91 @@ +const lcjs = require('@lightningchart/lcjs') +const { lightningChart, Themes, SolidLine, PalettedFill, LUT, ColorRGBA } = lcjs + +const lc = lightningChart({ + resourcesBaseUrl: new URL(document.head.baseURI).origin + new URL(document.head.baseURI).pathname + 'resources/', + }) +const chart = lc + .ParallelCoordinateChart({ + theme: Themes[new URLSearchParams(window.location.search).get('theme') || 'darkGold'] || undefined, + }) + .setTitle('Parallel Coordinate Chart with Value thresholds') + +const Axes = { + 'Variable A': 0, + 'Variable B': 1, + 'Variable C': 2, +} +chart.setAxes(Axes) +chart.getAxis(Axes['Variable A']).setInterval({ start: 20, end: 60 }) +chart.getAxis(Axes['Variable B']).setInterval({ start: 80, end: 120 }) +chart.getAxis(Axes['Variable C']).setInterval({ start: 0.0, end: 2.5 }) + +const series1 = chart.addSeries().setName('Sample 1').setData({ + 'Variable A': 36, + 'Variable B': 100, + 'Variable C': 1.1, +}) + +const series2 = chart.addSeries().setName('Sample 2').setData({ + 'Variable A': 32, + 'Variable B': 115, + 'Variable C': 0.5, +}) + +const series3 = chart.addSeries().setName('Sample 3').setData({ + 'Variable A': 35, + 'Variable B': 82, + 'Variable C': 0.9, +}) + +// Show value range warning thresholds for each axis. +// This can be done by styling the Axis stroke with color lookup by Y +const theme = chart.getTheme() +const colorOK = ColorRGBA(0, 0, 0, 0) +const colorWarning = theme.examples.badGoodColorPalette[0] +chart.getAxis(Axes['Variable A']).setStrokeStyle( + new SolidLine({ + thickness: 4, + fillStyle: new PalettedFill({ + lookUpProperty: 'y', + lut: new LUT({ + interpolate: false, + steps: [ + { value: 0, color: colorOK }, + { value: 50, color: colorWarning }, + ], + }), + }), + }), +) +chart.getAxis(Axes['Variable B']).setStrokeStyle( + new SolidLine({ + thickness: 4, + fillStyle: new PalettedFill({ + lookUpProperty: 'y', + lut: new LUT({ + interpolate: false, + steps: [ + { value: 0, color: colorWarning }, + { value: 85, color: colorOK }, + ], + }), + }), + }), +) +chart.getAxis(Axes['Variable C']).setStrokeStyle( + new SolidLine({ + thickness: 4, + fillStyle: new PalettedFill({ + lookUpProperty: 'y', + lut: new LUT({ + interpolate: false, + steps: [ + { value: 0, color: colorWarning }, + { value: 0.2, color: colorOK }, + { value: 1.5, color: colorWarning }, + ], + }), + }), + }), +) diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..34aaac1 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,70 @@ +const HtmlWebpackPlugin = require('html-webpack-plugin') +const { CleanWebpackPlugin } = require('clean-webpack-plugin') +const CopyWebpackPlugin = require('copy-webpack-plugin') +const path = require('path') +const webpack = require('webpack') + +const targetFolderName = 'dist' +const outputPath = path.resolve(__dirname, targetFolderName) +const packageJSON = require('./package.json') + +module.exports = { + mode: 'development', + entry: { + app: packageJSON.main, + }, + devServer: { + static: outputPath, + compress: true, + }, + resolve: { + modules: [path.resolve('./src'), path.resolve('./node_modules')], + extensions: ['.js'], + }, + output: { + filename: 'js/[name].[contenthash].bundle.js', + chunkFilename: 'js/[name].[contenthash].bundle.js', + path: outputPath, + }, + optimization: { + splitChunks: { + chunks: 'all', + cacheGroups: { + // make separate 'vendor' chunk that contains any dependencies + // allows for smaller file sizes and faster builds + vendor: { + test: /[\\/]node_modules[\\/]/, + chunks: 'initial', + name: 'vendor', + priority: -10, + reuseExistingChunk: true, + }, + }, + }, + runtimeChunk: 'single', + }, + plugins: [ + new CleanWebpackPlugin(), + new HtmlWebpackPlugin({ + title: 'app', + filename: path.resolve(__dirname, 'dist', 'index.html'), + }), + new CopyWebpackPlugin({ + patterns: [ + { + from: './assets/**/*', + to: `./examples/assets/${packageJSON.lightningChart.eID}/[name][ext]`, + noErrorOnMissing: true, + }, + { + from: './node_modules/@lightningchart/lcjs/dist/resources', + to: 'resources', + noErrorOnMissing: true, + }, + ], + }), + new webpack.DefinePlugin({ + LCJS_LICENSE: "'" + process.env.LCJS_LICENSE + "'", + }), + ], +}