mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 04:09:08 +02:00
move option to correct namespace (#10613)
* move option to correct namespace * change plugin name from snake_case to camelCase
This commit is contained in:
parent
b0a06d1652
commit
432d1e6a60
@ -33,7 +33,7 @@ const data = {
|
|||||||
// <block:plugin:2>
|
// <block:plugin:2>
|
||||||
// Note: changes to the plugin code is not reflected to the chart, because the plugin is loaded at chart construction time and editor changes only trigger an chart.update().
|
// Note: changes to the plugin code is not reflected to the chart, because the plugin is loaded at chart construction time and editor changes only trigger an chart.update().
|
||||||
const plugin = {
|
const plugin = {
|
||||||
id: 'custom_canvas_background_color',
|
id: 'customCanvasBackgroundColor',
|
||||||
beforeDraw: (chart, args, options) => {
|
beforeDraw: (chart, args, options) => {
|
||||||
const {ctx} = chart;
|
const {ctx} = chart;
|
||||||
ctx.save();
|
ctx.save();
|
||||||
@ -51,8 +51,10 @@ const config = {
|
|||||||
data: data,
|
data: data,
|
||||||
options: {
|
options: {
|
||||||
plugins: {
|
plugins: {
|
||||||
|
customCanvasBackgroundColor: {
|
||||||
color: 'lightGreen',
|
color: 'lightGreen',
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
plugins: [plugin],
|
plugins: [plugin],
|
||||||
};
|
};
|
||||||
@ -95,7 +97,7 @@ const image = new Image();
|
|||||||
image.src = 'https://www.chartjs.org/img/chartjs-logo.svg';
|
image.src = 'https://www.chartjs.org/img/chartjs-logo.svg';
|
||||||
|
|
||||||
const plugin = {
|
const plugin = {
|
||||||
id: 'custom_canvas_background_image',
|
id: 'customCanvasBackgroundImage',
|
||||||
beforeDraw: (chart) => {
|
beforeDraw: (chart) => {
|
||||||
if (image.complete) {
|
if (image.complete) {
|
||||||
const ctx = chart.ctx;
|
const ctx = chart.ctx;
|
||||||
|
@ -195,7 +195,7 @@ import {ChartType, Plugin} from 'chart.js';
|
|||||||
|
|
||||||
declare module 'chart.js' {
|
declare module 'chart.js' {
|
||||||
interface PluginOptionsByType<TType extends ChartType> {
|
interface PluginOptionsByType<TType extends ChartType> {
|
||||||
custom_canvas_background_color?: {
|
customCanvasBackgroundColor?: {
|
||||||
color?: string
|
color?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user