Skip to content
Closed
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
4 changes: 2 additions & 2 deletions docs/developers/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ var chart = new Chart(ctx, {
});
```

## Plugin Core API
## Plugin Core API

Read more about the [existing plugin extension hooks](../jsdoc/IPlugin.html).
Read more about the [existing plugin extension hooks](../typedoc/interfaces/iplugin.html).
9 changes: 2 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,8 @@ function docsTask(done) {
return run(bin, ['install', './'])
.then(() => run(bin, [cmd, './', './dist/docs']))
.then(() => {
const config = {
moduleResolution: 'Node',
target: 'ES6',
out: './dist/docs/typedoc'
};
gulp.src(['./src/**/*.js'], {read: false})
.pipe(typedoc(config, done));
gulp.src(['./src/**/*.js', './types/**/*.d.ts'], {read: false})
.pipe(typedoc(tsProject.config.typedocOptions, done));
}).catch((err) => {
done(new Error(err.stdout || err));
});
Expand Down
212 changes: 2 additions & 210 deletions src/core/core.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {clone} from '../helpers/helpers.core';
* @typedef { import("./core.controller").default } Chart
* @typedef { import("../platform/platform.base").IEvent } IEvent
* @typedef { import("../plugins/plugin.tooltip").default } Tooltip
* IPlugin interface defined for documentation in /types/IPlugin.d.ts
* @typedef {object} IPlugin
*/

defaults.set('plugins', {});
Expand Down Expand Up @@ -177,213 +179,3 @@ export class PluginService {

// singleton instance
export default new PluginService();

/**
* Plugin extension hooks.
* @interface IPlugin
* @typedef {object} IPlugin
* @since 2.1.0
*/
/**
* @method IPlugin#beforeInit
* @desc Called before initializing `chart`.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#afterInit
* @desc Called after `chart` has been initialized and before the first update.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#beforeUpdate
* @desc Called before updating `chart`. If any plugin returns `false`, the update
* is cancelled (and thus subsequent render(s)) until another `update` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart update.
*/
/**
* @method IPlugin#afterUpdate
* @desc Called after `chart` has been updated and before rendering. Note that this
* hook will not be called if the chart update has been previously cancelled.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#reset
* @desc Called during chart reset
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @since version 3.0.0
*/
/**
* @method IPlugin#beforeDatasetsUpdate
* @desc Called before updating the `chart` datasets. If any plugin returns `false`,
* the datasets update is cancelled until another `update` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @returns {boolean} false to cancel the datasets update.
* @since version 2.1.5
*/
/**
* @method IPlugin#afterDatasetsUpdate
* @desc Called after the `chart` datasets have been updated. Note that this hook
* will not be called if the datasets update has been previously cancelled.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @since version 2.1.5
*/
/**
* @method IPlugin#beforeDatasetUpdate
* @desc Called before updating the `chart` dataset at the given `args.index`. If any plugin
* returns `false`, the datasets update is cancelled until another `update` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {number} args.index - The dataset index.
* @param {object} args.meta - The dataset metadata.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart datasets drawing.
*/
/**
* @method IPlugin#afterDatasetUpdate
* @desc Called after the `chart` datasets at the given `args.index` has been updated. Note
* that this hook will not be called if the datasets update has been previously cancelled.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {number} args.index - The dataset index.
* @param {object} args.meta - The dataset metadata.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#beforeLayout
* @desc Called before laying out `chart`. If any plugin returns `false`,
* the layout update is cancelled until another `update` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart layout.
*/
/**
* @method IPlugin#afterLayout
* @desc Called after the `chart` has been layed out. Note that this hook will not
* be called if the layout update has been previously cancelled.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#beforeRender
* @desc Called before rendering `chart`. If any plugin returns `false`,
* the rendering is cancelled until another `render` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart rendering.
*/
/**
* @method IPlugin#afterRender
* @desc Called after the `chart` has been fully rendered (and animation completed). Note
* that this hook will not be called if the rendering has been previously cancelled.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#beforeDraw
* @desc Called before drawing `chart` at every animation frame. If any plugin returns `false`,
* the frame drawing is cancelled untilanother `render` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart drawing.
*/
/**
* @method IPlugin#afterDraw
* @desc Called after the `chart` has been drawn. Note that this hook will not be called
* if the drawing has been previously cancelled.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#beforeDatasetsDraw
* @desc Called before drawing the `chart` datasets. If any plugin returns `false`,
* the datasets drawing is cancelled until another `render` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart datasets drawing.
*/
/**
* @method IPlugin#afterDatasetsDraw
* @desc Called after the `chart` datasets have been drawn. Note that this hook
* will not be called if the datasets drawing has been previously cancelled.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#beforeDatasetDraw
* @desc Called before drawing the `chart` dataset at the given `args.index` (datasets
* are drawn in the reverse order). If any plugin returns `false`, the datasets drawing
* is cancelled until another `render` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {number} args.index - The dataset index.
* @param {object} args.meta - The dataset metadata.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart datasets drawing.
*/
/**
* @method IPlugin#afterDatasetDraw
* @desc Called after the `chart` datasets at the given `args.index` have been drawn
* (datasets are drawn in the reverse order). Note that this hook will not be called
* if the datasets drawing has been previously cancelled.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {number} args.index - The dataset index.
* @param {object} args.meta - The dataset metadata.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#beforeTooltipDraw
* @desc Called before drawing the `tooltip`. If any plugin returns `false`,
* the tooltip drawing is cancelled until another `render` is triggered.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {Tooltip} args.tooltip - The tooltip.
* @param {object} options - The plugin options.
* @returns {boolean} `false` to cancel the chart tooltip drawing.
*/
/**
* @method IPlugin#afterTooltipDraw
* @desc Called after drawing the `tooltip`. Note that this hook will not
* be called if the tooltip drawing has been previously cancelled.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {Tooltip} args.tooltip - The tooltip.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#beforeEvent
* @desc Called before processing the specified `event`. If any plugin returns `false`,
* the event will be discarded.
* @param {Chart} chart - The chart instance.
* @param {IEvent} event - The event object.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#afterEvent
* @desc Called after the `event` has been consumed. Note that this hook
* will not be called if the `event` has been previously discarded.
* @param {Chart} chart - The chart instance.
* @param {IEvent} event - The event object.
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#resize
* @desc Called after the chart as been resized.
* @param {Chart} chart - The chart instance.
* @param {number} size - The new canvas display size (eq. canvas.style width & height).
* @param {object} options - The plugin options.
*/
/**
* @method IPlugin#destroy
* @desc Called after the chart as been destroyed.
* @param {Chart} chart - The chart instance.
* @param {object} options - The plugin options.
*/
13 changes: 2 additions & 11 deletions src/platform/platform.base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

/**
* @typedef { import("../core/core.controller").default } Chart
* IEvent interface is defined in /types/IEvent.d.ts for documentation
* @typedef {{type: string, native?: Event, x: number, y: number}} IEvent
*/

/**
Expand Down Expand Up @@ -49,14 +51,3 @@ export default class BasePlatform {
return 1;
}
}

/**
* @interface IEvent
* @typedef {object} IEvent
* @prop {string} type - The event type name, possible values are:
* 'contextmenu', 'mouseenter', 'mousedown', 'mousemove', 'mouseup', 'mouseout',
* 'click', 'dblclick', 'keydown', 'keypress', 'keyup' and 'resize'
* @prop {*} native - The original native event (null for emulated events, e.g. 'resize')
* @prop {number} x - The mouse x position, relative to the canvas (null for incompatible events)
* @prop {number} y - The mouse y position, relative to the canvas (null for incompatible events)
*/
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
},
"typedocOptions": {
"name": "Chart.js",
"mode": "file",
"target": "ES6",
"includeDeclarations": true,
"excludeExternals": true,
"excludeNotExported": true,
"includeVersion": true,
"inputFiles": ["./src"],
"exclude": ["./node_modules"],
"inputFiles": ["./src", "./types"],
"out": "./dist/docs/typedoc"
},
"include": [
Expand Down
22 changes: 22 additions & 0 deletions types/IEvent.t.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

export interface IEvent {
/**
* The event type name.
*/
type: ('contextmenu' | 'mouseenter' | 'mousedown' | 'mousemove' | 'mouseup' | 'mouseout' | 'click' | 'dblclick' | 'keydown' | 'keypress' | 'keyup' | 'resize'),

/**
* The original native event (null for emulated events, e.g. 'resize')
*/
native: Event,

/**
* The mouse x position, relative to the canvas (null for incompatible events)
*/
x: number,

/**
* The mouse y position, relative to the canvas (null for incompatible events)
*/
y: number
}
Loading