MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / PlotlyLib

Class PlotlyLib

src/danfojs-base/plotting/index.ts:36–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36class PlotlyLib implements IPlotlyLib {
37 divId: string;
38 ndframe: DataFrame | Series;
39
40 constructor(ndframe: DataFrame | Series, divId: string) {
41 this.ndframe = ndframe;
42 this.divId = divId;
43 }
44
45 private getPlotConfig(plotConfig?: PlotConfigObject) {
46 const _plotConfig = {
47 config: plotConfig && plotConfig.config ? plotConfig.config : {},
48 layout: plotConfig && plotConfig.layout ? plotConfig.layout : {}
49 };
50 return _plotConfig;
51 }
52 /**
53 * Plot Series or DataFrame as lines.
54 * Uses Plotly library as backend, so supports Plotly's configuration parameters
55 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
56 */
57 line(plotConfig?: PlotConfigObject) {
58 const _plotConfig = this.getPlotConfig(plotConfig);
59 linePlot(this.ndframe, this.divId, _plotConfig, Plotly);
60 }
61
62 /**
63 * Plot Series or DataFrame as bars.
64 * Uses Plotly library as backend, so supports Plotly's configuration parameters
65 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
66 */
67 bar(plotConfig?: PlotConfigObject) {
68 const _plotConfig = this.getPlotConfig(plotConfig);
69 barPlot(this.ndframe, this.divId, _plotConfig, Plotly);
70 }
71
72 /**
73 * Plot Series or DataFrame as scatter.
74 * Uses Plotly library as backend, so supports Plotly's configuration parameters
75 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
76 */
77 scatter(plotConfig?: PlotConfigObject) {
78 const _plotConfig = this.getPlotConfig(plotConfig);
79 scatterPlot(this.ndframe, this.divId, _plotConfig, Plotly);
80 }
81
82 /**
83 * Plot Series or DataFrame as histogram.
84 * Uses Plotly library as backend, so supports Plotly's configuration parameters
85 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
86 */
87 hist(plotConfig?: PlotConfigObject) {
88 const _plotConfig = this.getPlotConfig(plotConfig);
89 histPlot(this.ndframe, this.divId, _plotConfig, Plotly);
90 }
91
92 /**
93 * Plot Series or DataFrame as pie.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected