mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-05 07:54:04 +01:00
Default options can now be accessed by importing `core/core.defaults`. The returned object acts as a singleton and is populated when importing classes that expose their own default values (meaning that importing only `code.defaults` results in an empty object). Also make `Chart.Ticks` and `Chart.Interaction` importable since existing defaults rely on these values. Add the `defaults._set` method that make easier declaring new defaults by merging given values with existing ones for a specific scope (`global`, `scale`, `bar`, etc).
50 lines
973 B
JavaScript
50 lines
973 B
JavaScript
'use strict';
|
|
|
|
var defaults = require('./core.defaults');
|
|
|
|
defaults._set('global', {
|
|
responsive: true,
|
|
responsiveAnimationDuration: 0,
|
|
maintainAspectRatio: true,
|
|
events: ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'],
|
|
hover: {
|
|
onHover: null,
|
|
mode: 'nearest',
|
|
intersect: true,
|
|
animationDuration: 400
|
|
},
|
|
onClick: null,
|
|
defaultColor: 'rgba(0,0,0,0.1)',
|
|
defaultFontColor: '#666',
|
|
defaultFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
|
|
defaultFontSize: 12,
|
|
defaultFontStyle: 'normal',
|
|
showLines: true,
|
|
|
|
// Element defaults defined in element extensions
|
|
elements: {},
|
|
|
|
// Layout options such as padding
|
|
layout: {
|
|
padding: {
|
|
top: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
left: 0
|
|
}
|
|
}
|
|
});
|
|
|
|
module.exports = function() {
|
|
|
|
// Occupy the global variable of Chart, and create a simple base class
|
|
var Chart = function(item, config) {
|
|
this.construct(item, config);
|
|
return this;
|
|
};
|
|
|
|
Chart.Chart = Chart;
|
|
|
|
return Chart;
|
|
};
|