Skip to content

Commit 62c9d65

Browse files
committed
Fixing minimum version for plotly.js
1 parent f16f06b commit 62c9d65

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ import { CommonModule } from '@angular/common';
182182
import { PlotlyViaCDNModule } from 'angular-plotly.js';
183183

184184

185-
PlotlyViaCDNModule.plotlyVersion = '1.5.0'; // can be `latest` or any version number (i.e.: '1.4.3')
185+
PlotlyViaCDNModule.plotlyVersion = '1.49.4'; // can be `latest` or any version number (i.e.: '1.40.0')
186186
PlotlyViaCDNModule.plotlyBundle = 'basic'; // optional: can be null (for full) or 'basic', 'cartesian', 'geo', 'gl3d', 'gl2d', 'mapbox' or 'finance'
187187

188188
@NgModule({

src/app/shared/plotly.service.spec.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('PlotlyService', () => {
2323
}));
2424

2525
it('should check the plotly dependency', inject([PlotlyService], (service: PlotlyService) => {
26-
PlotlyService.setPlotly(undefined);
26+
(PlotlyService as any)._plotly = undefined;
2727
expect(() => service.getPlotly()).toThrowError(`Peer dependency plotly.js isn't installed`);
2828
PlotlyService.setPlotly(PlotlyJS);
2929
}));
@@ -82,4 +82,9 @@ describe('PlotlyService', () => {
8282
service.resize('one' as any);
8383
expect(plotly.Plots.resize).toHaveBeenCalledWith('one');
8484
}));
85+
86+
87+
it('should fail if is using an unsupported version of plotly.js', inject([PlotlyService], () => {
88+
expect(() => PlotlyService.setPlotly({})).toThrowError(`Invalid plotly.js version. Please, use any version above 1.40.0`);
89+
}));
8590
});

src/app/shared/plotly.service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export class PlotlyService {
1717
}
1818

1919
public static setPlotly(plotly: any) {
20+
if (typeof plotly === 'object' && typeof plotly.react !== 'function') {
21+
throw new Error('Invalid plotly.js version. Please, use any version above 1.40.0');
22+
}
23+
2024
PlotlyService._plotly = plotly;
2125
}
2226

0 commit comments

Comments
 (0)