Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Chart.{Type} classes #5868

Merged
merged 1 commit into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions src/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ require('./controllers/controller.polarArea')(Chart);
require('./controllers/controller.radar')(Chart);
require('./controllers/controller.scatter')(Chart);

require('./charts/Chart.Bar')(Chart);
require('./charts/Chart.Bubble')(Chart);
require('./charts/Chart.Doughnut')(Chart);
require('./charts/Chart.Line')(Chart);
require('./charts/Chart.PolarArea')(Chart);
require('./charts/Chart.Radar')(Chart);
require('./charts/Chart.Scatter')(Chart);

// Loading built-in plugins
var plugins = require('./plugins');
for (var k in plugins) {
Expand Down Expand Up @@ -116,8 +108,33 @@ Chart.canvasHelpers = Chart.helpers.canvas;
/**
* Provided for backward compatibility, use Chart.layouts instead.
* @namespace Chart.layoutService
* @deprecated since version 2.8.0
* @deprecated since version 2.7.3
* @todo remove at version 3
* @private
*/
Chart.layoutService = Chart.layouts;

/**
* Provided for backward compatibility, instead we should create a new Chart
* by setting the type in the config (`new Chart(id, {type: '{chart-type}'}`).
* @deprecated since version 2.8.0
* @todo remove at version 3
*/
Chart.helpers.each(
[
'Bar',
'Bubble',
'Doughnut',
'Line',
'PolarArea',
'Radar',
'Scatter'
],
function(klass) {
Chart[klass] = function(ctx, cfg) {
return new Chart(ctx, Chart.helpers.merge(cfg || {}, {
type: klass.charAt(0).toLowerCase() + klass.slice(1)
}));
};
}
);
11 changes: 0 additions & 11 deletions src/charts/Chart.Bar.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/charts/Chart.Bubble.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/charts/Chart.Doughnut.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/charts/Chart.Line.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/charts/Chart.PolarArea.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/charts/Chart.Radar.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/charts/Chart.Scatter.js

This file was deleted.

27 changes: 27 additions & 0 deletions test/specs/global.deprecations.tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
describe('Deprecations', function() {
describe('Version 2.8.0', function() {
[
['Bar', 'bar'],
['Bubble', 'bubble'],
['Doughnut', 'doughnut'],
['Line', 'line'],
['PolarArea', 'polarArea'],
['Radar', 'radar'],
['Scatter', 'scatter']
].forEach(function(descriptor) {
var klass = descriptor[0];
var type = descriptor[1];

describe('Chart.' + klass, function() {
it('should be defined as a function', function() {
expect(Chart[klass]).toBeDefined();
expect(typeof Chart[klass]).toBe('function');
});
it('should create a chart of type "' + type + '"', function() {
var chart = new Chart[klass]('foo', {data: {}});
expect(chart instanceof Chart.Controller).toBeTruthy();
expect(chart.config.type).toBe(type);
});
});
});
});

describe('Version 2.7.3', function() {
describe('Chart.layoutService', function() {
it('should be defined and an alias of Chart.layouts', function() {
expect(Chart.layoutService).toBeDefined();
Expand Down