Skip to content

Commit 45a30fc

Browse files
committed
Remove Plotly lib ultimately reducing bundle size
1 parent a15335d commit 45a30fc

10 files changed

Lines changed: 1617 additions & 7098 deletions

File tree

danfojs/src/core/frame.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { Series } from "./series";
1818
import { Utils } from "./utils";
1919
import { GroupBy } from "./groupby";
2020
import { Plot } from "../plotting/plot";
21-
import { indexLoc } from "../core/indexing";
22-
import { concat } from "../core/concat.js";
21+
import { indexLoc } from "./indexing";
22+
import { concat } from "./concat.js";
2323

2424
const utils = new Utils();
2525
import { std, variance } from "mathjs";

danfojs/src/core/series.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { table } from 'table';
2323
import { Configs } from '../config/config';
2424
import { TimeSeries } from './timeseries';
2525
import { Plot } from '../plotting/plot';
26-
import { indexLoc } from '../core/indexing';
26+
import { indexLoc } from './indexing';
2727

2828

2929
const utils = new Utils();

danfojs/src/plotting/plot.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
import { Utils } from "../core/utils";
22
import { Series } from "../core/series";
3-
import Plotly from 'plotly.js-dist';
4-
5-
63
const utils = new Utils();
74

5+
/**
6+
* Change: Rising Odegua 6th Feb 2021
7+
* We no longer bundle Plotjs with DanfoJs. I noticed that removing this single
8+
* inport reduces the bundle size from 5.7mb to 2.1mb. I know it's still a huge
9+
* bundle, but it's progress!
10+
* If you need to use Plotly, then you can add the Plotly CDN
11+
* to your script before DanfoJs CDN
12+
*/
13+
try {
14+
const version = Plotly.version;
15+
console.info(`Using Plotly version ${version}`);
16+
} catch (error) {
17+
console.info(`Plotly CDN not found. If you need to make Plots, then add the Plotly CDN to your script`);
18+
}
819

920
/**
1021
* Plotting methods and Functions performed on Series and DataFrames

danfojs/tests/core/generic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const tf = require("@tensorflow/tfjs-core");
2+
const tf = require("@tensorflow/tfjs");
33

44
describe("Generic (NDFrame)", function () {
55
describe("NDframe Created from Array", function () {

lib/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/bundle.js.LICENSE.txt

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,3 @@
1-
/*
2-
* @copyright 2016 Sean Connelly (@voidqk), http://syntheti.cc
3-
* @license MIT
4-
* @preserve Project Home: https://github.com/voidqk/polybooljs
5-
*/
6-
7-
/*
8-
object-assign
9-
(c) Sindre Sorhus
10-
@license MIT
11-
*/
12-
13-
/*!
14-
* @overview es6-promise - a tiny implementation of Promises/A+.
15-
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
16-
* @license Licensed under MIT license
17-
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
18-
* @version v4.2.8+1e68dce6
19-
*/
20-
21-
/*!
22-
* Determine if an object is a Buffer
23-
*
24-
* @author Feross Aboukhadijeh <https://feross.org>
25-
* @license MIT
26-
*/
27-
28-
/*!
29-
* The buffer module from node.js, for the browser.
30-
*
31-
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
32-
* @license MIT
33-
*/
34-
35-
/*!
36-
* The buffer module from node.js, for the browser.
37-
*
38-
* @author Feross Aboukhadijeh <https://feross.org>
39-
* @license MIT
40-
*/
41-
42-
/*!
43-
* pad-left <https://github.com/jonschlinkert/pad-left>
44-
*
45-
* Copyright (c) 2014-2015, Jon Schlinkert.
46-
* Licensed under the MIT license.
47-
*/
48-
49-
/*!
50-
* repeat-string <https://github.com/jonschlinkert/repeat-string>
51-
*
52-
* Copyright (c) 2014-2015, Jon Schlinkert.
53-
* Licensed under the MIT License.
54-
*/
55-
56-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
57-
581
/**
592
* @license
603
* Copyright 2017 Google LLC. All Rights Reserved.

lib/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,16 @@
2121
"danfojs/types"
2222
],
2323
"dependencies": {
24-
"@babel/runtime": "^7.12.13",
2524
"@tensorflow/tfjs": "2.8.5",
2625
"mathjs": "7.5.1",
27-
"plotly.js-dist": "^1.58.4",
2826
"table": "^5.4.6",
2927
"xlsx": "^0.16.7"
3028
},
3129
"scripts": {
3230
"test": "yarn run build && karma start --single-run --browsers ChromeHeadless karma.conf.js",
3331
"build": "babel ./danfojs/src -d ./dist --no-comments",
3432
"lint": "eslint ./danfojs/src",
35-
"bundle": "webpack",
33+
"bundle": "webpack --mode production",
3634
"coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
3735
"coverage": "nyc report --reporter=text-lcov | coveralls && nyc report --reporter=lcov",
3836
"patch": "npm version patch"
@@ -62,10 +60,8 @@
6260
"devDependencies": {
6361
"@babel/cli": "^7.10.5",
6462
"@babel/core": "^7.10.5",
65-
"@babel/plugin-transform-modules-umd": "^7.10.4",
6663
"@babel/plugin-transform-runtime": "^7.12.10",
6764
"@babel/preset-env": "^7.10.4",
68-
"@babel/register": "^7.10.1",
6965
"babel-loader": "^8.1.0",
7066
"browserify": "16.5.2",
7167
"chai": "^4.2.0",
@@ -76,16 +72,10 @@
7672
"karma-chai": "^0.1.0",
7773
"karma-chrome-launcher": "^3.1.0",
7874
"karma-mocha": "^2.0.1",
79-
"mocha": "^7.2.0",
80-
"mocha-lcov-reporter": "^1.3.0",
81-
"mocha-loader": "^5.1.2",
82-
"mocha-webpack": "^1.1.0",
75+
"mocha": "^8.3.0",
8376
"nyc": "^15.1.0",
84-
"parcel-bundler": "^1.12.4",
85-
"source-map-loader": "^1.0.0",
86-
"transform-loader": "^0.2.4",
8777
"webpack": "5.21.2",
88-
"webpack-cli": "4.5.0"
78+
"webpack-cli": "^4.5.0"
8979
},
9080
"nyc": {
9181
"reporter": [

0 commit comments

Comments
 (0)