Skip to content

Commit

Permalink
Export the plugin as default (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcollin committed Mar 3, 2024
1 parent 1f2154b commit e2c4585
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function getNext(color, customize, context) {
return c;
}

export default {
var autocolorPlugin = {
id: 'autocolors',
beforeUpdate(chart, args, options) {
const {mode = 'dataset', enabled = true, customize, repeat} = options;
Expand Down Expand Up @@ -97,3 +97,5 @@ function labelMode(chart, gen, customize) {
setColors(dataset, c.background, c.border);
}
}

export {autocolorPlugin as default};
12 changes: 9 additions & 3 deletions types/index.esm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,28 @@ declare module 'chart.js' {
}
}

interface ColorsDescriptor {
export interface ColorsDescriptor {
background: string
border: string
}

interface AutocolorsOptions {
export interface AutocolorsOptions {
enabled?: boolean,
mode?: 'dataset' | 'data' | 'label',
offset?: number,
repeat?: number,
customize?: (ctx: AutocolorsContext, options: AutocolorsOptions) => ColorsDescriptor
}

interface AutocolorsContext {
export interface AutocolorsContext {
chart: Chart
colors: ColorsDescriptor
dataIndex?: number
datasetIndex: number
}

/**
* Exports the plugin class as default
*/
// eslint-disable-next-line @typescript-eslint/no-use-before-define
export { autocolorPlugin as default };

0 comments on commit e2c4585

Please sign in to comment.