@@ -43,16 +43,20 @@ class PlotlyLib implements IPlotlyLib {
4343 this . divId = divId ;
4444 }
4545
46+ private getPlotConfig ( plotConfig ?: PlotConfigObject ) {
47+ const _plotConfig = {
48+ config : plotConfig && plotConfig . config ? plotConfig . config : { } ,
49+ layout : plotConfig && plotConfig . layout ? plotConfig . layout : { }
50+ } ;
51+ return _plotConfig ;
52+ }
4653 /**
4754 * Plot Series or DataFrame as lines.
4855 * Uses Plotly library as backend, so supports Plotly's configuration parameters
4956 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
5057 */
5158 line ( plotConfig ?: PlotConfigObject ) {
52- const _plotConfig = plotConfig || {
53- config : { } ,
54- layout : { }
55- } ;
59+ const _plotConfig = this . getPlotConfig ( plotConfig ) ;
5660 linePlot ( this . ndframe , this . divId , _plotConfig , Plotly ) ;
5761 }
5862
@@ -62,10 +66,7 @@ class PlotlyLib implements IPlotlyLib {
6266 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
6367 */
6468 bar ( plotConfig ?: PlotConfigObject ) {
65- const _plotConfig = plotConfig || {
66- config : { } ,
67- layout : { }
68- } ;
69+ const _plotConfig = this . getPlotConfig ( plotConfig ) ;
6970 barPlot ( this . ndframe , this . divId , _plotConfig , Plotly ) ;
7071 }
7172
@@ -75,10 +76,7 @@ class PlotlyLib implements IPlotlyLib {
7576 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
7677 */
7778 scatter ( plotConfig ?: PlotConfigObject ) {
78- const _plotConfig = plotConfig || {
79- config : { } ,
80- layout : { }
81- } ;
79+ const _plotConfig = this . getPlotConfig ( plotConfig ) ;
8280 scatterPlot ( this . ndframe , this . divId , _plotConfig , Plotly ) ;
8381 }
8482
@@ -88,10 +86,7 @@ class PlotlyLib implements IPlotlyLib {
8886 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
8987 */
9088 hist ( plotConfig ?: PlotConfigObject ) {
91- const _plotConfig = plotConfig || {
92- config : { } ,
93- layout : { }
94- } ;
89+ const _plotConfig = this . getPlotConfig ( plotConfig ) ;
9590 histPlot ( this . ndframe , this . divId , _plotConfig , Plotly ) ;
9691 }
9792
@@ -101,10 +96,7 @@ class PlotlyLib implements IPlotlyLib {
10196 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
10297 */
10398 pie ( plotConfig ?: PlotConfigObject ) {
104- const _plotConfig = plotConfig || {
105- config : { } ,
106- layout : { }
107- } ;
99+ const _plotConfig = this . getPlotConfig ( plotConfig ) ;
108100 piePlot ( this . ndframe , this . divId , _plotConfig , Plotly ) ;
109101 }
110102
@@ -114,10 +106,7 @@ class PlotlyLib implements IPlotlyLib {
114106 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
115107 */
116108 box ( plotConfig ?: PlotConfigObject ) {
117- const _plotConfig = plotConfig || {
118- config : { } ,
119- layout : { }
120- } ;
109+ const _plotConfig = this . getPlotConfig ( plotConfig ) ;
121110 boxPlot ( this . ndframe , this . divId , _plotConfig , Plotly ) ;
122111 }
123112
@@ -127,10 +116,7 @@ class PlotlyLib implements IPlotlyLib {
127116 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
128117 */
129118 violin ( plotConfig ?: PlotConfigObject ) {
130- const _plotConfig = plotConfig || {
131- config : { } ,
132- layout : { }
133- } ;
119+ const _plotConfig = this . getPlotConfig ( plotConfig ) ;
134120 violinPlot ( this . ndframe , this . divId , _plotConfig , Plotly ) ;
135121 }
136122
@@ -140,18 +126,12 @@ class PlotlyLib implements IPlotlyLib {
140126 * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
141127 */
142128 table ( plotConfig ?: PlotConfigObject ) {
143- const _plotConfig = plotConfig || {
144- config : { } ,
145- layout : { }
146- } ;
129+ const _plotConfig = this . getPlotConfig ( plotConfig ) ;
147130 tablePlot ( this . ndframe , this . divId , _plotConfig , Plotly ) ;
148131 }
149132
150133}
151134
152- // class Vega {
153- // //TODO: Add support for vega library
154- // }
155135
156136export {
157137 PlotlyLib
0 commit comments