Skip to content

Commit

Permalink
Fixing minimum version for plotly.js
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefarzat committed Aug 31, 2019
1 parent f16f06b commit 62c9d65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ import { CommonModule } from '@angular/common';
import { PlotlyViaCDNModule } from 'angular-plotly.js';


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

@NgModule({
Expand Down
7 changes: 6 additions & 1 deletion src/app/shared/plotly.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('PlotlyService', () => {
}));

it('should check the plotly dependency', inject([PlotlyService], (service: PlotlyService) => {
PlotlyService.setPlotly(undefined);
(PlotlyService as any)._plotly = undefined;
expect(() => service.getPlotly()).toThrowError(`Peer dependency plotly.js isn't installed`);
PlotlyService.setPlotly(PlotlyJS);
}));
Expand Down Expand Up @@ -82,4 +82,9 @@ describe('PlotlyService', () => {
service.resize('one' as any);
expect(plotly.Plots.resize).toHaveBeenCalledWith('one');
}));


it('should fail if is using an unsupported version of plotly.js', inject([PlotlyService], () => {
expect(() => PlotlyService.setPlotly({})).toThrowError(`Invalid plotly.js version. Please, use any version above 1.40.0`);
}));
});
4 changes: 4 additions & 0 deletions src/app/shared/plotly.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export class PlotlyService {
}

public static setPlotly(plotly: any) {
if (typeof plotly === 'object' && typeof plotly.react !== 'function') {
throw new Error('Invalid plotly.js version. Please, use any version above 1.40.0');
}

PlotlyService._plotly = plotly;
}

Expand Down

0 comments on commit 62c9d65

Please sign in to comment.