]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove classic style extensions from docs/tests (#8076)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Thu, 19 Nov 2020 12:55:20 +0000 (14:55 +0200)
committerGitHub <noreply@github.com>
Thu, 19 Nov 2020 12:55:20 +0000 (07:55 -0500)
docs/docs/developers/axes.md
docs/docs/developers/charts.md
test/specs/core.registry.tests.js

index e28f937c85d3edc4e5991d968e43b57f301ad796..8a60ecb1052203ed6a5283eebfdfd8103dfcc1a0 100644 (file)
@@ -11,23 +11,6 @@ class MyScale extends Chart.Scale {
 MyScale.id = 'myScale';
 MyScale.defaults = defaultConfigObject;
 
-// Or in classic style
-/*
-function MyScale() {
-  Chart.Scale.call(this, arguments);
-  // constructor stuff
-}
-MyScale.prototype = Object.create(Chart.Scale.prototype);
-MyScale.prototype.constructor = MyScale;
-
-MyScale.prototype.draw = function(ctx) {
-  Chart.Scale.prototype.draw.call(this, arguments);
-  // ...
-}
-MyScale.id = 'myScale';
-MyScale.defaults = defaultConfigObject;
-*/
-
 // MyScale is now derived from Chart.Scale
 ```
 
index f4887480f383417892d6cf6f20bb5b0d389a3c3c..652cd41f5a0c09dc1413aa6942dd3d91b386697a 100644 (file)
@@ -113,44 +113,6 @@ new Chart(ctx, {
 });
 ```
 
-Same example in classic style
-
-```javascript
-function Custom() {
-  Chart.BubbleController.apply(this, arguments);
-  // constructor stuff
-}
-Custom.prototype = Object.create(Chart.BubbleController.prototype);
-Custom.prototype.constructor = Custom;
-
-Custom.prototype.draw = function(ctx) {
-    Chart.BubbleController.prototype.draw.apply(this, arguments);
-
-    var meta = this.getMeta();
-    var pt0 = meta.data[0];
-    var radius = pt0.radius;
-
-    var ctx = this.chart.chart.ctx;
-    ctx.save();
-    ctx.strokeStyle = 'red';
-    ctx.lineWidth = 1;
-    ctx.strokeRect(pt0.x - radius, pt0.y - radius, 2 * radius, 2 * radius);
-    ctx.restore();}
-}
-
-Custom.id = 'derivedBubble';
-Custom.defaults = Chart.defaults.bubble;
-
-Chart.register(Custom);
-
-// Now we can create and use our new chart type
-new Chart(ctx, {
-    type: 'derivedBubble',
-    data: data,
-    options: options
-});
-```
-
 ## TypeScript Typings
 
 If you want your new chart type to be statically typed, you must provide a `.d.ts` TypeScript declaration file. Chart.js provides a way to augment built-in types with user-defined ones, by using the concept of "declaration merging".
index e93207dc04e5edcf630ad3a6a2aa9c71923a3d29..05540390e38310679f2f24eee87cf883f6073973 100644 (file)
@@ -1,90 +1,4 @@
 describe('Chart.registry', function() {
-       it('should handle a classic controller extension', function() {
-               function CustomController() {
-                       Chart.controllers.line.apply(this, arguments);
-               }
-               CustomController.prototype = Object.create(Chart.controllers.line.prototype);
-               CustomController.prototype.constructor = CustomController;
-               CustomController.id = 'myline';
-               CustomController.defaults = Chart.defaults.controllers.line;
-
-               Chart.register(CustomController);
-
-               expect(Chart.registry.getController('myline')).toEqual(CustomController);
-               expect(Chart.defaults.controllers.myline).toEqual(CustomController.defaults);
-
-               Chart.unregister(CustomController);
-       });
-
-       it('should handle a classic scale extension', function() {
-               function CustomScale() {
-                       Chart.Scale.apply(this, arguments);
-               }
-               CustomScale.prototype = Object.create(Chart.Scale.prototype);
-               CustomScale.prototype.constructor = CustomScale;
-               CustomScale.id = 'myScale';
-               CustomScale.defaults = {
-                       foo: 'bar'
-               };
-
-               Chart.register(CustomScale);
-
-               expect(Chart.registry.getScale('myScale')).toEqual(CustomScale);
-               expect(Chart.defaults.scales.myScale).toEqual(CustomScale.defaults);
-
-               Chart.unregister(CustomScale);
-
-               expect(function() {
-                       Chart.registry.getScale('myScale');
-               }).toThrow(new Error('"myScale" is not a registered scale.'));
-               expect(Chart.defaults.scales.myScale).not.toBeDefined();
-       });
-
-       it('should handle a classic element extension', function() {
-               function CustomElement() {
-                       Chart.Element.apply(this, arguments);
-               }
-               CustomElement.prototype = Object.create(Chart.Element.prototype);
-               CustomElement.prototype.constructor = CustomElement;
-               CustomElement.id = 'myElement';
-               CustomElement.defaults = {
-                       foo: 'baz'
-               };
-
-               Chart.register(CustomElement);
-
-               expect(Chart.registry.getElement('myElement')).toEqual(CustomElement);
-               expect(Chart.defaults.elements.myElement).toEqual(CustomElement.defaults);
-
-               Chart.unregister(CustomElement);
-
-               expect(function() {
-                       Chart.registry.getElement('myElement');
-               }).toThrow(new Error('"myElement" is not a registered element.'));
-               expect(Chart.defaults.elements.myElement).not.toBeDefined();
-       });
-
-       it('should handle a classic plugin', function() {
-               const CustomPlugin = {
-                       id: 'customPlugin',
-                       defaults: {
-                               custom: 'plugin'
-                       }
-               };
-
-               Chart.register(CustomPlugin);
-
-               expect(Chart.registry.getPlugin('customPlugin')).toEqual(CustomPlugin);
-               expect(Chart.defaults.plugins.customPlugin).toEqual(CustomPlugin.defaults);
-
-               Chart.unregister(CustomPlugin);
-
-               expect(function() {
-                       Chart.registry.getPlugin('customPlugin');
-               }).toThrow(new Error('"customPlugin" is not a registered plugin.'));
-               expect(Chart.defaults.plugins.customPlugin).not.toBeDefined();
-       });
-
        it('should handle an ES6 controller extension', function() {
                class CustomController extends Chart.DatasetController {}
                CustomController.id = 'custom';