Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support node #118

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,28 @@ jobs:
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true

build-nodejs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Install Cairo dependencies
run: |
Invoke-WebRequest "http://ftp.gnome.org/pub/GNOME/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip" -OutFile "gtk.zip"
Expand-Archive gtk.zip -DestinationPath "C:\GTK"
Invoke-WebRequest "https://downloads.sourceforge.net/project/libjpeg-turbo/2.0.4/libjpeg-turbo-2.0.4-vc64.exe" -OutFile "libjpeg.exe" -UserAgent NativeHost
.\libjpeg.exe /S
- name: Add msbuild to PATH
uses: microsoft/[email protected]
with:
vs-version: '15.0'
- name: Install
run: npm ci
- name: Build
run: npm run build
- name: Test
run: npm run test-node
6 changes: 3 additions & 3 deletions docs/chartjs-chart-financial.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('chart.js'), require('chart.js/helpers')) :
typeof define === 'function' && define.amd ? define(['chart.js', 'chart.js/helpers'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Chart, global.Chart.helpers));
}(this, (function (chart_js, helpers) { 'use strict';
})(this, (function (chart_js, helpers) { 'use strict';

/**
* Computes the "optimal" sample size to maintain bars equally sized while preventing overlap.
Expand Down Expand Up @@ -191,7 +191,7 @@ FinancialController.overrides = {
sampleSize: 100
},
afterBuildTicks: scale => {
const DateTime = window && window.luxon && window.luxon.DateTime;
const DateTime = (typeof (window) !== 'undefined') && window.luxon && window.luxon.DateTime;
if (!DateTime) {
return;
}
Expand Down Expand Up @@ -519,4 +519,4 @@ OhlcController.defaults = helpers.merge({

chart_js.Chart.register(CandlestickController, OhlcController, CandlestickElement, OhlcElement);

})));
}));
11 changes: 7 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ const builds = require('./rollup.config');

module.exports = function(karma) {
const args = karma.args || {};
const watch = args.watch;
const inputs = args.inputs;
const coverage = args.coverage || karma.coverage;

// Use the same rollup config as our dist files: when debugging (--watch),
// we will prefer the unminified build which is easier to browse and works
// better with source mapping. In other cases, pick the minified build to
// make sure that the minification process (terser) doesn't break anything.
const regex = args.watch ? /chartjs-chart-financial\.js$/ : /chartjs-chart-financial\.min\.js$/;
const regex = watch ? /chartjs-chart-financial\.js$/ : /chartjs-chart-financial\.min\.js$/;
const output = builds[0].output.filter((v) => v.file.match(regex))[0];
const build = Object.assign({}, builds[0], {output: output});
const inputs = args.inputs || 'test/specs/**/*.js';
const files = inputs || 'test/specs/**/*.js';

karma.set({
browsers: ['chrome'],
Expand Down Expand Up @@ -41,7 +44,7 @@ module.exports = function(karma) {
'node_modules/chartjs-adapter-luxon/dist/chartjs-adapter-luxon.js',
'test/index.js',
'src/index.js'
].concat(inputs),
].concat(files),
preprocessors: {
'test/specs/**/*.js': ['rollup'],
'test/index.js': ['rollup'],
Expand Down Expand Up @@ -78,7 +81,7 @@ module.exports = function(karma) {
karma.customLaunchers.chrome.flags.push('--no-sandbox');
}

if (args.coverage) {
if (coverage) {
karma.reporters.push('coverage');
karma.coverageReporter = {
dir: 'coverage/',
Expand Down
Loading