diff --git a/CHANGELOG.md b/CHANGELOG.md index 18e11a2..9e45503 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Changelog +## [5.1.1] - 2023-06-15 +### Changed +- Adding support to strict version of bundle plotly (see https://github.com/plotly/angular-plotly.js/issues/237) + +## [5.1.0] - 2023-04-10 +### Changed +- Updated to Angular 15 + ## [5.0.0] - 2023-03-29 ### Changed - Updated to Angular 13 diff --git a/projects/plotly/src/lib/plotly-via-cdn.module.spec.ts b/projects/plotly/src/lib/plotly-via-cdn.module.spec.ts index 4060384..3e00ec1 100644 --- a/projects/plotly/src/lib/plotly-via-cdn.module.spec.ts +++ b/projects/plotly/src/lib/plotly-via-cdn.module.spec.ts @@ -45,12 +45,31 @@ describe('PlotlyViaCDNModule', () => { }); it('should NOT set Plotly version', () => { - const version = "invalid"; + const errorMsg= "Invalid plotly version. Please set 'latest' or version number (i.e.: 1.4.3) or strict version number (i.e.: strict-1.4.3)"; spyOn(PlotlyViaCDNModule, "loadViaCDN").and.callThrough(); - expect(() => { - PlotlyViaCDNModule.setPlotlyVersion(version); - }).toThrowError("Invalid plotly version. Please set 'latest' or version number (i.e.: 1.4.3)"); + let version = "invalid"; + expect(() => { PlotlyViaCDNModule.setPlotlyVersion(version); }).toThrowError(errorMsg); + + version = "strict-1"; + expect(() => { PlotlyViaCDNModule.setPlotlyVersion(version); }).toThrowError(errorMsg); + + version = "1"; + expect(() => { PlotlyViaCDNModule.setPlotlyVersion(version); }).toThrowError(errorMsg); + + version = "strict-1.1.a"; + expect(() => { PlotlyViaCDNModule.setPlotlyVersion(version); }).toThrowError(errorMsg); + + version = "strit-1.1.1"; + expect(() => { PlotlyViaCDNModule.setPlotlyVersion(version); }).toThrowError(errorMsg); + }); + + it('should allow Plotly version with strict- at the beginning', () => { + const version = "strict-2.24.1"; + spyOn(PlotlyViaCDNModule, "loadViaCDN"); + + PlotlyViaCDNModule.setPlotlyVersion(version); + expect((PlotlyViaCDNModule as any).plotlyVersion).toBe(version); }); }); }); diff --git a/projects/plotly/src/lib/plotly-via-cdn.module.ts b/projects/plotly/src/lib/plotly-via-cdn.module.ts index 6e8980c..9bfe801 100644 --- a/projects/plotly/src/lib/plotly-via-cdn.module.ts +++ b/projects/plotly/src/lib/plotly-via-cdn.module.ts @@ -24,9 +24,9 @@ export class PlotlyViaCDNModule { } public static setPlotlyVersion(version: string): void { - const isOk = version === 'latest' || /^\d\.\d{1,2}\.\d{1,2}$/.test(version); + const isOk = version === 'latest' || /^(strict-)?\d\.\d{1,2}\.\d{1,2}$/.test(version); if (!isOk) { - throw new Error(`Invalid plotly version. Please set 'latest' or version number (i.e.: 1.4.3)`); + throw new Error(`Invalid plotly version. Please set 'latest' or version number (i.e.: 1.4.3) or strict version number (i.e.: strict-1.4.3)`); } PlotlyViaCDNModule.loadViaCDN(); diff --git a/projects/plotly/src/lib/plotly.component.ts b/projects/plotly/src/lib/plotly.component.ts index 41a92ac..6fb6fda 100644 --- a/projects/plotly/src/lib/plotly.component.ts +++ b/projects/plotly/src/lib/plotly.component.ts @@ -69,6 +69,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck { @Output() animationInterrupted = new EventEmitter(); @Output() autoSize = new EventEmitter(); @Output() beforeExport = new EventEmitter(); + @Output() beforeHover = new EventEmitter(); @Output() buttonClicked = new EventEmitter(); /** * @deprecated DEPRECATED: Reconsider using `(plotlyClick)` instead of `(click)` to avoid event conflict. Please check https://github.com/plotly/angular-plotly.js#FAQ @@ -83,8 +84,12 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck { @Output() hover = new EventEmitter(); @Output() legendClick = new EventEmitter(); @Output() legendDoubleClick = new EventEmitter(); + /** + * @deprecated DEPRECATED: Event react is not list as an plotly.js event + */ @Output() react = new EventEmitter(); @Output() relayout = new EventEmitter(); + @Output() relayouting = new EventEmitter(); @Output() restyle = new EventEmitter(); @Output() redraw = new EventEmitter(); @Output() selected = new EventEmitter(); @@ -92,18 +97,21 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck { @Output() sliderChange = new EventEmitter(); @Output() sliderEnd = new EventEmitter(); @Output() sliderStart = new EventEmitter(); + @Output() sunburstclick = new EventEmitter(); @Output() transitioning = new EventEmitter(); @Output() transitionInterrupted = new EventEmitter(); @Output() unhover = new EventEmitter(); - @Output() relayouting = new EventEmitter(); + /** + * @deprecated DEPRECATED: Event treemapclick is not list as an plotly.js event + */ @Output() treemapclick = new EventEmitter(); - @Output() sunburstclick = new EventEmitter(); + @Output() webglcontextlost = new EventEmitter(); + public eventNames = ['afterExport', 'afterPlot', 'animated', 'animatingFrame', 'animationInterrupted', 'autoSize', - 'beforeExport', 'buttonClicked', 'clickAnnotation', 'deselect', 'doubleClick', 'framework', 'hover', - 'legendClick', 'legendDoubleClick', 'react', 'relayout', 'restyle', 'redraw', 'selected', 'selecting', 'sliderChange', - 'sliderEnd', 'sliderStart', 'transitioning', 'transitionInterrupted', 'unhover', 'relayouting', 'treemapclick', - 'sunburstclick']; + 'beforeExport', 'beforeHover', 'buttonClicked', 'clickAnnotation', 'deselect', 'doubleClick', 'framework', 'hover', + 'legendClick', 'legendDoubleClick', 'react', 'relayout', 'relayouting', 'restyle', 'redraw', 'selected', 'selecting', 'sliderChange', + 'sliderEnd', 'sliderStart', 'sunburstclick', 'transitioning', 'transitionInterrupted', 'unhover', 'treemapclick', 'webglcontextlost']; constructor( public plotly: PlotlyService,