Skip to content

Commit c07f100

Browse files
committed
Merge branch 'danfo/typescript' of https://github.com/opensource9ja/danfojs into danfo/typescript
2 parents 6c1d90a + 5acef6a commit c07f100

10 files changed

Lines changed: 288 additions & 188 deletions

File tree

src/danfojs-base/core/frame.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import NDframe from "./generic";
2525
import { table } from "table";
2626
import Series from './series';
2727
import Groupby from '../aggregators/groupby'
28+
import { Plotly } from "../plotting";
29+
2830
const utils = new Utils();
2931

3032
/**
@@ -2441,8 +2443,21 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
24412443
this.values as ArrayType2D,
24422444
columns,
24432445
colDtype,
2444-
colIndex
2446+
colIndex
24452447
).group()
2446-
2448+
2449+
}
2450+
2451+
/**
2452+
* Make plots of Series or DataFrame.
2453+
* Uses the Plotly as backend, so supports Plotly's configuration parameters
2454+
* @param divId Name of the div to show the plot
2455+
* @returns Plotly class that expoese different plot type
2456+
*/
2457+
plot(divId: string) {
2458+
//TODO: Add support for check plot library to use
2459+
// So we can support other plot library like d3, vega, etc
2460+
const plt = new Plotly(this, divId);
2461+
return plt;
24472462
}
24482463
}

src/danfojs-base/core/series.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Dt from './datetime';
2626
import dummyEncode from "../transformers/encoders/dummy.encoder";
2727
import DataFrame from "./frame";
2828
import tensorflow from '../shared/tensorflowlib'
29-
import Plot from "../plotting/plotly";
29+
import { Plotly } from "../plotting";
3030

3131
const utils = new Utils();
3232

@@ -1368,7 +1368,9 @@ export default class Series extends NDframe implements SeriesInterface {
13681368
* @returns Plotly class that expoese different plot type
13691369
*/
13701370
plot(divId: string) {
1371-
const plt = new Plot(this, divId);
1371+
//TODO: Add support for check plot library to use
1372+
// So we can support other plot library like d3, vega, etc
1373+
const plt = new Plotly(this, divId);
13721374
return plt;
13731375
}
13741376
}

src/danfojs-base/plotting/index.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @license
3+
* Copyright 2021, JsData. All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
* ==========================================================================
14+
*/
15+
import { linePlot } from "./plotly/index";
16+
import Series from "../core/series";
17+
import DataFrame from "../core/frame";
18+
import { PlotConfigObject } from "../shared/types";
19+
20+
class Plotly {
21+
divId: string;
22+
ndframe: DataFrame | Series;
23+
24+
constructor(ndframe: DataFrame | Series, divId: string) {
25+
this.ndframe = ndframe;
26+
this.divId = divId;
27+
}
28+
29+
/**
30+
* Plot Series or DataFrame as lines.
31+
* Uses the Plotly as backend, so supoorts Plotly's configuration parameters
32+
* @param plotConfig configuration options for making Plots, supports Plotly.js parameters.
33+
*/
34+
line(plotConfig: PlotConfigObject) {
35+
linePlot(this.ndframe, this.divId, plotConfig);
36+
}
37+
38+
39+
}
40+
41+
export {
42+
Plotly
43+
}

src/danfojs-base/plotting/plotly.ts

Lines changed: 0 additions & 179 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @license
3+
* Copyright 2021, JsData. All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
* ==========================================================================
14+
*/
15+
16+
export { linePlot } from "./line";

0 commit comments

Comments
 (0)