From fa6c0efef53e1b86fdbe65205c179d8fb2c8431a Mon Sep 17 00:00:00 2001 From: Luis Stanley Jovel Date: Tue, 9 Oct 2018 12:38:55 -0600 Subject: [PATCH] Plotly.js add missing properties (#29428) * Add definitions for removeAllListeners funtion as detailed https://github.com/plotly/plotly.js/issues/107#issuecomment-279716312 * adding automargin property as per the documentation: https://plot.ly/javascript/reference/#layout-xaxis-automargin * making the colorbar property optional * Fix lint warnings * updating tests * create ColorBar interface --- types/plotly.js/index.d.ts | 98 +++++++++++++++-------------- types/plotly.js/test/index-tests.ts | 3 +- 2 files changed, 53 insertions(+), 48 deletions(-) diff --git a/types/plotly.js/index.d.ts b/types/plotly.js/index.d.ts index 93c6a95271..121001b49b 100644 --- a/types/plotly.js/index.d.ts +++ b/types/plotly.js/index.d.ts @@ -166,6 +166,7 @@ export interface PlotlyHTMLElement extends HTMLElement { on(event: 'plotly_afterexport' | 'plotly_afterplot' | 'plotly_animated' | 'plotly_animationinterrupted' | 'plotly_autosize' | 'plotly_beforeexport' | 'plotly_deselect' | 'plotly_doubleclick' | 'plotly_framework' | 'plotly_redraw' | 'plotly_transitioning' | 'plotly_transitioninterrupted', callback: () => void): void; + removeAllListeners: (handler: string) => void; } export interface ToImgopts { @@ -350,6 +351,7 @@ export interface LayoutAxis extends Axis { position: number; rangeslider: Partial; rangeselector: Partial; + automargin: boolean; } export interface SceneAxis extends Axis { @@ -560,6 +562,54 @@ export interface Transform { value: any; order: 'ascending' | 'descending'; } + +export interface ColorBar { + thicknessmode: 'fraction' | 'pixels'; + thickness: number; + lenmode: 'fraction' | 'pixels'; + len: number; + x: number; + xanchor: 'left' | 'center' | 'right'; + xpad: number; + y: number; + yanchor: 'top' | 'middle' | 'bottom'; + ypad: number; + outlinecolor: Color; + outlinewidth: number; + bordercolor: Color; + borderwidth: Color; + bgcolor: Color; + tickmode: 'auto' | 'linear' | 'array'; + nticks: number; + tick0: number | string; + dtick: number | string; + tickvals: Datum[] | Datum[][] | Datum[][][] | TypedArray; + ticktext: Datum[] | Datum[][] | Datum[][][] | TypedArray; + ticks: 'outside' | 'inside' | ''; + ticklen: number; + tickwidth: number; + tickcolor: Color; + showticklabels: boolean; + tickfont: Font; + tickangle: number; + tickformat: string; + tickformatstops: { + dtickrange: any[]; + value: string; + }; + tickprefix: string; + showtickprefix: 'all' | 'first' | 'last' | 'none'; + ticksuffix: string; + showticksuffix: 'all' | 'first' | 'last' | 'none'; + separatethousands: boolean; + exponentformat: 'none' | 'e' | 'E' | 'power' | 'SI' | 'B'; + showexponent: 'all' | 'first' | 'last' | 'none'; + title: string; + titlefont: Font; + titleside: 'right' | 'top' | 'bottom'; + tickvalssrc: any; + ticktextsrc: any; +} /** * Any combination of "x", "y", "z", "text", "name" joined with a "+" OR "all" or "none" or "skip". * examples: "x", "y", "x+y", "x+y+z", "all" @@ -584,53 +634,7 @@ export interface PlotMarker { showscale: boolean; line: Partial; width: number; - colorbar: { - thicknessmode: 'fraction' | 'pixels', - thickness: number, - lenmode: 'fraction' | 'pixels', - len: number, - x: number, - xanchor: 'left' | 'center' | 'right', - xpad: number, - y: number, - yanchor: 'top' | 'middle' | 'bottom', - ypad: number, - outlinecolor: Color, - outlinewidth: number, - bordercolor: Color, - borderwidth: Color, - bgcolor: Color, - tickmode: 'auto' | 'linear' | 'array', - nticks: number, - tick0: number | string, - dtick: number | string, - tickvals: Datum[] | Datum[][] | Datum[][][] | TypedArray, - ticktext: Datum[] | Datum[][] | Datum[][][] | TypedArray, - ticks: 'outside' | 'inside' | '', - ticklen: number, - tickwidth: number, - tickcolor: Color, - showticklabels: boolean, - tickfont: Font, - tickangle: number, - tickformat: string, - tickformatstops: { - dtickrange: any[], - value: string, - }, - tickprefix: string, - showtickprefix: 'all' | 'first' | 'last' | 'none', - ticksuffix: string, - showticksuffix: 'all' | 'first' | 'last' | 'none', - separatethousands: boolean, - exponentformat: 'none' | 'e' | 'E' | 'power' | 'SI' | 'B', - showexponent: 'all' | 'first' | 'last' | 'none', - title: string, - titlefont: Font, - titleside: 'right' | 'top' | 'bottom', - tickvalssrc: any, - ticktextsrc: any, - }; + colorbar: Partial; gradient: { type: 'radial' | 'horizontal' | 'vertical' | 'none', color: Color, diff --git a/types/plotly.js/test/index-tests.ts b/types/plotly.js/test/index-tests.ts index 89786a5375..79343f43f7 100644 --- a/types/plotly.js/test/index-tests.ts +++ b/types/plotly.js/test/index-tests.ts @@ -546,5 +546,6 @@ function rand() { myPlot.on('plotly_transitioninterrupted', () => { console.log('transition interrupted'); }); + + myPlot.removeAllListeners('plotly_restyle'); })(); -//////////////////////////////////////////////////////////////////////