import {isArray, isNullOrUndef, valueOrDefault} from '../helpers/helpers.core';
import {_limitValue, sign} from '../helpers/helpers.math';
-defaults._set('bar', {
+defaults.set('bar', {
hover: {
mode: 'index'
},
import {extend} from '../helpers/helpers.core';
import {resolve} from '../helpers/helpers.options';
-defaults._set('bubble', {
+defaults.set('bubble', {
animation: {
numbers: {
properties: ['x', 'y', 'borderWidth', 'radius']
const DOUBLE_PI = PI * 2;
const HALF_PI = PI / 2;
-defaults._set('doughnut', {
+defaults.set('doughnut', {
animation: {
numbers: {
type: 'number',
import BarController from './controller.bar';
import defaults from '../core/core.defaults';
-defaults._set('horizontalBar', {
+defaults.set('horizontalBar', {
hover: {
mode: 'index',
axis: 'y'
import {isNumber} from '../helpers/helpers.math';
import {resolve} from '../helpers/helpers.options';
-defaults._set('line', {
+defaults.set('line', {
showLines: true,
spanGaps: false,
import defaults from '../core/core.defaults';
import {clone} from '../helpers/helpers.core';
-defaults._set('pie', clone(defaults.doughnut));
-defaults._set('pie', {
+defaults.set('pie', clone(defaults.doughnut));
+defaults.set('pie', {
cutoutPercentage: 0
});
import {toRadians} from '../helpers/helpers.math';
import {resolve} from '../helpers/helpers.options';
-defaults._set('polarArea', {
+defaults.set('polarArea', {
animation: {
numbers: {
type: 'number',
import Point from '../elements/element.point';
import {valueOrDefault} from '../helpers/helpers.core';
-defaults._set('radar', {
+defaults.set('radar', {
spanGaps: false,
scales: {
r: {
import LineController from './controller.line';
import defaults from '../core/core.defaults';
-defaults._set('scatter', {
+defaults.set('scatter', {
scales: {
x: {
type: 'linear',
const numbers = ['x', 'y', 'borderWidth', 'radius', 'tension'];
const colors = ['borderColor', 'backgroundColor'];
-defaults._set('animation', {
+defaults.set('animation', {
// Plain properties can be overridden in each object
duration: 1000,
easing: 'easeOutQuart',
import {merge} from '../helpers/helpers.core';
-export default {
- color: 'rgba(0,0,0,0.1)',
- elements: {},
- events: [
- 'mousemove',
- 'mouseout',
- 'click',
- 'touchstart',
- 'touchmove'
- ],
- fontColor: '#666',
- fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
- fontSize: 12,
- fontStyle: 'normal',
- lineHeight: 1.2,
- hover: {
- onHover: null,
- mode: 'nearest',
- intersect: true
- },
- maintainAspectRatio: true,
- onClick: null,
- responsive: true,
- showLines: true,
-
+class Defaults {
+ constructor() {
+ this.color = 'rgba(0,0,0,0.1)';
+ this.elements = {};
+ this.events = [
+ 'mousemove',
+ 'mouseout',
+ 'click',
+ 'touchstart',
+ 'touchmove'
+ ];
+ this.fontColor = '#666';
+ this.fontFamily = "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif";
+ this.fontSize = 12;
+ this.fontStyle = 'normal';
+ this.lineHeight = 1.2;
+ this.hover = {
+ onHover: null,
+ mode: 'nearest',
+ intersect: true
+ };
+ this.maintainAspectRatio = true;
+ this.onClick = null;
+ this.responsive = true;
+ this.showLines = true;
+ this.plugins = undefined;
+ this.scale = undefined;
+ this.legend = undefined;
+ this.title = undefined;
+ this.tooltips = undefined;
+ this.doughnut = undefined;
+ }
/**
+ * @param {string} scope
+ * @param {*} values
* @private
*/
- _set: function(scope, values) {
+ set(scope, values) {
return merge(this[scope] || (this[scope] = {}), values);
}
-};
+}
+
+// singleton instance
+export default new Defaults();
chartArea.y = y;
}
-defaults._set('layout', {
+defaults.set('layout', {
padding: {
top: 0,
right: 0,
* @typedef { import("../plugins/plugin.tooltip").default } Tooltip
*/
-defaults._set('plugins', {});
+defaults.set('plugins', {});
/**
* The plugin service singleton
import {_parseFont, resolve, toPadding} from '../helpers/helpers.options';
import Ticks from './core.ticks';
-defaults._set('scale', {
+defaults.set('scale', {
display: true,
offset: false,
reverse: false,
import {getAngleFromPoint} from '../helpers/helpers.math';
const TAU = Math.PI * 2;
-defaults._set('elements', {
+defaults.set('elements', {
arc: {
backgroundColor: defaults.color,
borderColor: '#fff',
const defaultColor = defaults.color;
-defaults._set('elements', {
+defaults.set('elements', {
line: {
tension: 0.4,
backgroundColor: defaultColor,
const defaultColor = defaults.color;
-defaults._set('elements', {
+defaults.set('elements', {
point: {
radius: 3,
pointStyle: 'circle',
const defaultColor = defaults.color;
-defaults._set('elements', {
+defaults.set('elements', {
rectangle: {
backgroundColor: defaultColor,
borderColor: defaultColor,
import {isArray, isFinite, valueOrDefault} from '../helpers/helpers.core';
import {_normalizeAngle} from '../helpers/helpers.math';
-defaults._set('plugins', {
+defaults.set('plugins', {
filler: {
propagate: true
}
* @typedef { import("../platform/platform.base").IEvent } IEvent
*/
-defaults._set('legend', {
+defaults.set('legend', {
display: true,
position: 'top',
align: 'center',
import helpers from '../helpers/index';
import layouts from '../core/core.layouts';
-defaults._set('title', {
+defaults.set('title', {
align: 'center',
display: false,
fontStyle: 'bold',
const valueOrDefault = helpers.valueOrDefault;
const getRtlHelper = helpers.rtl.getRtlAdapter;
-defaults._set('tooltips', {
+defaults.set('tooltips', {
enabled: true,
custom: null,
mode: 'nearest',