language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | chartjs | Chart.js | 7c3e71d58b6cb4b169ef03ca22f7bf2cfd09b912.json | update copyright date | gulpfile.js | @@ -29,7 +29,7 @@ var header = "/*!\n" +
" * http://chartjs.org/\n" +
" * Version: {{ version }}\n" +
" *\n" +
- " * Copyright 2016 Nick Downie\n" +
+ " * Copyright 2017 Nick Downie\n" +
" * Released under the MIT license\n" +
" * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md\n" +
" */\n"; | false |
Other | chartjs | Chart.js | 3187a788e17f79ad69da509748aeb64cdbac48f0.json | Add support for local plugins and plugin options
Plugins can now be declared in the chart `config.plugins` array and will only be applied to the associated chart(s), after the globally registered plugins. Plugin specific options are now scoped under the `config.options.plugins` options. Hooks now receive the chart instance as first argument and the plugin options as last argument. | src/chart.js | @@ -5,13 +5,13 @@ var Chart = require('./core/core.js')();
require('./core/core.helpers')(Chart);
require('./core/core.canvasHelpers')(Chart);
+require('./core/core.plugin.js')(Chart);
require('./core/core.element')(Chart);
require('./core/core.animation')(Chart);
require('./core/core.controller')(Chart);
require('./core/core.datasetController')(Chart);
require('./core/core.layoutService')(Chart);
require('./core/core.scaleService')(Chart);
-require('./core/core.plugin.js')(Chart);
require('./core/core.ticks.js')(Chart);
require('./core/core.scale')(Chart);
require('./core/core.title')(Chart); | true |
Other | chartjs | Chart.js | 3187a788e17f79ad69da509748aeb64cdbac48f0.json | Add support for local plugins and plugin options
Plugins can now be declared in the chart `config.plugins` array and will only be applied to the associated chart(s), after the globally registered plugins. Plugin specific options are now scoped under the `config.options.plugins` options. Hooks now receive the chart instance as first argument and the plugin options as last argument. | src/core/core.controller.js | @@ -258,7 +258,7 @@ module.exports = function(Chart) {
var me = this;
// Before init plugin notification
- Chart.plugins.notify('beforeInit', [me]);
+ Chart.plugins.notify(me, 'beforeInit');
me.bindEvents();
@@ -273,7 +273,7 @@ module.exports = function(Chart) {
me.update();
// After init plugin notification
- Chart.plugins.notify('afterInit', [me]);
+ Chart.plugins.notify(me, 'afterInit');
return me;
},
@@ -315,7 +315,7 @@ module.exports = function(Chart) {
if (!silent) {
// Notify any plugins about the resize
var newSize = {width: newWidth, height: newHeight};
- Chart.plugins.notify('resize', [me, newSize]);
+ Chart.plugins.notify(me, 'resize', [newSize]);
// Notify of resize
if (me.options.onResize) {
@@ -460,7 +460,7 @@ module.exports = function(Chart) {
var me = this;
updateConfig(me);
- Chart.plugins.notify('beforeUpdate', [me]);
+ Chart.plugins.notify(me, 'beforeUpdate');
// In case the entire data object changed
me.tooltip._data = me.data;
@@ -476,7 +476,7 @@ module.exports = function(Chart) {
Chart.layoutService.update(me, me.chart.width, me.chart.height);
// Apply changes to the datasets that require the scales to have been calculated i.e BorderColor changes
- Chart.plugins.notify('afterScaleUpdate', [me]);
+ Chart.plugins.notify(me, 'afterScaleUpdate');
// Can only reset the new controllers after the scales have been updated
helpers.each(newControllers, function(controller) {
@@ -486,7 +486,7 @@ module.exports = function(Chart) {
me.updateDatasets();
// Do this before render so that any plugins that need final scale updates can use it
- Chart.plugins.notify('afterUpdate', [me]);
+ Chart.plugins.notify(me, 'afterUpdate');
if (me._bufferedRender) {
me._bufferedRequest = {
@@ -530,18 +530,18 @@ module.exports = function(Chart) {
var me = this;
var i, ilen;
- if (Chart.plugins.notify('beforeDatasetsUpdate', [me])) {
+ if (Chart.plugins.notify(me, 'beforeDatasetsUpdate')) {
for (i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
me.getDatasetMeta(i).controller.update();
}
- Chart.plugins.notify('afterDatasetsUpdate', [me]);
+ Chart.plugins.notify(me, 'afterDatasetsUpdate');
}
},
render: function(duration, lazy) {
var me = this;
- Chart.plugins.notify('beforeRender', [me]);
+ Chart.plugins.notify(me, 'beforeRender');
var animationOptions = me.options.animation;
if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) {
@@ -577,7 +577,7 @@ module.exports = function(Chart) {
var easingDecimal = ease || 1;
me.clear();
- Chart.plugins.notify('beforeDraw', [me, easingDecimal]);
+ Chart.plugins.notify(me, 'beforeDraw', [easingDecimal]);
// Draw all the scales
helpers.each(me.boxes, function(box) {
@@ -587,7 +587,7 @@ module.exports = function(Chart) {
me.scale.draw();
}
- Chart.plugins.notify('beforeDatasetsDraw', [me, easingDecimal]);
+ Chart.plugins.notify(me, 'beforeDatasetsDraw', [easingDecimal]);
// Draw each dataset via its respective controller (reversed to support proper line stacking)
helpers.each(me.data.datasets, function(dataset, datasetIndex) {
@@ -596,12 +596,12 @@ module.exports = function(Chart) {
}
}, me, true);
- Chart.plugins.notify('afterDatasetsDraw', [me, easingDecimal]);
+ Chart.plugins.notify(me, 'afterDatasetsDraw', [easingDecimal]);
// Finally draw the tooltip
me.tooltip.transition(easingDecimal).draw();
- Chart.plugins.notify('afterDraw', [me, easingDecimal]);
+ Chart.plugins.notify(me, 'afterDraw', [easingDecimal]);
},
// Get the single element that was clicked on
@@ -701,7 +701,7 @@ module.exports = function(Chart) {
me.chart.ctx = null;
}
- Chart.plugins.notify('destroy', [me]);
+ Chart.plugins.notify(me, 'destroy');
delete Chart.instances[me.id];
}, | true |
Other | chartjs | Chart.js | 3187a788e17f79ad69da509748aeb64cdbac48f0.json | Add support for local plugins and plugin options
Plugins can now be declared in the chart `config.plugins` array and will only be applied to the associated chart(s), after the globally registered plugins. Plugin specific options are now scoped under the `config.options.plugins` options. Hooks now receive the chart instance as first argument and the plugin options as last argument. | src/core/core.plugin.js | @@ -2,16 +2,31 @@
module.exports = function(Chart) {
- var noop = Chart.helpers.noop;
+ var helpers = Chart.helpers;
+ var noop = helpers.noop;
+
+ Chart.defaults.global.plugins = {};
/**
* The plugin service singleton
* @namespace Chart.plugins
* @since 2.1.0
*/
Chart.plugins = {
+ /**
+ * Globally registered plugins.
+ * @private
+ */
_plugins: [],
+ /**
+ * This identifier is used to invalidate the descriptors cache attached to each chart
+ * when a global plugin is registered or unregistered. In this case, the cache ID is
+ * incremented and descriptors are regenerated during following API calls.
+ * @private
+ */
+ _cacheId: 0,
+
/**
* Registers the given plugin(s) if not already registered.
* @param {Array|Object} plugins plugin instance(s).
@@ -23,6 +38,8 @@ module.exports = function(Chart) {
p.push(plugin);
}
});
+
+ this._cacheId++;
},
/**
@@ -37,6 +54,8 @@ module.exports = function(Chart) {
p.splice(idx, 1);
}
});
+
+ this._cacheId++;
},
/**
@@ -45,6 +64,7 @@ module.exports = function(Chart) {
*/
clear: function() {
this._plugins = [];
+ this._cacheId++;
},
/**
@@ -66,28 +86,78 @@ module.exports = function(Chart) {
},
/**
- * Calls registered plugins on the specified extension, with the given args. This
- * method immediately returns as soon as a plugin explicitly returns false. The
+ * Calls enabled plugins for chart, on the specified extension and with the given args.
+ * This method immediately returns as soon as a plugin explicitly returns false. The
* returned value can be used, for instance, to interrupt the current action.
+ * @param {Object} chart chart instance for which plugins should be called.
* @param {String} extension the name of the plugin method to call (e.g. 'beforeUpdate').
* @param {Array} [args] extra arguments to apply to the extension call.
* @returns {Boolean} false if any of the plugins return false, else returns true.
*/
- notify: function(extension, args) {
- var plugins = this._plugins;
- var ilen = plugins.length;
- var i, plugin;
+ notify: function(chart, extension, args) {
+ var descriptors = this.descriptors(chart);
+ var ilen = descriptors.length;
+ var i, descriptor, plugin, params, method;
for (i=0; i<ilen; ++i) {
- plugin = plugins[i];
- if (typeof plugin[extension] === 'function') {
- if (plugin[extension].apply(plugin, args || []) === false) {
+ descriptor = descriptors[i];
+ plugin = descriptor.plugin;
+ method = plugin[extension];
+ if (typeof method === 'function') {
+ params = [chart].concat(args || []);
+ params.push(descriptor.options);
+ if (method.apply(plugin, params) === false) {
return false;
}
}
}
return true;
+ },
+
+ /**
+ * Returns descriptors of enabled plugins for the given chart.
+ * @returns {Array} [{ plugin, options }]
+ * @private
+ */
+ descriptors: function(chart) {
+ var cache = chart._plugins || (chart._plugins = {});
+ if (cache.id === this._cacheId) {
+ return cache.descriptors;
+ }
+
+ var plugins = [];
+ var descriptors = [];
+ var config = (chart && chart.config) || {};
+ var defaults = Chart.defaults.global.plugins;
+ var options = (config.options && config.options.plugins) || {};
+
+ this._plugins.concat(config.plugins || []).forEach(function(plugin) {
+ var idx = plugins.indexOf(plugin);
+ if (idx !== -1) {
+ return;
+ }
+
+ var id = plugin.id;
+ var opts = options[id];
+ if (opts === false) {
+ return;
+ }
+
+ if (opts === true) {
+ opts = helpers.clone(defaults[id]);
+ }
+
+ plugins.push(plugin);
+ descriptors.push({
+ plugin: plugin,
+ options: opts || {}
+ });
+ });
+
+ cache.descriptors = descriptors;
+ cache.id = this._cacheId;
+ return descriptors;
}
};
@@ -96,7 +166,7 @@ module.exports = function(Chart) {
* @interface Chart.PluginBase
* @since 2.1.0
*/
- Chart.PluginBase = Chart.Element.extend({
+ Chart.PluginBase = helpers.inherits({
// Called at start of chart init
beforeInit: noop,
@@ -123,7 +193,7 @@ module.exports = function(Chart) {
* Provided for backward compatibility, use Chart.plugins instead
* @namespace Chart.pluginService
* @deprecated since version 2.1.5
- * @todo remove me at version 3
+ * TODO remove me at version 3
*/
Chart.pluginService = Chart.plugins;
}; | true |
Other | chartjs | Chart.js | 3187a788e17f79ad69da509748aeb64cdbac48f0.json | Add support for local plugins and plugin options
Plugins can now be declared in the chart `config.plugins` array and will only be applied to the associated chart(s), after the globally registered plugins. Plugin specific options are now scoped under the `config.options.plugins` options. Hooks now receive the chart instance as first argument and the plugin options as last argument. | test/core.plugin.tests.js | @@ -1,16 +1,13 @@
describe('Chart.plugins', function() {
- var oldPlugins;
-
- beforeAll(function() {
- oldPlugins = Chart.plugins.getAll();
- });
-
- afterAll(function() {
- Chart.plugins.register(oldPlugins);
+ beforeEach(function() {
+ this._plugins = Chart.plugins.getAll();
+ Chart.plugins.clear();
});
- beforeEach(function() {
+ afterEach(function() {
Chart.plugins.clear();
+ Chart.plugins.register(this._plugins);
+ delete this._plugins;
});
describe('Chart.plugins.register', function() {
@@ -66,63 +63,282 @@ describe('Chart.plugins', function() {
});
describe('Chart.plugins.notify', function() {
- it('should call plugins with arguments', function() {
- var myplugin = {
- count: 0,
- trigger: function(chart) {
- myplugin.count = chart.count;
+ it('should call inline plugins with arguments', function() {
+ var plugin = {hook: function() {}};
+ var chart = window.acquireChart({
+ plugins: [plugin]
+ });
+
+ spyOn(plugin, 'hook');
+
+ Chart.plugins.notify(chart, 'hook', 42);
+ expect(plugin.hook.calls.count()).toBe(1);
+ expect(plugin.hook.calls.first().args[0]).toBe(chart);
+ expect(plugin.hook.calls.first().args[1]).toBe(42);
+ expect(plugin.hook.calls.first().args[2]).toEqual({});
+ });
+
+ it('should call global plugins with arguments', function() {
+ var plugin = {hook: function() {}};
+ var chart = window.acquireChart({});
+
+ spyOn(plugin, 'hook');
+
+ Chart.plugins.register(plugin);
+ Chart.plugins.notify(chart, 'hook', 42);
+ expect(plugin.hook.calls.count()).toBe(1);
+ expect(plugin.hook.calls.first().args[0]).toBe(chart);
+ expect(plugin.hook.calls.first().args[1]).toBe(42);
+ expect(plugin.hook.calls.first().args[2]).toEqual({});
+ });
+
+ it('should call plugin only once even if registered multiple times', function() {
+ var plugin = {hook: function() {}};
+ var chart = window.acquireChart({
+ plugins: [plugin, plugin]
+ });
+
+ spyOn(plugin, 'hook');
+
+ Chart.plugins.register([plugin, plugin]);
+ Chart.plugins.notify(chart, 'hook');
+ expect(plugin.hook.calls.count()).toBe(1);
+ });
+
+ it('should call plugins in the correct order (global first)', function() {
+ var results = [];
+ var chart = window.acquireChart({
+ plugins: [{
+ hook: function() {
+ results.push(1);
+ }
+ }, {
+ hook: function() {
+ results.push(2);
+ }
+ }, {
+ hook: function() {
+ results.push(3);
+ }
+ }]
+ });
+
+ Chart.plugins.register([{
+ hook: function() {
+ results.push(4);
}
- };
+ }, {
+ hook: function() {
+ results.push(5);
+ }
+ }, {
+ hook: function() {
+ results.push(6);
+ }
+ }]);
- Chart.plugins.register(myplugin);
- Chart.plugins.notify('trigger', [{count: 10}]);
- expect(myplugin.count).toBe(10);
+ var ret = Chart.plugins.notify(chart, 'hook');
+ expect(ret).toBeTruthy();
+ expect(results).toEqual([4, 5, 6, 1, 2, 3]);
});
it('should return TRUE if no plugin explicitly returns FALSE', function() {
- Chart.plugins.register({
- check: function() {}
+ var chart = window.acquireChart({
+ plugins: [{
+ hook: function() {}
+ }, {
+ hook: function() {
+ return null;
+ }
+ }, {
+ hook: function() {
+ return 0;
+ }
+ }, {
+ hook: function() {
+ return true;
+ }
+ }, {
+ hook: function() {
+ return 1;
+ }
+ }]
});
- Chart.plugins.register({
- check: function() {
- return;
- }
+
+ var plugins = chart.config.plugins;
+ plugins.forEach(function(plugin) {
+ spyOn(plugin, 'hook').and.callThrough();
});
- Chart.plugins.register({
- check: function() {
- return null;
- }
+
+ var ret = Chart.plugins.notify(chart, 'hook');
+ expect(ret).toBeTruthy();
+ plugins.forEach(function(plugin) {
+ expect(plugin.hook).toHaveBeenCalled();
});
- Chart.plugins.register({
- check: function() {
- return 42;
- }
+ });
+
+ it('should return FALSE if any plugin explicitly returns FALSE', function() {
+ var chart = window.acquireChart({
+ plugins: [{
+ hook: function() {}
+ }, {
+ hook: function() {
+ return null;
+ }
+ }, {
+ hook: function() {
+ return false;
+ }
+ }, {
+ hook: function() {
+ return 42;
+ }
+ }, {
+ hook: function() {
+ return 'bar';
+ }
+ }]
});
- var res = Chart.plugins.notify('check');
- expect(res).toBeTruthy();
+
+ var plugins = chart.config.plugins;
+ plugins.forEach(function(plugin) {
+ spyOn(plugin, 'hook').and.callThrough();
+ });
+
+ var ret = Chart.plugins.notify(chart, 'hook');
+ expect(ret).toBeFalsy();
+ expect(plugins[0].hook).toHaveBeenCalled();
+ expect(plugins[1].hook).toHaveBeenCalled();
+ expect(plugins[2].hook).toHaveBeenCalled();
+ expect(plugins[3].hook).not.toHaveBeenCalled();
+ expect(plugins[4].hook).not.toHaveBeenCalled();
});
+ });
- it('should return FALSE if no plugin explicitly returns FALSE', function() {
- Chart.plugins.register({
- check: function() {}
+ describe('config.options.plugins', function() {
+ it('should call plugins with options at last argument', function() {
+ var plugin = {id: 'foo', hook: function() {}};
+ var chart = window.acquireChart({
+ options: {
+ plugins: {
+ foo: {a: '123'},
+ }
+ }
});
- Chart.plugins.register({
- check: function() {
- return;
+
+ spyOn(plugin, 'hook');
+
+ Chart.plugins.register(plugin);
+ Chart.plugins.notify(chart, 'hook');
+ Chart.plugins.notify(chart, 'hook', ['bla']);
+ Chart.plugins.notify(chart, 'hook', ['bla', 42]);
+
+ expect(plugin.hook.calls.count()).toBe(3);
+ expect(plugin.hook.calls.argsFor(0)[1]).toEqual({a: '123'});
+ expect(plugin.hook.calls.argsFor(1)[2]).toEqual({a: '123'});
+ expect(plugin.hook.calls.argsFor(2)[3]).toEqual({a: '123'});
+ });
+
+ it('should call plugins with options associated to their identifier', function() {
+ var plugins = {
+ a: {id: 'a', hook: function() {}},
+ b: {id: 'b', hook: function() {}},
+ c: {id: 'c', hook: function() {}}
+ };
+
+ Chart.plugins.register(plugins.a);
+
+ var chart = window.acquireChart({
+ plugins: [plugins.b, plugins.c],
+ options: {
+ plugins: {
+ a: {a: '123'},
+ b: {b: '456'},
+ c: {c: '789'}
+ }
}
});
- Chart.plugins.register({
- check: function() {
- return false;
+
+ spyOn(plugins.a, 'hook');
+ spyOn(plugins.b, 'hook');
+ spyOn(plugins.c, 'hook');
+
+ Chart.plugins.notify(chart, 'hook');
+
+ expect(plugins.a.hook).toHaveBeenCalled();
+ expect(plugins.b.hook).toHaveBeenCalled();
+ expect(plugins.c.hook).toHaveBeenCalled();
+ expect(plugins.a.hook.calls.first().args[1]).toEqual({a: '123'});
+ expect(plugins.b.hook.calls.first().args[1]).toEqual({b: '456'});
+ expect(plugins.c.hook.calls.first().args[1]).toEqual({c: '789'});
+ });
+
+ it('should not called plugins when config.options.plugins.{id} is FALSE', function() {
+ var plugins = {
+ a: {id: 'a', hook: function() {}},
+ b: {id: 'b', hook: function() {}},
+ c: {id: 'c', hook: function() {}}
+ };
+
+ Chart.plugins.register(plugins.a);
+
+ var chart = window.acquireChart({
+ plugins: [plugins.b, plugins.c],
+ options: {
+ plugins: {
+ a: false,
+ b: false
+ }
}
});
- Chart.plugins.register({
- check: function() {
- return 42;
+
+ spyOn(plugins.a, 'hook');
+ spyOn(plugins.b, 'hook');
+ spyOn(plugins.c, 'hook');
+
+ Chart.plugins.notify(chart, 'hook');
+
+ expect(plugins.a.hook).not.toHaveBeenCalled();
+ expect(plugins.b.hook).not.toHaveBeenCalled();
+ expect(plugins.c.hook).toHaveBeenCalled();
+ });
+
+ it('should call plugins with default options when plugin options is TRUE', function() {
+ var plugin = {id: 'a', hook: function() {}};
+
+ Chart.defaults.global.plugins.a = {a: 42};
+ Chart.plugins.register(plugin);
+
+ var chart = window.acquireChart({
+ options: {
+ plugins: {
+ a: true
+ }
}
});
- var res = Chart.plugins.notify('check');
- expect(res).toBeFalsy();
+
+ spyOn(plugin, 'hook');
+
+ Chart.plugins.notify(chart, 'hook');
+
+ expect(plugin.hook).toHaveBeenCalled();
+ expect(plugin.hook.calls.first().args[1]).toEqual({a: 42});
+ });
+
+
+ it('should call plugins with default options if plugin config options is undefined', function() {
+ var plugin = {id: 'a', hook: function() {}};
+
+ Chart.defaults.global.plugins.a = {a: 'foobar'};
+ Chart.plugins.register(plugin);
+ spyOn(plugin, 'hook');
+
+ var chart = window.acquireChart();
+
+ Chart.plugins.notify(chart, 'hook');
+
+ expect(plugin.hook).toHaveBeenCalled();
+ expect(plugin.hook.calls.first().args[1]).toEqual({a: 'foobar'});
});
});
}); | true |
Other | chartjs | Chart.js | 3187a788e17f79ad69da509748aeb64cdbac48f0.json | Add support for local plugins and plugin options
Plugins can now be declared in the chart `config.plugins` array and will only be applied to the associated chart(s), after the globally registered plugins. Plugin specific options are now scoped under the `config.options.plugins` options. Hooks now receive the chart instance as first argument and the plugin options as last argument. | test/mockContext.js | @@ -274,6 +274,7 @@
var canvas = document.createElement('canvas');
var chart, key;
+ config = config || {};
options = options || {};
options.canvas = options.canvas || {height: 512, width: 512};
options.wrapper = options.wrapper || {class: 'chartjs-wrapper'}; | true |
Other | chartjs | Chart.js | 152ce9c9f83e3678aee663ee250d7cda06bb3b99.json | Pass the hover event to the onHover event handler (#3669)
Pass the hover event to the onHover event handler
This makes the behavior of the `onHover` handler consistent with the `onClick` handler:
```
function(event, activeElements) {
var chartInstance = this;
}
``` | docs/01-Chart-Configuration.md | @@ -81,7 +81,7 @@ responsive | Boolean | true | Resizes the chart canvas when its container does.
responsiveAnimationDuration | Number | 0 | Duration in milliseconds it takes to animate to new size after a resize event.
maintainAspectRatio | Boolean | true | Maintain the original canvas aspect ratio `(width / height)` when resizing
events | Array[String] | `["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"]` | Events that the chart should listen to for tooltips and hovering
-onClick | Function | null | Called if the event is of type 'mouseup' or 'click'. Called in the context of the chart and passed an array of active elements
+onClick | Function | null | Called if the event is of type 'mouseup' or 'click'. Called in the context of the chart and passed the event and an array of active elements
legendCallback | Function | ` function (chart) { }` | Function to generate a legend. Receives the chart object to generate a legend from. Default implementation returns an HTML string.
onResize | Function | null | Called when a resize occurs. Gets passed two arguments: the chart instance and the new size.
@@ -310,7 +310,7 @@ Name | Type | Default | Description
mode | String | 'nearest' | Sets which elements appear in the tooltip. See [Interaction Modes](#interaction-modes) for details
intersect | Boolean | true | if true, the hover mode only applies when the mouse position intersects an item on the chart
animationDuration | Number | 400 | Duration in milliseconds it takes to animate hover style changes
-onHover | Function | null | Called when any of the events fire. Called in the context of the chart and passed an array of active elements (bars, points, etc)
+onHover | Function | null | Called when any of the events fire. Called in the context of the chart and passed the event and an array of active elements (bars, points, etc)
### Interaction Modes
When configuring interaction with the graph via hover or tooltips, a number of different modes are available. | true |
Other | chartjs | Chart.js | 152ce9c9f83e3678aee663ee250d7cda06bb3b99.json | Pass the hover event to the onHover event handler (#3669)
Pass the hover event to the onHover event handler
This makes the behavior of the `onHover` handler consistent with the `onClick` handler:
```
function(event, activeElements) {
var chartInstance = this;
}
``` | src/core/core.controller.js | @@ -796,7 +796,7 @@ module.exports = function(Chart) {
// On Hover hook
if (hoverOptions.onHover) {
- hoverOptions.onHover.call(me, me.active);
+ hoverOptions.onHover.call(me, e, me.active);
}
if (e.type === 'mouseup' || e.type === 'click') { | true |
Other | chartjs | Chart.js | 97f6c8f12d75981ace1df5662f544f0758653170.json | Add rectRounded point style | docs/03-Line-Chart.md | @@ -57,7 +57,7 @@ pointHitRadius | `Number or Array<Number>` | The pixel size of the non-displayed
pointHoverBackgroundColor | `Color or Array<Color>` | Point background color when hovered
pointHoverBorderColor | `Color or Array<Color>` | Point border color when hovered
pointHoverBorderWidth | `Number or Array<Number>` | Border width of point when hovered
-pointStyle | `String, Array<String>, Image, Array<Image>` | The style of point. Options are 'circle', 'triangle', 'rect', 'rectRot', 'cross', 'crossRot', 'star', 'line', and 'dash'. If the option is an image, that image is drawn on the canvas using `drawImage`.
+pointStyle | `String, Array<String>, Image, Array<Image>` | The style of point. Options are 'circle', 'triangle', 'rect', 'rectRounded', 'rectRot', 'cross', 'crossRot', 'star', 'line', and 'dash'. If the option is an image, that image is drawn on the canvas using `drawImage`.
showLine | `Boolean` | If false, the line is not drawn for this dataset
spanGaps | `Boolean` | If true, lines will be drawn between points with no or null data
steppedLine | `Boolean` | If true, the line is shown as a stepped line and 'lineTension' will be ignored | true |
Other | chartjs | Chart.js | 97f6c8f12d75981ace1df5662f544f0758653170.json | Add rectRounded point style | docs/05-Radar-Chart.md | @@ -50,7 +50,7 @@ pointHitRadius | `Number or Array<Number>` | The pixel size of the non-displayed
pointHoverBackgroundColor | `Color or Array<Color>` | Point background color when hovered
pointHoverBorderColor | `Color or Array<Color>` | Point border color when hovered
pointHoverBorderWidth | `Number or Array<Number>` | Border width of point when hovered
-pointStyle | `String or Array<String>` | The style of point. Options include 'circle', 'triangle', 'rect', 'rectRot', 'cross', 'crossRot', 'star', 'line', and 'dash'
+pointStyle | `String or Array<String>` | The style of point. Options include 'circle', 'triangle', 'rect', 'rectRounded', 'rectRot', 'cross', 'crossRot', 'star', 'line', and 'dash'
An example data object using these attributes is shown below.
| true |
Other | chartjs | Chart.js | 97f6c8f12d75981ace1df5662f544f0758653170.json | Add rectRounded point style | src/core/core.canvasHelpers.js | @@ -43,6 +43,14 @@ module.exports = function(Chart) {
ctx.fillRect(x - size, y - size, 2 * size, 2 * size);
ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
break;
+ case 'rectRounded':
+ var offset = radius / Math.SQRT2;
+ var leftX = x - offset;
+ var topY = y - offset;
+ var sideSize = Math.SQRT2 * radius;
+ Chart.helpers.drawRoundedRectangle(ctx, leftX, topY, sideSize, sideSize, radius / 2);
+ ctx.fill();
+ break;
case 'rectRot':
size = 1 / Math.SQRT2 * radius;
ctx.beginPath(); | true |
Other | chartjs | Chart.js | 97f6c8f12d75981ace1df5662f544f0758653170.json | Add rectRounded point style | test/element.point.tests.js | @@ -208,6 +208,30 @@ describe('Point element tests', function() {
args: []
}]);
+ var drawRoundedRectangleSpy = jasmine.createSpy('drawRoundedRectangle');
+ var drawRoundedRectangle = Chart.helpers.drawRoundedRectangle;
+ var offset = point._view.radius / Math.SQRT2;
+ Chart.helpers.drawRoundedRectangle = drawRoundedRectangleSpy;
+ mockContext.resetCalls();
+ point._view.pointStyle = 'rectRounded';
+ point.draw();
+
+ expect(drawRoundedRectangleSpy).toHaveBeenCalledWith(
+ mockContext,
+ 10 - offset,
+ 15 - offset,
+ Math.SQRT2 * 2,
+ Math.SQRT2 * 2,
+ 2 / 2
+ );
+ expect(mockContext.getCalls()).toContain(
+ jasmine.objectContaining({
+ name: 'fill',
+ args: [],
+ })
+ );
+
+ Chart.helpers.drawRoundedRectangle = drawRoundedRectangle;
mockContext.resetCalls();
point._view.pointStyle = 'rectRot';
point.draw(); | true |
Other | chartjs | Chart.js | 7e5e29e3ee15100de599124b4951d50f3aad5f57.json | Improve radial scale (#3625)
Clean up radial linear scale. It now supports multiple lines for point labels. Fixes #3225 | samples/radar/radar.html | @@ -32,7 +32,7 @@
var config = {
type: 'radar',
data: {
- labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
+ labels: [["Eating", "Dinner"], ["Drinking", "Water"], "Sleeping", ["Designing", "Graphics"], "Coding", "Cycling", "Running"],
datasets: [{
label: "My First dataset",
backgroundColor: color(window.chartColors.red).alpha(0.2).rgbString(), | true |
Other | chartjs | Chart.js | 7e5e29e3ee15100de599124b4951d50f3aad5f57.json | Improve radial scale (#3625)
Clean up radial linear scale. It now supports multiple lines for point labels. Fixes #3225 | src/scales/scale.radialLinear.js | @@ -47,10 +47,266 @@ module.exports = function(Chart) {
}
};
+ function getValueCount(scale) {
+ return !scale.options.lineArc ? scale.chart.data.labels.length : 0;
+ }
+
+ function getPointLabelFontOptions(scale) {
+ var pointLabelOptions = scale.options.pointLabels;
+ var fontSize = helpers.getValueOrDefault(pointLabelOptions.fontSize, globalDefaults.defaultFontSize);
+ var fontStyle = helpers.getValueOrDefault(pointLabelOptions.fontStyle, globalDefaults.defaultFontStyle);
+ var fontFamily = helpers.getValueOrDefault(pointLabelOptions.fontFamily, globalDefaults.defaultFontFamily);
+ var font = helpers.fontString(fontSize, fontStyle, fontFamily);
+
+ return {
+ size: fontSize,
+ style: fontStyle,
+ family: fontFamily,
+ font: font
+ };
+ }
+
+ function measureLabelSize(ctx, fontSize, label) {
+ if (helpers.isArray(label)) {
+ return {
+ w: helpers.longestText(ctx, ctx.font, label),
+ h: (label.length * fontSize) + ((label.length - 1) * 1.5 * fontSize)
+ };
+ }
+
+ return {
+ w: ctx.measureText(label).width,
+ h: fontSize
+ };
+ }
+
+ function determineLimits(angle, pos, size, min, max) {
+ if (angle === min || angle === max) {
+ return {
+ start: pos - (size / 2),
+ end: pos + (size / 2)
+ };
+ } else if (angle < min || angle > max) {
+ return {
+ start: pos - size - 5,
+ end: pos
+ };
+ }
+
+ return {
+ start: pos,
+ end: pos + size + 5
+ };
+ }
+
+ /**
+ * Helper function to fit a radial linear scale with point labels
+ */
+ function fitWithPointLabels(scale) {
+ /*
+ * Right, this is really confusing and there is a lot of maths going on here
+ * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
+ *
+ * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
+ *
+ * Solution:
+ *
+ * We assume the radius of the polygon is half the size of the canvas at first
+ * at each index we check if the text overlaps.
+ *
+ * Where it does, we store that angle and that index.
+ *
+ * After finding the largest index and angle we calculate how much we need to remove
+ * from the shape radius to move the point inwards by that x.
+ *
+ * We average the left and right distances to get the maximum shape radius that can fit in the box
+ * along with labels.
+ *
+ * Once we have that, we can find the centre point for the chart, by taking the x text protrusion
+ * on each side, removing that from the size, halving it and adding the left x protrusion width.
+ *
+ * This will mean we have a shape fitted to the canvas, as large as it can be with the labels
+ * and position it in the most space efficient manner
+ *
+ * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif
+ */
+
+ var plFont = getPointLabelFontOptions(scale);
+
+ // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width.
+ // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points
+ var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2);
+ var furthestLimits = {
+ l: scale.width,
+ r: 0,
+ t: scale.height,
+ b: 0
+ };
+ var furthestAngles = {};
+ var i;
+ var textSize;
+ var pointPosition;
+
+ scale.ctx.font = plFont.font;
+ scale._pointLabelSizes = [];
+
+ var valueCount = getValueCount(scale);
+ for (i = 0; i < valueCount; i++) {
+ pointPosition = scale.getPointPosition(i, largestPossibleRadius);
+ textSize = measureLabelSize(scale.ctx, plFont.size, scale.pointLabels[i] || '');
+ scale._pointLabelSizes[i] = textSize;
+
+ // Add quarter circle to make degree 0 mean top of circle
+ var angleRadians = scale.getIndexAngle(i);
+ var angle = helpers.toDegrees(angleRadians) % 360;
+ var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);
+ var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);
+
+ if (hLimits.start < furthestLimits.l) {
+ furthestLimits.l = hLimits.start;
+ furthestAngles.l = angleRadians;
+ }
+
+ if (hLimits.end > furthestLimits.r) {
+ furthestLimits.r = hLimits.end;
+ furthestAngles.r = angleRadians;
+ }
+
+ if (vLimits.start < furthestLimits.t) {
+ furthestLimits.t = vLimits.start;
+ furthestAngles.t = angleRadians;
+ }
+
+ if (vLimits.end > furthestLimits.b) {
+ furthestLimits.b = vLimits.end;
+ furthestAngles.b = angleRadians;
+ }
+ }
+
+ scale.setReductions(largestPossibleRadius, furthestLimits, furthestAngles);
+ }
+
+ /**
+ * Helper function to fit a radial linear scale with no point labels
+ */
+ function fit(scale) {
+ var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2);
+ scale.drawingArea = Math.round(largestPossibleRadius);
+ scale.setCenterPoint(0, 0, 0, 0);
+ }
+
+ function getTextAlignForAngle(angle) {
+ if (angle === 0 || angle === 180) {
+ return 'center';
+ } else if (angle < 180) {
+ return 'left';
+ }
+
+ return 'right';
+ }
+
+ function fillText(ctx, text, position, fontSize) {
+ if (helpers.isArray(text)) {
+ var y = position.y;
+ var spacing = 1.5 * fontSize;
+
+ for (var i = 0; i < text.length; ++i) {
+ ctx.fillText(text[i], position.x, y);
+ y+= spacing;
+ }
+ } else {
+ ctx.fillText(text, position.x, position.y);
+ }
+ }
+
+ function adjustPointPositionForLabelHeight(angle, textSize, position) {
+ if (angle === 90 || angle === 270) {
+ position.y -= (textSize.h / 2);
+ } else if (angle > 270 || angle < 90) {
+ position.y -= textSize.h;
+ }
+ }
+
+ function drawPointLabels(scale) {
+ var ctx = scale.ctx;
+ var getValueOrDefault = helpers.getValueOrDefault;
+ var opts = scale.options;
+ var angleLineOpts = opts.angleLines;
+ var pointLabelOpts = opts.pointLabels;
+
+ ctx.lineWidth = angleLineOpts.lineWidth;
+ ctx.strokeStyle = angleLineOpts.color;
+
+ var outerDistance = scale.getDistanceFromCenterForValue(opts.reverse ? scale.min : scale.max);
+
+ // Point Label Font
+ var plFont = getPointLabelFontOptions(scale);
+
+ ctx.textBaseline = 'top';
+
+ for (var i = getValueCount(scale) - 1; i >= 0; i--) {
+ if (angleLineOpts.display) {
+ var outerPosition = scale.getPointPosition(i, outerDistance);
+ ctx.beginPath();
+ ctx.moveTo(scale.xCenter, scale.yCenter);
+ ctx.lineTo(outerPosition.x, outerPosition.y);
+ ctx.stroke();
+ ctx.closePath();
+ }
+ // Extra 3px out for some label spacing
+ var pointLabelPosition = scale.getPointPosition(i, outerDistance + 5);
+
+ // Keep this in loop since we may support array properties here
+ var pointLabelFontColor = getValueOrDefault(pointLabelOpts.fontColor, globalDefaults.defaultFontColor);
+ ctx.font = plFont.font;
+ ctx.fillStyle = pointLabelFontColor;
+
+ var angleRadians = scale.getIndexAngle(i);
+ var angle = helpers.toDegrees(angleRadians);
+ ctx.textAlign = getTextAlignForAngle(angle);
+ adjustPointPositionForLabelHeight(angle, scale._pointLabelSizes[i], pointLabelPosition);
+ fillText(ctx, scale.pointLabels[i] || '', pointLabelPosition, plFont.size);
+ }
+ }
+
+ function drawRadiusLine(scale, gridLineOpts, radius, index) {
+ var ctx = scale.ctx;
+ ctx.strokeStyle = helpers.getValueAtIndexOrDefault(gridLineOpts.color, index - 1);
+ ctx.lineWidth = helpers.getValueAtIndexOrDefault(gridLineOpts.lineWidth, index - 1);
+
+ if (scale.options.lineArc) {
+ // Draw circular arcs between the points
+ ctx.beginPath();
+ ctx.arc(scale.xCenter, scale.yCenter, radius, 0, Math.PI * 2);
+ ctx.closePath();
+ ctx.stroke();
+ } else {
+ // Draw straight lines connecting each index
+ var valueCount = getValueCount(scale);
+
+ if (valueCount === 0) {
+ return;
+ }
+
+ ctx.beginPath();
+ var pointPosition = scale.getPointPosition(0, radius);
+ ctx.moveTo(pointPosition.x, pointPosition.y);
+
+ for (var i = 1; i < valueCount; i++) {
+ pointPosition = scale.getPointPosition(i, radius);
+ ctx.lineTo(pointPosition.x, pointPosition.y);
+ }
+
+ ctx.closePath();
+ ctx.stroke();
+ }
+ }
+
+ function numberOrZero(param) {
+ return helpers.isNumber(param) ? param : 0;
+ }
+
var LinearRadialScale = Chart.LinearScaleBase.extend({
- getValueCount: function() {
- return this.chart.data.labels.length;
- },
setDimensions: function() {
var me = this;
var opts = me.options;
@@ -68,9 +324,8 @@ module.exports = function(Chart) {
determineDataLimits: function() {
var me = this;
var chart = me.chart;
- me.min = null;
- me.max = null;
-
+ var min = Number.POSITIVE_INFINITY;
+ var max = Number.NEGATIVE_INFINITY;
helpers.each(chart.data.datasets, function(dataset, datasetIndex) {
if (chart.isDatasetVisible(datasetIndex)) {
@@ -82,21 +337,15 @@ module.exports = function(Chart) {
return;
}
- if (me.min === null) {
- me.min = value;
- } else if (value < me.min) {
- me.min = value;
- }
-
- if (me.max === null) {
- me.max = value;
- } else if (value > me.max) {
- me.max = value;
- }
+ min = Math.min(value, min);
+ max = Math.max(value, max);
});
}
});
+ me.min = (min === Number.POSITIVE_INFINITY ? 0 : min);
+ me.max = (max === Number.NEGATIVE_INFINITY ? 0 : max);
+
// Common base implementation to handle ticks.min, ticks.max, ticks.beginAtZero
me.handleTickRangeOptions();
},
@@ -116,130 +365,54 @@ module.exports = function(Chart) {
return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
},
fit: function() {
- /*
- * Right, this is really confusing and there is a lot of maths going on here
- * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
- *
- * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
- *
- * Solution:
- *
- * We assume the radius of the polygon is half the size of the canvas at first
- * at each index we check if the text overlaps.
- *
- * Where it does, we store that angle and that index.
- *
- * After finding the largest index and angle we calculate how much we need to remove
- * from the shape radius to move the point inwards by that x.
- *
- * We average the left and right distances to get the maximum shape radius that can fit in the box
- * along with labels.
- *
- * Once we have that, we can find the centre point for the chart, by taking the x text protrusion
- * on each side, removing that from the size, halving it and adding the left x protrusion width.
- *
- * This will mean we have a shape fitted to the canvas, as large as it can be with the labels
- * and position it in the most space efficient manner
- *
- * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif
- */
-
- var pointLabels = this.options.pointLabels;
- var pointLabelFontSize = helpers.getValueOrDefault(pointLabels.fontSize, globalDefaults.defaultFontSize);
- var pointLabeFontStyle = helpers.getValueOrDefault(pointLabels.fontStyle, globalDefaults.defaultFontStyle);
- var pointLabeFontFamily = helpers.getValueOrDefault(pointLabels.fontFamily, globalDefaults.defaultFontFamily);
- var pointLabeFont = helpers.fontString(pointLabelFontSize, pointLabeFontStyle, pointLabeFontFamily);
-
- // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width.
- // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points
- var largestPossibleRadius = helpers.min([(this.height / 2 - pointLabelFontSize - 5), this.width / 2]),
- pointPosition,
- i,
- textWidth,
- halfTextWidth,
- furthestRight = this.width,
- furthestRightIndex,
- furthestRightAngle,
- furthestLeft = 0,
- furthestLeftIndex,
- furthestLeftAngle,
- xProtrusionLeft,
- xProtrusionRight,
- radiusReductionRight,
- radiusReductionLeft;
- this.ctx.font = pointLabeFont;
-
- for (i = 0; i < this.getValueCount(); i++) {
- // 5px to space the text slightly out - similar to what we do in the draw function.
- pointPosition = this.getPointPosition(i, largestPossibleRadius);
- textWidth = this.ctx.measureText(this.pointLabels[i] ? this.pointLabels[i] : '').width + 5;
-
- // Add quarter circle to make degree 0 mean top of circle
- var angleRadians = this.getIndexAngle(i) + (Math.PI / 2);
- var angle = (angleRadians * 360 / (2 * Math.PI)) % 360;
-
- if (angle === 0 || angle === 180) {
- // At angle 0 and 180, we're at exactly the top/bottom
- // of the radar chart, so text will be aligned centrally, so we'll half it and compare
- // w/left and right text sizes
- halfTextWidth = textWidth / 2;
- if (pointPosition.x + halfTextWidth > furthestRight) {
- furthestRight = pointPosition.x + halfTextWidth;
- furthestRightIndex = i;
- }
- if (pointPosition.x - halfTextWidth < furthestLeft) {
- furthestLeft = pointPosition.x - halfTextWidth;
- furthestLeftIndex = i;
- }
- } else if (angle < 180) {
- // Less than half the values means we'll left align the text
- if (pointPosition.x + textWidth > furthestRight) {
- furthestRight = pointPosition.x + textWidth;
- furthestRightIndex = i;
- }
- // More than half the values means we'll right align the text
- } else if (pointPosition.x - textWidth < furthestLeft) {
- furthestLeft = pointPosition.x - textWidth;
- furthestLeftIndex = i;
- }
+ if (this.options.lineArc) {
+ fit(this);
+ } else {
+ fitWithPointLabels(this);
}
-
- xProtrusionLeft = furthestLeft;
- xProtrusionRight = Math.ceil(furthestRight - this.width);
-
- furthestRightAngle = this.getIndexAngle(furthestRightIndex);
- furthestLeftAngle = this.getIndexAngle(furthestLeftIndex);
-
- radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2);
- radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2);
-
- // Ensure we actually need to reduce the size of the chart
- radiusReductionRight = (helpers.isNumber(radiusReductionRight)) ? radiusReductionRight : 0;
- radiusReductionLeft = (helpers.isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0;
-
- this.drawingArea = Math.round(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2);
- this.setCenterPoint(radiusReductionLeft, radiusReductionRight);
},
- setCenterPoint: function(leftMovement, rightMovement) {
+ /**
+ * Set radius reductions and determine new radius and center point
+ * @private
+ */
+ setReductions: function(largestPossibleRadius, furthestLimits, furthestAngles) {
+ var me = this;
+ var radiusReductionLeft = furthestLimits.l / Math.sin(furthestAngles.l);
+ var radiusReductionRight = Math.max(furthestLimits.r - me.width, 0) / Math.sin(furthestAngles.r);
+ var radiusReductionTop = -furthestLimits.t / Math.cos(furthestAngles.t);
+ var radiusReductionBottom = -Math.max(furthestLimits.b - me.height, 0) / Math.cos(furthestAngles.b);
+
+ radiusReductionLeft = numberOrZero(radiusReductionLeft);
+ radiusReductionRight = numberOrZero(radiusReductionRight);
+ radiusReductionTop = numberOrZero(radiusReductionTop);
+ radiusReductionBottom = numberOrZero(radiusReductionBottom);
+
+ me.drawingArea = Math.min(
+ Math.round(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2),
+ Math.round(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2));
+ me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReductionTop, radiusReductionBottom);
+ },
+ setCenterPoint: function(leftMovement, rightMovement, topMovement, bottomMovement) {
var me = this;
var maxRight = me.width - rightMovement - me.drawingArea,
- maxLeft = leftMovement + me.drawingArea;
+ maxLeft = leftMovement + me.drawingArea,
+ maxTop = topMovement + me.drawingArea,
+ maxBottom = me.height - bottomMovement - me.drawingArea;
me.xCenter = Math.round(((maxLeft + maxRight) / 2) + me.left);
- // Always vertically in the centre as the text height doesn't change
- me.yCenter = Math.round((me.height / 2) + me.top);
+ me.yCenter = Math.round(((maxTop + maxBottom) / 2) + me.top);
},
getIndexAngle: function(index) {
- var angleMultiplier = (Math.PI * 2) / this.getValueCount();
+ var angleMultiplier = (Math.PI * 2) / getValueCount(this);
var startAngle = this.chart.options && this.chart.options.startAngle ?
this.chart.options.startAngle :
0;
var startAngleRadians = startAngle * Math.PI * 2 / 360;
// Start from the top instead of right, so remove a quarter of the circle
- return index * angleMultiplier - (Math.PI / 2) + startAngleRadians;
+ return index * angleMultiplier + startAngleRadians;
},
getDistanceFromCenterForValue: function(value) {
var me = this;
@@ -257,7 +430,7 @@ module.exports = function(Chart) {
},
getPointPosition: function(index, distanceFromCenter) {
var me = this;
- var thisAngle = me.getIndexAngle(index);
+ var thisAngle = me.getIndexAngle(index) - (Math.PI / 2);
return {
x: Math.round(Math.cos(thisAngle) * distanceFromCenter) + me.xCenter,
y: Math.round(Math.sin(thisAngle) * distanceFromCenter) + me.yCenter
@@ -284,8 +457,6 @@ module.exports = function(Chart) {
var opts = me.options;
var gridLineOpts = opts.gridLines;
var tickOpts = opts.ticks;
- var angleLineOpts = opts.angleLines;
- var pointLabelOpts = opts.pointLabels;
var getValueOrDefault = helpers.getValueOrDefault;
if (opts.display) {
@@ -305,29 +476,7 @@ module.exports = function(Chart) {
// Draw circular lines around the scale
if (gridLineOpts.display && index !== 0) {
- ctx.strokeStyle = helpers.getValueAtIndexOrDefault(gridLineOpts.color, index - 1);
- ctx.lineWidth = helpers.getValueAtIndexOrDefault(gridLineOpts.lineWidth, index - 1);
-
- if (opts.lineArc) {
- // Draw circular arcs between the points
- ctx.beginPath();
- ctx.arc(me.xCenter, me.yCenter, yCenterOffset, 0, Math.PI * 2);
- ctx.closePath();
- ctx.stroke();
- } else {
- // Draw straight lines connecting each index
- ctx.beginPath();
- for (var i = 0; i < me.getValueCount(); i++) {
- var pointPosition = me.getPointPosition(i, yCenterOffset);
- if (i === 0) {
- ctx.moveTo(pointPosition.x, pointPosition.y);
- } else {
- ctx.lineTo(pointPosition.x, pointPosition.y);
- }
- }
- ctx.closePath();
- ctx.stroke();
- }
+ drawRadiusLine(me, gridLineOpts, yCenterOffset, index);
}
if (tickOpts.display) {
@@ -354,59 +503,7 @@ module.exports = function(Chart) {
});
if (!opts.lineArc) {
- ctx.lineWidth = angleLineOpts.lineWidth;
- ctx.strokeStyle = angleLineOpts.color;
-
- var outerDistance = me.getDistanceFromCenterForValue(opts.reverse ? me.min : me.max);
-
- // Point Label Font
- var pointLabelFontSize = getValueOrDefault(pointLabelOpts.fontSize, globalDefaults.defaultFontSize);
- var pointLabeFontStyle = getValueOrDefault(pointLabelOpts.fontStyle, globalDefaults.defaultFontStyle);
- var pointLabeFontFamily = getValueOrDefault(pointLabelOpts.fontFamily, globalDefaults.defaultFontFamily);
- var pointLabeFont = helpers.fontString(pointLabelFontSize, pointLabeFontStyle, pointLabeFontFamily);
-
- for (var i = me.getValueCount() - 1; i >= 0; i--) {
- if (angleLineOpts.display) {
- var outerPosition = me.getPointPosition(i, outerDistance);
- ctx.beginPath();
- ctx.moveTo(me.xCenter, me.yCenter);
- ctx.lineTo(outerPosition.x, outerPosition.y);
- ctx.stroke();
- ctx.closePath();
- }
- // Extra 3px out for some label spacing
- var pointLabelPosition = me.getPointPosition(i, outerDistance + 5);
-
- // Keep this in loop since we may support array properties here
- var pointLabelFontColor = getValueOrDefault(pointLabelOpts.fontColor, globalDefaults.defaultFontColor);
- ctx.font = pointLabeFont;
- ctx.fillStyle = pointLabelFontColor;
-
- var pointLabels = me.pointLabels;
-
- // Add quarter circle to make degree 0 mean top of circle
- var angleRadians = this.getIndexAngle(i) + (Math.PI / 2);
- var angle = (angleRadians * 360 / (2 * Math.PI)) % 360;
-
- if (angle === 0 || angle === 180) {
- ctx.textAlign = 'center';
- } else if (angle < 180) {
- ctx.textAlign = 'left';
- } else {
- ctx.textAlign = 'right';
- }
-
- // Set the correct text baseline based on outer positioning
- if (angle === 90 || angle === 270) {
- ctx.textBaseline = 'middle';
- } else if (angle > 270 || angle < 90) {
- ctx.textBaseline = 'bottom';
- } else {
- ctx.textBaseline = 'top';
- }
-
- ctx.fillText(pointLabels[i] ? pointLabels[i] : '', pointLabelPosition.x, pointLabelPosition.y);
- }
+ drawPointLabels(me);
}
}
} | true |
Other | chartjs | Chart.js | 7e5e29e3ee15100de599124b4951d50f3aad5f57.json | Improve radial scale (#3625)
Clean up radial linear scale. It now supports multiple lines for point labels. Fixes #3225 | test/controller.polarArea.tests.js | @@ -96,9 +96,9 @@ describe('Polar area controller tests', function() {
expect(meta.data.length).toBe(4);
[
- {o: 156, s: -0.5 * Math.PI, e: 0},
- {o: 211, s: 0, e: 0.5 * Math.PI},
- {o: 45, s: 0.5 * Math.PI, e: Math.PI},
+ {o: 168, s: -0.5 * Math.PI, e: 0},
+ {o: 228, s: 0, e: 0.5 * Math.PI},
+ {o: 48, s: 0.5 * Math.PI, e: Math.PI},
{o: 0, s: Math.PI, e: 1.5 * Math.PI}
].forEach(function(expected, i) {
expect(meta.data[i]._model.x).toBeCloseToPixel(256);
@@ -140,7 +140,7 @@ describe('Polar area controller tests', function() {
expect(meta.data[0]._model.x).toBeCloseToPixel(256);
expect(meta.data[0]._model.y).toBeCloseToPixel(272);
expect(meta.data[0]._model.innerRadius).toBeCloseToPixel(0);
- expect(meta.data[0]._model.outerRadius).toBeCloseToPixel(156);
+ expect(meta.data[0]._model.outerRadius).toBeCloseToPixel(168);
expect(meta.data[0]._model).toEqual(jasmine.objectContaining({
startAngle: -0.5 * Math.PI,
endAngle: 0,
@@ -178,9 +178,9 @@ describe('Polar area controller tests', function() {
expect(meta.data.length).toBe(4);
[
- {o: 156, s: 0, e: 0.5 * Math.PI},
- {o: 211, s: 0.5 * Math.PI, e: Math.PI},
- {o: 45, s: Math.PI, e: 1.5 * Math.PI},
+ {o: 168, s: 0, e: 0.5 * Math.PI},
+ {o: 228, s: 0.5 * Math.PI, e: Math.PI},
+ {o: 48, s: Math.PI, e: 1.5 * Math.PI},
{o: 0, s: 1.5 * Math.PI, e: 2.0 * Math.PI}
].forEach(function(expected, i) {
expect(meta.data[i]._model.x).toBeCloseToPixel(256); | true |
Other | chartjs | Chart.js | 7e5e29e3ee15100de599124b4951d50f3aad5f57.json | Improve radial scale (#3625)
Clean up radial linear scale. It now supports multiple lines for point labels. Fixes #3225 | test/scale.radialLinear.tests.js | @@ -342,9 +342,9 @@ describe('Test the radial linear scale', function() {
}
});
- expect(chart.scale.drawingArea).toBe(225);
- expect(chart.scale.xCenter).toBe(256);
- expect(chart.scale.yCenter).toBe(272);
+ expect(chart.scale.drawingArea).toBe(233);
+ expect(chart.scale.xCenter).toBe(247);
+ expect(chart.scale.yCenter).toBe(280);
});
it('should correctly get the label for a given data index', function() {
@@ -390,16 +390,16 @@ describe('Test the radial linear scale', function() {
});
expect(chart.scale.getDistanceFromCenterForValue(chart.scale.min)).toBe(0);
- expect(chart.scale.getDistanceFromCenterForValue(chart.scale.max)).toBe(225);
+ expect(chart.scale.getDistanceFromCenterForValue(chart.scale.max)).toBe(233);
expect(chart.scale.getPointPositionForValue(1, 5)).toEqual({
- x: 269,
- y: 268,
+ x: 261,
+ y: 275,
});
chart.scale.options.reverse = true;
chart.update();
- expect(chart.scale.getDistanceFromCenterForValue(chart.scale.min)).toBe(225);
+ expect(chart.scale.getDistanceFromCenterForValue(chart.scale.min)).toBe(233);
expect(chart.scale.getDistanceFromCenterForValue(chart.scale.max)).toBe(0);
});
@@ -431,14 +431,14 @@ describe('Test the radial linear scale', function() {
var slice = 72; // (360 / 5)
for (var i = 0; i < 5; i++) {
- expect(radToNearestDegree(chart.scale.getIndexAngle(i))).toBe(15 + (slice * i) - 90);
+ expect(radToNearestDegree(chart.scale.getIndexAngle(i))).toBe(15 + (slice * i));
}
chart.options.startAngle = 0;
chart.update();
for (var x = 0; x < 5; x++) {
- expect(radToNearestDegree(chart.scale.getIndexAngle(x))).toBe((slice * x) - 90);
+ expect(radToNearestDegree(chart.scale.getIndexAngle(x))).toBe((slice * x));
}
});
}); | true |
Other | chartjs | Chart.js | 5dd1c77cf51adda1055c2eabb9f064b8ed5ee5ff.json | Take vertical padding into account | src/core/core.layoutService.js | @@ -154,9 +154,11 @@ module.exports = function(Chart) {
helpers.each(leftBoxes.concat(rightBoxes, topBoxes, bottomBoxes), getMinimumBoxSize);
- // If a box has padding, we move the left scale over to avoid ugly charts (see issue #2478)
+ // If a horizontal box has padding, we move the left boxes over to avoid ugly charts (see issue #2478)
var maxHorizontalLeftPadding = 0;
var maxHorizontalRightPadding = 0;
+ var maxVerticalTopPadding = 0;
+ var maxVerticalBottomPadding = 0;
helpers.each(topBoxes.concat(bottomBoxes), function(horizontalBox) {
if (horizontalBox.getPadding) {
@@ -166,6 +168,14 @@ module.exports = function(Chart) {
}
});
+ helpers.each(leftBoxes.concat(rightBoxes), function(verticalBox) {
+ if (verticalBox.getPadding) {
+ var boxPadding = verticalBox.getPadding();
+ maxVerticalTopPadding = Math.max(maxVerticalTopPadding, boxPadding.top);
+ maxVerticalBottomPadding = Math.max(maxVerticalBottomPadding, boxPadding.bottom);
+ }
+ });
+
// At this point, maxChartAreaHeight and maxChartAreaWidth are the size the chart area could
// be if the axes are drawn at their minimum sizes.
// Steps 5 & 6
@@ -264,10 +274,12 @@ module.exports = function(Chart) {
// We may be adding some padding to account for rotated x axis labels
var leftPaddingAddition = Math.max(maxHorizontalLeftPadding - totalLeftBoxesWidth, 0);
- var rightPaddingAddition = Math.max(maxHorizontalRightPadding - totalRightBoxesWidth, 0);
-
totalLeftBoxesWidth += leftPaddingAddition;
- totalRightBoxesWidth += rightPaddingAddition;
+ totalRightBoxesWidth += Math.max(maxHorizontalRightPadding - totalRightBoxesWidth, 0);
+
+ var topPaddingAddition = Math.max(maxVerticalTopPadding - totalTopBoxesHeight, 0);
+ totalTopBoxesHeight += topPaddingAddition;
+ totalBottomBoxesHeight += Math.max(maxVerticalBottomPadding - totalBottomBoxesHeight, 0);
// Figure out if our chart area changed. This would occur if the dataset layout label rotation
// changed due to the application of the margins in step 6. Since we can only get bigger, this is safe to do
@@ -302,7 +314,7 @@ module.exports = function(Chart) {
// Step 7 - Position the boxes
var left = leftPadding + leftPaddingAddition;
- var top = topPadding;
+ var top = topPadding + topPaddingAddition;
function placeBox(box) {
if (box.isHorizontal()) { | true |
Other | chartjs | Chart.js | 5dd1c77cf51adda1055c2eabb9f064b8ed5ee5ff.json | Take vertical padding into account | src/core/core.scale.js | @@ -51,6 +51,12 @@ module.exports = function(Chart) {
};
Chart.Scale = Chart.Element.extend({
+ /**
+ * Get the padding needed for the scale
+ * @method getPadding
+ * @private
+ * @returns {Padding} the necessary padding
+ */
getPadding: function() {
var me = this;
return { | true |
Other | chartjs | Chart.js | 5dd1c77cf51adda1055c2eabb9f064b8ed5ee5ff.json | Take vertical padding into account | test/scale.logarithmic.tests.js | @@ -722,7 +722,7 @@ describe('Logarithmic Scale tests', function() {
expect(xScale.getPixelForValue(10, 0, 0)).toBeCloseToPixel(276); // halfway
expect(xScale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(48); // 0 is invalid, put it on the left.
- expect(xScale.getValueForPixel(481.5)).toBeCloseTo(80, 1e-4);
+ expect(xScale.getValueForPixel(481.5)).toBeCloseToPixel(80);
expect(xScale.getValueForPixel(48)).toBeCloseTo(1, 1e-4);
expect(xScale.getValueForPixel(276)).toBeCloseTo(10, 1e-4);
| true |
Other | chartjs | Chart.js | b95ba3d5c3c6a7a93a2a2a1b02f550b9c33a288e.json | Convert the easing helpers to typescript (#10627)
Co-authored-by: Chart.js <> | src/helpers/helpers.easing.js | @@ -1,122 +0,0 @@
-import {PI, TAU, HALF_PI} from './helpers.math';
-
-const atEdge = (t) => t === 0 || t === 1;
-const elasticIn = (t, s, p) => -(Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * TAU / p));
-const elasticOut = (t, s, p) => Math.pow(2, -10 * t) * Math.sin((t - s) * TAU / p) + 1;
-
-/**
- * Easing functions adapted from Robert Penner's easing equations.
- * @namespace Chart.helpers.easing.effects
- * @see http://www.robertpenner.com/easing/
- */
-const effects = {
- linear: t => t,
-
- easeInQuad: t => t * t,
-
- easeOutQuad: t => -t * (t - 2),
-
- easeInOutQuad: t => ((t /= 0.5) < 1)
- ? 0.5 * t * t
- : -0.5 * ((--t) * (t - 2) - 1),
-
- easeInCubic: t => t * t * t,
-
- easeOutCubic: t => (t -= 1) * t * t + 1,
-
- easeInOutCubic: t => ((t /= 0.5) < 1)
- ? 0.5 * t * t * t
- : 0.5 * ((t -= 2) * t * t + 2),
-
- easeInQuart: t => t * t * t * t,
-
- easeOutQuart: t => -((t -= 1) * t * t * t - 1),
-
- easeInOutQuart: t => ((t /= 0.5) < 1)
- ? 0.5 * t * t * t * t
- : -0.5 * ((t -= 2) * t * t * t - 2),
-
- easeInQuint: t => t * t * t * t * t,
-
- easeOutQuint: t => (t -= 1) * t * t * t * t + 1,
-
- easeInOutQuint: t => ((t /= 0.5) < 1)
- ? 0.5 * t * t * t * t * t
- : 0.5 * ((t -= 2) * t * t * t * t + 2),
-
- easeInSine: t => -Math.cos(t * HALF_PI) + 1,
-
- easeOutSine: t => Math.sin(t * HALF_PI),
-
- easeInOutSine: t => -0.5 * (Math.cos(PI * t) - 1),
-
- easeInExpo: t => (t === 0) ? 0 : Math.pow(2, 10 * (t - 1)),
-
- easeOutExpo: t => (t === 1) ? 1 : -Math.pow(2, -10 * t) + 1,
-
- easeInOutExpo: t => atEdge(t) ? t : t < 0.5
- ? 0.5 * Math.pow(2, 10 * (t * 2 - 1))
- : 0.5 * (-Math.pow(2, -10 * (t * 2 - 1)) + 2),
-
- easeInCirc: t => (t >= 1) ? t : -(Math.sqrt(1 - t * t) - 1),
-
- easeOutCirc: t => Math.sqrt(1 - (t -= 1) * t),
-
- easeInOutCirc: t => ((t /= 0.5) < 1)
- ? -0.5 * (Math.sqrt(1 - t * t) - 1)
- : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1),
-
- easeInElastic: t => atEdge(t) ? t : elasticIn(t, 0.075, 0.3),
-
- easeOutElastic: t => atEdge(t) ? t : elasticOut(t, 0.075, 0.3),
-
- easeInOutElastic(t) {
- const s = 0.1125;
- const p = 0.45;
- return atEdge(t) ? t :
- t < 0.5
- ? 0.5 * elasticIn(t * 2, s, p)
- : 0.5 + 0.5 * elasticOut(t * 2 - 1, s, p);
- },
-
- easeInBack(t) {
- const s = 1.70158;
- return t * t * ((s + 1) * t - s);
- },
-
- easeOutBack(t) {
- const s = 1.70158;
- return (t -= 1) * t * ((s + 1) * t + s) + 1;
- },
-
- easeInOutBack(t) {
- let s = 1.70158;
- if ((t /= 0.5) < 1) {
- return 0.5 * (t * t * (((s *= (1.525)) + 1) * t - s));
- }
- return 0.5 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2);
- },
-
- easeInBounce: t => 1 - effects.easeOutBounce(1 - t),
-
- easeOutBounce(t) {
- const m = 7.5625;
- const d = 2.75;
- if (t < (1 / d)) {
- return m * t * t;
- }
- if (t < (2 / d)) {
- return m * (t -= (1.5 / d)) * t + 0.75;
- }
- if (t < (2.5 / d)) {
- return m * (t -= (2.25 / d)) * t + 0.9375;
- }
- return m * (t -= (2.625 / d)) * t + 0.984375;
- },
-
- easeInOutBounce: t => (t < 0.5)
- ? effects.easeInBounce(t * 2) * 0.5
- : effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5,
-};
-
-export default effects; | true |
Other | chartjs | Chart.js | b95ba3d5c3c6a7a93a2a2a1b02f550b9c33a288e.json | Convert the easing helpers to typescript (#10627)
Co-authored-by: Chart.js <> | src/helpers/helpers.easing.ts | @@ -0,0 +1,124 @@
+import {PI, TAU, HALF_PI} from './helpers.math';
+
+const atEdge = (t: number) => t === 0 || t === 1;
+const elasticIn = (t: number, s: number, p: number) => -(Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * TAU / p));
+const elasticOut = (t: number, s: number, p: number) => Math.pow(2, -10 * t) * Math.sin((t - s) * TAU / p) + 1;
+
+/**
+ * Easing functions adapted from Robert Penner's easing equations.
+ * @namespace Chart.helpers.easing.effects
+ * @see http://www.robertpenner.com/easing/
+ */
+const effects = {
+ linear: (t: number) => t,
+
+ easeInQuad: (t: number) => t * t,
+
+ easeOutQuad: (t: number) => -t * (t - 2),
+
+ easeInOutQuad: (t: number) => ((t /= 0.5) < 1)
+ ? 0.5 * t * t
+ : -0.5 * ((--t) * (t - 2) - 1),
+
+ easeInCubic: (t: number) => t * t * t,
+
+ easeOutCubic: (t: number) => (t -= 1) * t * t + 1,
+
+ easeInOutCubic: (t: number) => ((t /= 0.5) < 1)
+ ? 0.5 * t * t * t
+ : 0.5 * ((t -= 2) * t * t + 2),
+
+ easeInQuart: (t: number) => t * t * t * t,
+
+ easeOutQuart: (t: number) => -((t -= 1) * t * t * t - 1),
+
+ easeInOutQuart: (t: number) => ((t /= 0.5) < 1)
+ ? 0.5 * t * t * t * t
+ : -0.5 * ((t -= 2) * t * t * t - 2),
+
+ easeInQuint: (t: number) => t * t * t * t * t,
+
+ easeOutQuint: (t: number) => (t -= 1) * t * t * t * t + 1,
+
+ easeInOutQuint: (t: number) => ((t /= 0.5) < 1)
+ ? 0.5 * t * t * t * t * t
+ : 0.5 * ((t -= 2) * t * t * t * t + 2),
+
+ easeInSine: (t: number) => -Math.cos(t * HALF_PI) + 1,
+
+ easeOutSine: (t: number) => Math.sin(t * HALF_PI),
+
+ easeInOutSine: (t: number) => -0.5 * (Math.cos(PI * t) - 1),
+
+ easeInExpo: (t: number) => (t === 0) ? 0 : Math.pow(2, 10 * (t - 1)),
+
+ easeOutExpo: (t: number) => (t === 1) ? 1 : -Math.pow(2, -10 * t) + 1,
+
+ easeInOutExpo: (t: number) => atEdge(t) ? t : t < 0.5
+ ? 0.5 * Math.pow(2, 10 * (t * 2 - 1))
+ : 0.5 * (-Math.pow(2, -10 * (t * 2 - 1)) + 2),
+
+ easeInCirc: (t: number) => (t >= 1) ? t : -(Math.sqrt(1 - t * t) - 1),
+
+ easeOutCirc: (t: number) => Math.sqrt(1 - (t -= 1) * t),
+
+ easeInOutCirc: (t: number) => ((t /= 0.5) < 1)
+ ? -0.5 * (Math.sqrt(1 - t * t) - 1)
+ : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1),
+
+ easeInElastic: (t: number) => atEdge(t) ? t : elasticIn(t, 0.075, 0.3),
+
+ easeOutElastic: (t: number) => atEdge(t) ? t : elasticOut(t, 0.075, 0.3),
+
+ easeInOutElastic(t: number) {
+ const s = 0.1125;
+ const p = 0.45;
+ return atEdge(t) ? t :
+ t < 0.5
+ ? 0.5 * elasticIn(t * 2, s, p)
+ : 0.5 + 0.5 * elasticOut(t * 2 - 1, s, p);
+ },
+
+ easeInBack(t: number) {
+ const s = 1.70158;
+ return t * t * ((s + 1) * t - s);
+ },
+
+ easeOutBack(t: number) {
+ const s = 1.70158;
+ return (t -= 1) * t * ((s + 1) * t + s) + 1;
+ },
+
+ easeInOutBack(t: number) {
+ let s = 1.70158;
+ if ((t /= 0.5) < 1) {
+ return 0.5 * (t * t * (((s *= (1.525)) + 1) * t - s));
+ }
+ return 0.5 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2);
+ },
+
+ easeInBounce: (t: number) => 1 - effects.easeOutBounce(1 - t),
+
+ easeOutBounce(t: number) {
+ const m = 7.5625;
+ const d = 2.75;
+ if (t < (1 / d)) {
+ return m * t * t;
+ }
+ if (t < (2 / d)) {
+ return m * (t -= (1.5 / d)) * t + 0.75;
+ }
+ if (t < (2.5 / d)) {
+ return m * (t -= (2.25 / d)) * t + 0.9375;
+ }
+ return m * (t -= (2.625 / d)) * t + 0.984375;
+ },
+
+ easeInOutBounce: (t: number) => (t < 0.5)
+ ? effects.easeInBounce(t * 2) * 0.5
+ : effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5,
+} as const;
+
+export type EasingFunction = keyof typeof effects
+
+export default effects; | true |
Other | chartjs | Chart.js | b95ba3d5c3c6a7a93a2a2a1b02f550b9c33a288e.json | Convert the easing helpers to typescript (#10627)
Co-authored-by: Chart.js <> | src/helpers/types.ts | @@ -5,4 +5,5 @@
// export * from '.';
export * from './helpers.core';
+export * from './helpers.easing';
export * from '../../types/helpers'; | true |
Other | chartjs | Chart.js | b95ba3d5c3c6a7a93a2a2a1b02f550b9c33a288e.json | Convert the easing helpers to typescript (#10627)
Co-authored-by: Chart.js <> | types/helpers/helpers.easing.d.ts | @@ -1,5 +0,0 @@
-import { EasingFunction } from '..';
-
-export type EasingFunctionSignature = (t: number) => number;
-
-export declare const easingEffects: Record<EasingFunction, EasingFunctionSignature>; | true |
Other | chartjs | Chart.js | b95ba3d5c3c6a7a93a2a2a1b02f550b9c33a288e.json | Convert the easing helpers to typescript (#10627)
Co-authored-by: Chart.js <> | types/index.d.ts | @@ -1,13 +1,15 @@
import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils';
import { TimeUnit } from '../src/core/core.adapters';
+import { EasingFunction } from '../src/helpers/helpers.easing';
import { AnimationEvent } from './animation';
import { AnyObject, EmptyObject } from './basic';
import { Color } from './color';
import Element from '../src/core/core.element';
import { ChartArea, Padding, Point } from './geometric';
import { LayoutItem, LayoutPosition } from './layout';
+export { EasingFunction } from '../src/helpers/helpers.easing';
export { Animation, Animations, Animator, AnimationEvent } from './animation';
export { Color } from './color';
export { ChartArea, Point } from './geometric';
@@ -1528,39 +1530,6 @@ export interface CoreChartOptions<TType extends ChartType> extends ParsingOption
}>;
}
-export type EasingFunction =
- | 'linear'
- | 'easeInQuad'
- | 'easeOutQuad'
- | 'easeInOutQuad'
- | 'easeInCubic'
- | 'easeOutCubic'
- | 'easeInOutCubic'
- | 'easeInQuart'
- | 'easeOutQuart'
- | 'easeInOutQuart'
- | 'easeInQuint'
- | 'easeOutQuint'
- | 'easeInOutQuint'
- | 'easeInSine'
- | 'easeOutSine'
- | 'easeInOutSine'
- | 'easeInExpo'
- | 'easeOutExpo'
- | 'easeInOutExpo'
- | 'easeInCirc'
- | 'easeOutCirc'
- | 'easeInOutCirc'
- | 'easeInElastic'
- | 'easeOutElastic'
- | 'easeInOutElastic'
- | 'easeInBack'
- | 'easeOutBack'
- | 'easeInOutBack'
- | 'easeInBounce'
- | 'easeOutBounce'
- | 'easeInOutBounce';
-
export type AnimationSpec<TType extends ChartType> = {
/**
* The number of milliseconds an animation takes. | true |
Other | chartjs | Chart.js | 74f50df250ba08c47d90c53bc2d590c43d9c95fe.json | Fix broken link (#10640) | docs/configuration/index.md | @@ -23,7 +23,7 @@ Chart type determines the main type of the chart.
### data
-See [Data Structures](../general/data-structures) for details.
+See [Data Structures](../general/data-structures.md) for details.
### options
| false |
Other | chartjs | Chart.js | b0a06d1652888d2491e99a8f658e447461771acf.json | fix filter paramater in package.json (#10614) | package.json | @@ -45,8 +45,8 @@
"build": "rollup -c && npm run emitDeclarations",
"dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome --grep",
"dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox --grep",
- "docs": "pnpm run build && pnpm --filter './docs/**' build",
- "docs:dev": "pnpm run build && pnpm --filter './docs/**' dev",
+ "docs": "pnpm run build && pnpm --filter \"./docs/**\" build",
+ "docs:dev": "pnpm run build && pnpm --filter \"./docs/**\" dev",
"lint-js": "eslint \"src/**/*.{js,ts}\" \"test/**/*.js\" \"docs/**/*.js\"",
"lint-md": "eslint \"**/*.md\"",
"lint-types": "eslint \"types/**/*.ts\" && pnpm run build && node types/tests/autogen.js && tsc -p types/tests/",
@@ -55,7 +55,7 @@
"test": "pnpm lint && pnpm test-ci",
"test-ci": "concurrently \"pnpm:test-ci-*\"",
"test-ci-karma": "cross-env NODE_ENV=test karma start ./karma.conf.cjs --auto-watch --single-run --coverage --grep",
- "test-ci-integration": "pnpm --filter './test/integration/**' test"
+ "test-ci-integration": "pnpm --filter \"./test/integration/**\" test"
},
"devDependencies": {
"@kurkle/color": "^0.2.1", | false |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | docs/axes/_common.md | @@ -7,6 +7,7 @@ Namespace: `options.scales[scaleId]`
| `type` | `string` | | Type of scale being employed. Custom scales can be created and registered with a string key. This allows changing the type of an axis for a chart.
| `alignToPixels` | `boolean` | `false` | Align pixel values to device pixels.
| `backgroundColor` | [`Color`](/general/colors.md) | | Background color of the scale area.
+| `border` | `object` | | Border configuration. [more...](/axes/styling.md#border-configuration)
| `display` | `boolean`\|`string` | `true` | Controls the axis global visibility (visible when `true`, hidden when `false`). When `display: 'auto'`, the axis is visible only if at least one associated dataset is visible.
| `grid` | `object` | | Grid line configuration. [more...](/axes/styling.md#grid-line-configuration)
| `min` | `number` | | User defined minimum number for the scale, overrides minimum value from data. [more...](/axes/index.md#axis-range-settings) | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | docs/axes/styling.md | @@ -8,14 +8,9 @@ Namespace: `options.scales[scaleId].grid`, it defines options for the grid lines
| Name | Type | Scriptable | Indexable | Default | Description
| ---- | ---- | :-------------------------------: | :-----------------------------: | ------- | -----------
-| `borderColor` | [`Color`](../general/colors.md) | | | `Chart.defaults.borderColor` | The color of the border line.
-| `borderWidth` | `number` | | | `1` | The width of the border line.
-| `borderDash` | `number[]` | Yes | | `[]` | Length and spacing of dashes on grid lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
-| `borderDashOffset` | `number` | Yes | | `0.0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
| `circular` | `boolean` | | | `false` | If true, gridlines are circular (on radar and polar area charts only).
| `color` | [`Color`](../general/colors.md) | Yes | Yes | `Chart.defaults.borderColor` | The color of the grid lines. If specified as an array, the first color applies to the first grid line, the second to the second grid line, and so on.
| `display` | `boolean` | | | `true` | If false, do not display grid lines for this axis.
-| `drawBorder` | `boolean` | | | `true` | If true, draw a border at the edge between the axis and the chart area.
| `drawOnChartArea` | `boolean` | | | `true` | If true, draw lines on the chart area inside the axis lines. This is useful when there are multiple axes and you need to control which grid lines are drawn.
| `drawTicks` | `boolean` | | | `true` | If true, draw lines beside the ticks in the axis area beside the chart.
| `lineWidth` | `number` | Yes | Yes | `1` | Stroke width of grid lines.
@@ -25,7 +20,7 @@ Namespace: `options.scales[scaleId].grid`, it defines options for the grid lines
| `tickColor` | [`Color`](../general/colors.md) | Yes | Yes | | Color of the tick line. If unset, defaults to the grid line color.
| `tickLength` | `number` | | | `8` | Length in pixels that the grid lines will draw into the axis area.
| `tickWidth` | `number` | Yes | Yes | | Width of the tick mark in pixels. If unset, defaults to the grid line width.
-| `z` | `number` | | | `0` | z-index of gridline layer. Values <= 0 are drawn under datasets, > 0 on top.
+| `z` | `number` | | | `-1` | z-index of the gridline layer. Values <= 0 are drawn under datasets, > 0 on top.
The scriptable context is described in [Options](../general/options.md#tick) section.
@@ -42,3 +37,16 @@ Namespace: `options.scales[scaleId].ticks.major`, it defines options for the maj
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| `enabled` | `boolean` | `false` | If true, major ticks are generated. A major tick will affect autoskipping and `major` will be defined on ticks in the scriptable options context.
+
+## Border Configuration
+
+Namespace: `options.scales[scaleId].border`, it defines options for the border that run perpendicular to the axis.
+
+| Name | Type | Scriptable | Indexable | Default | Description
+| ---- | ---- | :-------------------------------: | :-----------------------------: | ------- | -----------
+| `display` | `boolean` | | | `true` | If true, draw a border at the edge between the axis and the chart area.
+| `color` | [`Color`](../general/colors.md) | | | `Chart.defaults.borderColor` | The color of the border line.
+| `width` | `number` | | | `1` | The width of the border line.
+| `dash` | `number[]` | Yes | | `[]` | Length and spacing of dashes on grid lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
+| `dashOffset` | `number` | Yes | | `0.0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
+| `z` | `number` | | | `0` | z-index of the border layer. Values <= 0 are drawn under datasets, > 0 on top. | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | docs/migration/v4-migration.md | @@ -17,6 +17,12 @@ A number of changes were made to the configuration options passed to the `Chart`
* The radialLinear grid indexable and scriptable options don't decrease the index of the specified grid line anymore.
* The `destroy` plugin hook has been removed and replaced with `afterDestroy`.
* Ticks callback on time scale now receives timestamp instead of a formatted label.
+* `scales[id].grid.drawBorder` has been renamed to `scales[id].border.display`.
+* `scales[id].grid.borderWidth` has been renamed to `scales[id].border.width`.
+* `scales[id].grid.borderColor` has been renamed to `scales[id].border.color`.
+* `scales[id].grid.borderDash` has been renamed to `scales[id].border.dash`.
+* `scales[id].grid.borderDashOffset` has been renamed to `scales[id].border.dashOffset`.
+* The z index for the border of a scale is now configurable instead of being 1 higher as the grid z index.
* Linear scales now add and subtracts `5%` of the max value to the range if the min and max are the same instead of `1`.
* If the tooltip callback returns `undefined`, then the default callback will be used.
| true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | docs/samples/scale-options/grid.md | @@ -61,16 +61,20 @@ const config = {
},
scales: {
x: {
+ border: {
+ display: BORDER
+ },
grid: {
display: DISPLAY,
- drawBorder: BORDER,
drawOnChartArea: CHART_AREA,
drawTicks: TICKS,
}
},
y: {
+ border: {
+ display: false
+ },
grid: {
- drawBorder: false,
color: function(context) {
if (context.tick.value > 0) {
return Utils.CHART_COLORS.green; | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | src/core/core.scale.defaults.js | @@ -26,16 +26,19 @@ export function applyScaleDefaults(defaults) {
grid: {
display: true,
lineWidth: 1,
- drawBorder: true,
drawOnChartArea: true,
drawTicks: true,
tickLength: 8,
tickWidth: (_ctx, options) => options.lineWidth,
tickColor: (_ctx, options) => options.color,
offset: false,
- borderDash: [],
- borderDashOffset: 0.0,
- borderWidth: 1
+ },
+
+ border: {
+ display: true,
+ dash: [],
+ dashOffset: 0.0,
+ width: 1
},
// scale title
@@ -80,13 +83,13 @@ export function applyScaleDefaults(defaults) {
defaults.route('scale.ticks', 'color', '', 'color');
defaults.route('scale.grid', 'color', '', 'borderColor');
- defaults.route('scale.grid', 'borderColor', '', 'borderColor');
+ defaults.route('scale.border', 'color', '', 'borderColor');
defaults.route('scale.title', 'color', '', 'color');
defaults.describe('scale', {
_fallback: false,
_scriptable: (name) => !name.startsWith('before') && !name.startsWith('after') && name !== 'callback' && name !== 'parser',
- _indexable: (name) => name !== 'borderDash' && name !== 'tickBorderDash',
+ _indexable: (name) => name !== 'borderDash' && name !== 'tickBorderDash' && name !== 'dash',
});
defaults.describe('scales', { | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | src/core/core.scale.js | @@ -1004,16 +1004,16 @@ export default class Scale extends Element {
const axis = this.axis;
const chart = this.chart;
const options = this.options;
- const {grid, position} = options;
+ const {grid, position, border} = options;
const offset = grid.offset;
const isHorizontal = this.isHorizontal();
const ticks = this.ticks;
const ticksLength = ticks.length + (offset ? 1 : 0);
const tl = getTickMarkLength(grid);
const items = [];
- const borderOpts = grid.setContext(this.getContext());
- const axisWidth = borderOpts.drawBorder ? borderOpts.borderWidth : 0;
+ const borderOpts = border.setContext(this.getContext());
+ const axisWidth = borderOpts.display ? borderOpts.width : 0;
const axisHalfWidth = axisWidth / 2;
const alignBorderValue = function(pixel) {
return _alignPixel(chart, pixel, axisWidth);
@@ -1076,12 +1076,14 @@ export default class Scale extends Element {
const limit = valueOrDefault(options.ticks.maxTicksLimit, ticksLength);
const step = Math.max(1, Math.ceil(ticksLength / limit));
for (i = 0; i < ticksLength; i += step) {
- const optsAtIndex = grid.setContext(this.getContext(i));
+ const context = this.getContext(i);
+ const optsAtIndex = grid.setContext(context);
+ const optsAtIndexBorder = border.setContext(context);
const lineWidth = optsAtIndex.lineWidth;
const lineColor = optsAtIndex.color;
- const borderDash = optsAtIndex.borderDash || [];
- const borderDashOffset = optsAtIndex.borderDashOffset;
+ const borderDash = optsAtIndexBorder.dash || [];
+ const borderDashOffset = optsAtIndexBorder.dashOffset;
const tickWidth = optsAtIndex.tickWidth;
const tickColor = optsAtIndex.tickColor;
@@ -1496,9 +1498,9 @@ export default class Scale extends Element {
* @protected
*/
drawBorder() {
- const {chart, ctx, options: {grid}} = this;
- const borderOpts = grid.setContext(this.getContext());
- const axisWidth = grid.drawBorder ? borderOpts.borderWidth : 0;
+ const {chart, ctx, options: {border, grid}} = this;
+ const borderOpts = border.setContext(this.getContext());
+ const axisWidth = border.display ? borderOpts.width : 0;
if (!axisWidth) {
return;
}
@@ -1516,8 +1518,8 @@ export default class Scale extends Element {
x1 = x2 = borderValue;
}
ctx.save();
- ctx.lineWidth = borderOpts.borderWidth;
- ctx.strokeStyle = borderOpts.borderColor;
+ ctx.lineWidth = borderOpts.width;
+ ctx.strokeStyle = borderOpts.color;
ctx.beginPath();
ctx.moveTo(x1, y1);
@@ -1622,6 +1624,7 @@ export default class Scale extends Element {
const opts = this.options;
const tz = opts.ticks && opts.ticks.z || 0;
const gz = valueOrDefault(opts.grid && opts.grid.z, -1);
+ const bz = valueOrDefault(opts.border && opts.border.z, 0);
if (!this._isVisible() || this.draw !== Scale.prototype.draw) {
// backward compatibility: draw has been overridden by custom scale
@@ -1641,7 +1644,7 @@ export default class Scale extends Element {
this.drawTitle();
}
}, {
- z: gz + 1, // TODO, v4 move border options to its own object and add z
+ z: bz,
draw: () => {
this.drawBorder();
} | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | src/scales/scale.radialLinear.js | @@ -264,7 +264,7 @@ function pathRadiusLine(scale, radius, circular, labelCount) {
}
}
-function drawRadiusLine(scale, gridLineOpts, radius, labelCount) {
+function drawRadiusLine(scale, gridLineOpts, radius, labelCount, borderOpts) {
const ctx = scale.ctx;
const circular = gridLineOpts.circular;
@@ -277,8 +277,8 @@ function drawRadiusLine(scale, gridLineOpts, radius, labelCount) {
ctx.save();
ctx.strokeStyle = color;
ctx.lineWidth = lineWidth;
- ctx.setLineDash(gridLineOpts.borderDash);
- ctx.lineDashOffset = gridLineOpts.borderDashOffset;
+ ctx.setLineDash(borderOpts.dash);
+ ctx.lineDashOffset = borderOpts.dashOffset;
ctx.beginPath();
pathRadiusLine(scale, radius, circular, labelCount);
@@ -527,7 +527,7 @@ export default class RadialLinearScale extends LinearScaleBase {
drawGrid() {
const ctx = this.ctx;
const opts = this.options;
- const {angleLines, grid} = opts;
+ const {angleLines, grid, border} = opts;
const labelCount = this._pointLabels.length;
let i, offset, position;
@@ -540,8 +540,11 @@ export default class RadialLinearScale extends LinearScaleBase {
this.ticks.forEach((tick, index) => {
if (index !== 0) {
offset = this.getDistanceFromCenterForValue(tick.value);
- const optsAtIndex = grid.setContext(this.getContext(index));
- drawRadiusLine(this, optsAtIndex, offset, labelCount);
+ const context = this.getContext(index);
+ const optsAtIndex = grid.setContext(context);
+ const optsAtIndexBorder = border.setContext(context);
+
+ drawRadiusLine(this, optsAtIndex, offset, labelCount, optsAtIndexBorder);
}
});
} | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.layouts/stacked-boxes-with-weight.js | @@ -19,8 +19,8 @@ module.exports = {
stackWeight: 2,
offset: true,
bounds: 'data',
- grid: {
- borderColor: 'red'
+ border: {
+ color: 'red'
},
ticks: {
autoSkip: false,
@@ -35,8 +35,8 @@ module.exports = {
stackWeight: 2,
offset: true,
bounds: 'data',
- grid: {
- borderColor: 'green'
+ border: {
+ color: 'green'
},
ticks: {
autoSkip: false,
@@ -51,8 +51,8 @@ module.exports = {
stackWeight: 6,
offset: true,
bounds: 'data',
- grid: {
- borderColor: 'blue'
+ border: {
+ color: 'blue'
},
ticks: {
autoSkip: false,
@@ -66,8 +66,8 @@ module.exports = {
stack: '1',
stackWeight: 2,
offset: true,
- grid: {
- borderColor: 'red'
+ border: {
+ color: 'red'
},
ticks: {
precision: 0
@@ -79,8 +79,8 @@ module.exports = {
stack: '1',
offset: true,
stackWeight: 2,
- grid: {
- borderColor: 'green'
+ border: {
+ color: 'green'
},
ticks: {
precision: 0
@@ -92,8 +92,8 @@ module.exports = {
stack: '1',
stackWeight: 3,
offset: true,
- grid: {
- borderColor: 'blue'
+ border: {
+ color: 'blue'
},
ticks: {
precision: 0 | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.layouts/stacked-boxes.js | @@ -18,8 +18,8 @@ module.exports = {
stack: '1',
offset: true,
bounds: 'data',
- grid: {
- borderColor: 'red'
+ border: {
+ color: 'red'
},
ticks: {
autoSkip: false,
@@ -33,8 +33,8 @@ module.exports = {
stack: '1',
offset: true,
bounds: 'data',
- grid: {
- borderColor: 'green'
+ border: {
+ color: 'green'
},
ticks: {
autoSkip: false,
@@ -48,8 +48,8 @@ module.exports = {
stack: '1',
offset: true,
bounds: 'data',
- grid: {
- borderColor: 'blue'
+ border: {
+ color: 'blue'
},
ticks: {
autoSkip: false,
@@ -62,8 +62,8 @@ module.exports = {
position: 'left',
stack: '1',
offset: true,
- grid: {
- borderColor: 'red'
+ border: {
+ color: 'red'
},
ticks: {
precision: 0
@@ -74,8 +74,8 @@ module.exports = {
position: 'left',
stack: '1',
offset: true,
- grid: {
- borderColor: 'green'
+ border: {
+ color: 'green'
},
ticks: {
precision: 0
@@ -86,8 +86,8 @@ module.exports = {
position: 'left',
stack: '1',
offset: true,
- grid: {
- borderColor: 'blue'
+ border: {
+ color: 'blue',
},
ticks: {
precision: 0 | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/border-behind-elements.js | @@ -22,18 +22,18 @@ module.exports = {
ticks: {
display: false
},
- grid: {
- borderColor: 'red',
- borderWidth: 5
+ border: {
+ color: 'red',
+ width: 5
}
},
x: {
ticks: {
display: false
},
- grid: {
- borderColor: 'red',
- borderWidth: 5
+ border: {
+ color: 'red',
+ width: 5
}
}
} | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/cartesian-axis-border-settings.json | @@ -22,12 +22,14 @@
"min": -100,
"max": 100,
"grid": {
- "borderColor": "blue",
- "borderWidth": 5,
"color": "red",
- "drawBorder": true,
"drawOnChartArea": false
},
+ "border": {
+ "display": true,
+ "color": "blue",
+ "width": 5
+ },
"ticks": {
"display": false
}
@@ -36,9 +38,11 @@
"axis": "y",
"min": -100,
"max": 100,
+ "border": {
+ "color": "red"
+ },
"grid": {
"color": "red",
- "borderColor": "red",
"drawOnChartArea": false
},
"ticks": { | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/grid/border-over-grid.js | @@ -7,9 +7,11 @@ module.exports = {
position: {y: 0},
min: -10,
max: 10,
+ border: {
+ color: 'black',
+ width: 5
+ },
grid: {
- borderColor: 'black',
- borderWidth: 5,
color: 'lightGray',
lineWidth: 3,
},
@@ -21,9 +23,11 @@ module.exports = {
position: {x: 0},
min: -10,
max: 10,
+ border: {
+ color: 'black',
+ width: 5
+ },
grid: {
- borderColor: 'black',
- borderWidth: 5,
color: 'lightGray',
lineWidth: 3,
}, | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/grid/colors.js | @@ -14,9 +14,11 @@ module.exports = {
ticks: {
display: false
},
+ border: {
+ color: 'blue',
+ width: 2,
+ },
grid: {
- borderColor: 'blue',
- borderWidth: 2,
color: 'green',
drawTicks: false,
}
@@ -25,9 +27,11 @@ module.exports = {
ticks: {
display: false
},
+ border: {
+ color: 'black',
+ width: 2,
+ },
grid: {
- borderColor: 'black',
- borderWidth: 2,
color: 'red',
drawTicks: false,
} | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/grid/scriptable-borderDash.js | @@ -7,8 +7,10 @@ module.exports = {
position: {y: 0},
min: -10,
max: 10,
+ border: {
+ dash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
+ },
grid: {
- borderDash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
color: 'lightGray',
lineWidth: 3,
},
@@ -20,8 +22,10 @@ module.exports = {
position: {x: 0},
min: -10,
max: 10,
+ border: {
+ dash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
+ },
grid: {
- borderDash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
color: 'lightGray',
lineWidth: 3,
}, | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/label-offset-vertical-axes.json | @@ -15,17 +15,21 @@
"display": false
},
"grid":{
- "display": false,
- "drawBorder": false
+ "display": false
+ },
+ "border": {
+ "display": false
}
},
"y": {
"ticks": {
"labelOffset": 25
},
+ "border": {
+ "display": false
+ },
"grid":{
- "display": false,
- "drawBorder": false
+ "display": false
}
}
} | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/tick-drawing.json | @@ -15,9 +15,11 @@
"ticks": {
"display": false
},
+ "border": {
+ "display": false
+ },
"grid":{
"drawOnChartArea": false,
- "drawBorder": false,
"color": "rgba(0, 0, 0, 1)"
}
},
@@ -27,9 +29,11 @@
"ticks": {
"display": false
},
+ "border": {
+ "display": false
+ },
"grid":{
"drawOnChartArea": false,
- "drawBorder": false,
"color": "rgba(0, 0, 0, 1)"
}
},
@@ -43,10 +47,12 @@
"ticks": {
"display": false
},
+ "border": {
+ "display": false
+ },
"grid":{
"offset": false,
"drawOnChartArea": false,
- "drawBorder": false,
"color": "rgba(0, 0, 0, 1)"
}
},
@@ -59,10 +65,12 @@
"ticks": {
"display": false
},
+ "border": {
+ "display": false
+ },
"grid":{
"offset": false,
"drawOnChartArea": false,
- "drawBorder": false,
"color": "rgba(0, 0, 0, 1)"
}
} | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/tick-override-styles.json | @@ -15,9 +15,12 @@
"ticks": {
"display": false
},
+
+ "border": {
+ "display": false
+ },
"grid":{
"drawOnChartArea": false,
- "drawBorder": false,
"color": "rgba(0, 0, 0, 1)",
"width": 1,
"tickColor": "rgba(255, 0, 0, 1)",
@@ -34,10 +37,12 @@
"ticks": {
"display": false
},
+ "border": {
+ "display": false
+ },
"grid":{
"offset": false,
"drawOnChartArea": false,
- "drawBorder": false,
"color": "rgba(0, 0, 0, 1)",
"tickColor": "rgba(255, 0, 0, 1)",
"tickWidth": 5 | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/x-axis-position-center.json | @@ -22,23 +22,28 @@
"axis": "x",
"min": -100,
"max": 100,
+ "border": {
+ "color": "red"
+ },
"grid": {
"color": "red",
- "borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
- "display": true
+ "display": true,
+ "color": "red"
}
},
"y": {
"position": "left",
"axis": "y",
"min": -100,
"max": 100,
+ "border": {
+ "color": "red"
+ },
"grid": {
"color": "red",
- "borderColor": "red",
"drawOnChartArea": false
},
"ticks": { | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/x-axis-position-dynamic.json | @@ -24,9 +24,11 @@
"axis": "x",
"min": -100,
"max": 100,
+ "border": {
+ "color": "red"
+ },
"grid": {
"color": "red",
- "borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
@@ -38,9 +40,11 @@
"axis": "y",
"min": -100,
"max": 100,
+ "border": {
+ "color": "red"
+ },
"grid": {
"color": "red",
- "borderColor": "red",
"drawOnChartArea": false
},
"ticks": { | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/y-axis-position-center.json | @@ -22,9 +22,11 @@
"axis": "x",
"min": -100,
"max": 100,
+ "border": {
+ "color": "red"
+ },
"grid": {
"color": "red",
- "borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
@@ -36,9 +38,11 @@
"axis": "y",
"min": -100,
"max": 100,
+ "border": {
+ "color": "red"
+ },
"grid": {
"color": "red",
- "borderColor": "red",
"drawOnChartArea": false
},
"ticks": { | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/core.scale/y-axis-position-dynamic.json | @@ -22,9 +22,11 @@
"axis": "x",
"min": -100,
"max": 100,
+ "border": {
+ "color": "red"
+ },
"grid": {
"color": "red",
- "borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
@@ -38,9 +40,11 @@
"axis": "y",
"min": -100,
"max": 100,
+ "border": {
+ "color": "red"
+ },
"grid": {
"color": "red",
- "borderColor": "red",
"drawOnChartArea": false
},
"ticks": { | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/scale.radialLinear/border-dash.json | @@ -10,9 +10,11 @@
"r": {
"grid": {
"color": "rgba(0, 0, 255, 0.5)",
- "lineWidth": 1,
- "borderDash": [4, 2],
- "borderDashOffset": 2
+ "lineWidth": 1
+ },
+ "border": {
+ "dash": [4, 2],
+ "dashOffset": 2
},
"angleLines": {
"color": "rgba(0, 0, 255, 0.5)", | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/scale.radialLinear/circular-border-dash.json | @@ -8,12 +8,14 @@
"responsive": false,
"scales": {
"r": {
+ "border": {
+ "dash": [4, 2],
+ "dashOffset": 2
+ },
"grid": {
"circular": true,
"color": "rgba(0, 0, 255, 0.5)",
- "lineWidth": 1,
- "borderDash": [4, 2],
- "borderDashOffset": 2
+ "lineWidth": 1
},
"angleLines": {
"color": "rgba(0, 0, 255, 0.5)", | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/fixtures/scale.timeseries/financial-daily.js | @@ -46,8 +46,8 @@ module.exports = {
},
y: {
type: 'linear',
- grid: {
- drawBorder: false
+ border: {
+ display: false
}
}
} | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/specs/scale.linear.tests.js | @@ -1119,7 +1119,9 @@ describe('Linear Scale', function() {
type: 'linear',
grid: {
drawTicks: false,
- drawBorder: false
+ },
+ border: {
+ display: false
},
title: {
display: false, | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | test/specs/scale.time.tests.js | @@ -1102,8 +1102,8 @@ describe('Time scale tests', function() {
},
y: {
type: 'linear',
- grid: {
- drawBorder: false
+ border: {
+ display: false
}
}
} | true |
Other | chartjs | Chart.js | 3eb947719e2ac9e3751bf85e262ccf3033649f3d.json | Put the border opts in own object (#10571)
* put borderOpts in own object
* document z option
* remove todo and change scaleId to id
* update some tests
* clean bit, remove console log
* fix failing test
* lint
* Remove comment | types/index.d.ts | @@ -2831,13 +2831,28 @@ export interface PluginChartOptions<TType extends ChartType> {
plugins: PluginOptionsByType<TType>;
}
+export interface BorderOptions {
+ /**
+ * @default true
+ */
+ display: boolean
+ /**
+ * @default []
+ */
+ dash: Scriptable<number[], ScriptableScaleContext>;
+ /**
+ * @default 0
+ */
+ dashOffset: Scriptable<number, ScriptableScaleContext>;
+ color: Color;
+ width: number;
+}
+
export interface GridLineOptions {
/**
* @default true
*/
display: boolean;
- borderColor: Color;
- borderWidth: number;
/**
* @default false
*/
@@ -2846,23 +2861,10 @@ export interface GridLineOptions {
* @default 'rgba(0, 0, 0, 0.1)'
*/
color: ScriptableAndArray<Color, ScriptableScaleContext>;
- /**
- * @default []
- */
- borderDash: Scriptable<number[], ScriptableScaleContext>;
- /**
- * @default 0
- */
- borderDashOffset: Scriptable<number, ScriptableScaleContext>;
/**
* @default 1
*/
lineWidth: ScriptableAndArray<number, ScriptableScaleContext>;
-
- /**
- * @default true
- */
- drawBorder: boolean;
/**
* @default true
*/
@@ -3092,6 +3094,8 @@ export interface CartesianScaleOptions extends CoreScaleOptions {
grid: GridLineOptions;
+ border: BorderOptions;
+
/** Options for the scale title. */
title: {
/** If true, displays the axis title. */ | true |
Other | chartjs | Chart.js | 49b16c967833534b6bad7b1f2b8a0df8f69368ad.json | Change react integration test to TS (#10605)
* switch to ts
* change web integration test to TS
* remove space
* lint things
* one more lint
* Add spaces | test/integration/node/package-lock.json | @@ -1,24 +0,0 @@
-{
- "name": "node",
- "lockfileVersion": 2,
- "requires": true,
- "packages": {
- "": {
- "dependencies": {
- "chart.js": "^3.8.2"
- }
- },
- "node_modules/chart.js": {
- "version": "3.8.2",
- "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.8.2.tgz",
- "integrity": "sha512-7rqSlHWMUKFyBDOJvmFGW2lxULtcwaPLegDjX/Nu5j6QybY+GCiQkEY+6cqHw62S5tcwXMD8Y+H5OBGoR7d+ZQ=="
- }
- },
- "dependencies": {
- "chart.js": {
- "version": "3.8.2",
- "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.8.2.tgz",
- "integrity": "sha512-7rqSlHWMUKFyBDOJvmFGW2lxULtcwaPLegDjX/Nu5j6QybY+GCiQkEY+6cqHw62S5tcwXMD8Y+H5OBGoR7d+ZQ=="
- }
- }
-} | true |
Other | chartjs | Chart.js | 49b16c967833534b6bad7b1f2b8a0df8f69368ad.json | Change react integration test to TS (#10605)
* switch to ts
* change web integration test to TS
* remove space
* lint things
* one more lint
* Add spaces | test/integration/react-browser/package.json | @@ -3,9 +3,13 @@
"description": "chart.js should work in react-browser (Web)",
"dependencies": {
"chart.js": "file:../package.tgz",
+ "@types/node": "^18.7.6",
+ "@types/react": "^18.0.17",
+ "@types/react-dom": "^18.0.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
+ "typescript": "^4.7.4",
"web-vitals": "^2.1.4"
},
"scripts": { | true |
Other | chartjs | Chart.js | 49b16c967833534b6bad7b1f2b8a0df8f69368ad.json | Change react integration test to TS (#10605)
* switch to ts
* change web integration test to TS
* remove space
* lint things
* one more lint
* Add spaces | test/integration/react-browser/src/App.tsx | @@ -1,4 +1,4 @@
-import { useEffect } from 'react';
+import React, {useEffect} from 'react';
import {Chart, DoughnutController, ArcElement} from 'chart.js';
import {merge} from 'chart.js/helpers';
@@ -7,7 +7,9 @@ Chart.register(DoughnutController, ArcElement);
function App() {
useEffect(() => {
const c = Chart.getChart('myChart');
- if(c) c.destroy();
+ if (c) {
+ c.destroy();
+ }
new Chart('myChart', {
type: 'doughnut',
@@ -17,8 +19,8 @@ function App() {
data: [2, 3]
}]
}
- })
- }, [])
+ });
+ }, []);
return (
<div className="App"> | true |
Other | chartjs | Chart.js | 49b16c967833534b6bad7b1f2b8a0df8f69368ad.json | Change react integration test to TS (#10605)
* switch to ts
* change web integration test to TS
* remove space
* lint things
* one more lint
* Add spaces | test/integration/react-browser/src/AppAuto.tsx | @@ -0,0 +1,30 @@
+import React, {useEffect} from 'react';
+import Chart from 'chart.js/auto';
+import {merge} from 'chart.js/helpers';
+
+function AppAuto() {
+ useEffect(() => {
+ const c = Chart.getChart('myChart');
+ if (c) {
+ c.destroy();
+ }
+
+ new Chart('myChart', {
+ type: 'doughnut',
+ data: {
+ labels: ['Chart', 'JS'],
+ datasets: [{
+ data: [2, 3]
+ }]
+ }
+ });
+ }, []);
+
+ return (
+ <div className="App">
+ <canvas id="myChart"></canvas>
+ </div>
+ );
+}
+
+export default AppAuto; | true |
Other | chartjs | Chart.js | 49b16c967833534b6bad7b1f2b8a0df8f69368ad.json | Change react integration test to TS (#10605)
* switch to ts
* change web integration test to TS
* remove space
* lint things
* one more lint
* Add spaces | test/integration/react-browser/src/index.js | @@ -1,10 +0,0 @@
-import React from 'react';
-import ReactDOM from 'react-dom/client';
-import App from './App';
-
-const root = ReactDOM.createRoot(document.getElementById('root'));
-root.render(
- <React.StrictMode>
- <App />
- </React.StrictMode>
-); | true |
Other | chartjs | Chart.js | 49b16c967833534b6bad7b1f2b8a0df8f69368ad.json | Change react integration test to TS (#10605)
* switch to ts
* change web integration test to TS
* remove space
* lint things
* one more lint
* Add spaces | test/integration/react-browser/src/index.tsx | @@ -0,0 +1,12 @@
+import React from 'react';
+import {render} from 'react-dom';
+import App from './App';
+import AppAuto from './AppAuto';
+
+render(
+ <React.StrictMode>
+ <App />
+ <AppAuto />
+ </React.StrictMode>,
+ document.getElementById('root')
+); | true |
Other | chartjs | Chart.js | 49b16c967833534b6bad7b1f2b8a0df8f69368ad.json | Change react integration test to TS (#10605)
* switch to ts
* change web integration test to TS
* remove space
* lint things
* one more lint
* Add spaces | test/integration/react-browser/tsconfig.json | @@ -0,0 +1,14 @@
+{
+ "compilerOptions": {
+ "jsx": "react",
+ "target": "ES6",
+ "moduleResolution": "Node",
+ "allowSyntheticDefaultImports": true,
+ "alwaysStrict": true,
+ "strict": true,
+ "noEmit": true
+ },
+ "include": [
+ "./**/*.tsx",
+ ]
+ } | true |
Other | chartjs | Chart.js | d09e424a0a8f17dd290ef898e5709293fb950977.json | Use borderRadius for legend and remove fallbacks (#10551)
* Use borderRadius for legend
* re enable test
* fix lint
* add note in migration guide
* Update types/index.d.ts
Co-authored-by: Jukka Kurkela <jukka.kurkela@gmail.com> | docs/configuration/legend.md | @@ -67,6 +67,8 @@ Namespace: `options.plugins.legend.labels`
| `textAlign` | `string` | `'center'` | Horizontal alignment of the label text. Options are: `'left'`, `'right'` or `'center'`.
| `usePointStyle` | `boolean` | `false` | Label style will match corresponding point style (size is based on pointStyleWidth or the minimum value between boxWidth and font.size).
| `pointStyleWidth` | `number` | `null` | If `usePointStyle` is true, the width of the point style used for the legend (only for `circle`, `rect` and `line` point stlye).
+| `useBorderRadius` | `boolean` | `false` | Label borderRadius will match coresponding borderRadius.
+| `borderRadius` | `number` | `undefined` | Override the borderRadius to use.
## Legend Title Configuration
| true |
Other | chartjs | Chart.js | d09e424a0a8f17dd290ef898e5709293fb950977.json | Use borderRadius for legend and remove fallbacks (#10551)
* Use borderRadius for legend
* re enable test
* fix lint
* add note in migration guide
* Update types/index.d.ts
Co-authored-by: Jukka Kurkela <jukka.kurkela@gmail.com> | docs/migration/v4-migration.md | @@ -17,4 +17,7 @@ A number of changes were made to the configuration options passed to the `Chart`
* If the tooltip callback returns `undefined`, then the default callback will be used.
#### Type changes
-* The order of the `ChartMeta` parameters have been changed from `<Element, DatasetElement, Type>` to `<Type, Element, DatasetElement>`
+* The order of the `ChartMeta` parameters have been changed from `<Element, DatasetElement, Type>` to `<Type, Element, DatasetElement>`.
+
+### General
+* Removed fallback to `fontColor` for the legend text and strikethrough color. | true |
Other | chartjs | Chart.js | d09e424a0a8f17dd290ef898e5709293fb950977.json | Use borderRadius for legend and remove fallbacks (#10551)
* Use borderRadius for legend
* re enable test
* fix lint
* add note in migration guide
* Update types/index.d.ts
Co-authored-by: Jukka Kurkela <jukka.kurkela@gmail.com> | src/plugins/plugin.legend.js | @@ -278,7 +278,7 @@ export class Legend extends Element {
const defaultColor = defaults.color;
const rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);
const labelFont = toFont(labelOpts.font);
- const {color: fontColor, padding} = labelOpts;
+ const {padding} = labelOpts;
const fontSize = labelFont.size;
const halfFontSize = fontSize / 2;
let cursor;
@@ -384,9 +384,8 @@ export class Legend extends Element {
const lineHeight = itemHeight + padding;
this.legendItems.forEach((legendItem, i) => {
- // TODO: Remove fallbacks at v4
- ctx.strokeStyle = legendItem.fontColor || fontColor; // for strikethrough effect
- ctx.fillStyle = legendItem.fontColor || fontColor; // render in correct colour
+ ctx.strokeStyle = legendItem.fontColor; // for strikethrough effect
+ ctx.fillStyle = legendItem.fontColor; // render in correct colour
const textWidth = ctx.measureText(legendItem.text).width;
const textAlign = rtlHelper.textAlign(legendItem.textAlign || (legendItem.textAlign = labelOpts.textAlign));
@@ -637,7 +636,7 @@ export default {
// lineWidth :
generateLabels(chart) {
const datasets = chart.data.datasets;
- const {labels: {usePointStyle, pointStyle, textAlign, color}} = chart.legend.options;
+ const {labels: {usePointStyle, pointStyle, textAlign, color, useBorderRadius, borderRadius}} = chart.legend.options;
return chart._getSortedDatasetMetas().map((meta) => {
const style = meta.controller.getStyle(usePointStyle ? 0 : undefined);
@@ -657,7 +656,7 @@ export default {
pointStyle: pointStyle || style.pointStyle,
rotation: style.rotation,
textAlign: textAlign || style.textAlign,
- borderRadius: 0, // TODO: v4, default to style.borderRadius
+ borderRadius: useBorderRadius && (borderRadius || style.borderRadius),
// Below is extra data used for toggling the datasets
datasetIndex: meta.index | true |
Other | chartjs | Chart.js | d09e424a0a8f17dd290ef898e5709293fb950977.json | Use borderRadius for legend and remove fallbacks (#10551)
* Use borderRadius for legend
* re enable test
* fix lint
* add note in migration guide
* Update types/index.d.ts
Co-authored-by: Jukka Kurkela <jukka.kurkela@gmail.com> | test/specs/plugin.legend.tests.js | @@ -61,7 +61,7 @@ describe('Legend block tests', function() {
expect(chart.legend.legendItems).toEqual([{
text: 'dataset1',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: '#f31',
fontColor: '#666',
hidden: false,
@@ -77,7 +77,7 @@ describe('Legend block tests', function() {
datasetIndex: 0
}, {
text: 'dataset2',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: true,
@@ -93,7 +93,7 @@ describe('Legend block tests', function() {
datasetIndex: 1
}, {
text: 'dataset3',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: false,
@@ -140,7 +140,7 @@ describe('Legend block tests', function() {
expect(chart.legend.legendItems).toEqual([{
text: 'dataset1',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: '#f31',
fontColor: '#666',
hidden: false,
@@ -156,7 +156,7 @@ describe('Legend block tests', function() {
datasetIndex: 0
}, {
text: 'dataset2',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: true,
@@ -172,7 +172,7 @@ describe('Legend block tests', function() {
datasetIndex: 1
}, {
text: 'dataset3',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: false,
@@ -226,7 +226,7 @@ describe('Legend block tests', function() {
expect(chart.legend.legendItems).toEqual([{
text: 'dataset3',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: false,
@@ -242,7 +242,7 @@ describe('Legend block tests', function() {
datasetIndex: 2
}, {
text: 'dataset2',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: true,
@@ -258,7 +258,7 @@ describe('Legend block tests', function() {
datasetIndex: 1
}, {
text: 'dataset1',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: '#f31',
fontColor: '#666',
hidden: false,
@@ -291,10 +291,11 @@ describe('Legend block tests', function() {
hidden: true,
borderJoinStyle: 'miter',
data: [],
- legendHidden: true
+ legendHidden: true,
}, {
label: 'dataset3',
borderWidth: 10,
+ borderRadius: 10,
borderColor: 'green',
pointStyle: 'crossRot',
data: []
@@ -317,7 +318,7 @@ describe('Legend block tests', function() {
expect(chart.legend.legendItems).toEqual([{
text: 'dataset1',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: '#f31',
fontColor: '#666',
hidden: false,
@@ -333,7 +334,7 @@ describe('Legend block tests', function() {
datasetIndex: 0
}, {
text: 'dataset3',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: false,
@@ -391,7 +392,7 @@ describe('Legend block tests', function() {
expect(chart.legend.legendItems).toEqual([{
text: 'dataset3',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: false,
@@ -407,7 +408,7 @@ describe('Legend block tests', function() {
datasetIndex: 2
}, {
text: 'dataset2',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: true,
@@ -423,7 +424,7 @@ describe('Legend block tests', function() {
datasetIndex: 1
}, {
text: 'dataset1',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: '#f31',
fontColor: '#666',
hidden: false,
@@ -556,7 +557,51 @@ describe('Legend block tests', function() {
expect(chart.legend.legendItems).toEqual([{
text: 'dataset1',
- borderRadius: 0,
+ borderRadius: undefined,
+ fillStyle: '#f31',
+ fontColor: '#666',
+ hidden: false,
+ lineCap: undefined,
+ lineDash: undefined,
+ lineDashOffset: undefined,
+ lineJoin: undefined,
+ lineWidth: 5,
+ strokeStyle: 'red',
+ pointStyle: undefined,
+ rotation: undefined,
+ textAlign: undefined,
+ datasetIndex: 0
+ }]);
+ });
+
+ it('should use the borderRadius in the legend', function() {
+ var chart = window.acquireChart({
+ type: 'bar',
+ data: {
+ datasets: [{
+ label: 'dataset1',
+ backgroundColor: ['#f31', '#666', '#14e'],
+ borderWidth: [5, 10, 15],
+ borderColor: ['red', 'green', 'blue'],
+ borderRadius: 10,
+ data: []
+ }],
+ labels: []
+ },
+ options: {
+ plugins: {
+ legend: {
+ labels: {
+ useBorderRadius: true,
+ }
+ }
+ }
+ }
+ });
+
+ expect(chart.legend.legendItems).toEqual([{
+ text: 'dataset1',
+ borderRadius: 10,
fillStyle: '#f31',
fontColor: '#666',
hidden: false,
@@ -600,7 +645,7 @@ describe('Legend block tests', function() {
expect(chart.legend.legendItems).toEqual([{
text: 'dataset1',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgb(50, 0, 0)',
fontColor: '#666',
hidden: false,
@@ -659,7 +704,7 @@ describe('Legend block tests', function() {
expect(chart.legend.legendItems).toEqual([{
text: 'dataset1',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: false,
@@ -675,7 +720,7 @@ describe('Legend block tests', function() {
datasetIndex: 0
}, {
text: 'dataset2',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: '#f31',
fontColor: '#666',
hidden: false,
@@ -735,7 +780,7 @@ describe('Legend block tests', function() {
expect(chart.legend.legendItems).toEqual([{
text: 'dataset1',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: 'rgba(0,0,0,0.1)',
fontColor: '#666',
hidden: false,
@@ -751,7 +796,7 @@ describe('Legend block tests', function() {
datasetIndex: 0
}, {
text: 'dataset2',
- borderRadius: 0,
+ borderRadius: undefined,
fillStyle: '#f31',
fontColor: '#666',
hidden: false, | true |
Other | chartjs | Chart.js | d09e424a0a8f17dd290ef898e5709293fb950977.json | Use borderRadius for legend and remove fallbacks (#10551)
* Use borderRadius for legend
* re enable test
* fix lint
* add note in migration guide
* Update types/index.d.ts
Co-authored-by: Jukka Kurkela <jukka.kurkela@gmail.com> | types/index.d.ts | @@ -2340,6 +2340,18 @@ export interface LegendOptions<TType extends ChartType> {
* @default false
*/
usePointStyle: boolean;
+
+ /**
+ * Label borderRadius will match corresponding borderRadius.
+ * @default false
+ */
+ useBorderRadius: boolean;
+
+ /**
+ * Override the borderRadius to use.
+ * @default undefined
+ */
+ borderRadius: number;
};
/**
* true for rendering the legends from right to left. | true |
Other | chartjs | Chart.js | d9203719f6ebcd390fb6787a59e7d8424c0126a5.json | add correct padding object to type (#10585)
* add correct padding object to type
* Apply suggestions from code review
Add spacing
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> | types/geometric.d.ts | @@ -35,3 +35,5 @@ export type RoundedRect = {
h: number;
radius?: CornerRadius
}
+
+export type Padding = Partial<TRBL> | number | Point; | true |
Other | chartjs | Chart.js | d9203719f6ebcd390fb6787a59e7d8424c0126a5.json | add correct padding object to type (#10585)
* add correct padding object to type
* Apply suggestions from code review
Add spacing
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> | types/index.d.ts | @@ -5,7 +5,7 @@ import { AnimationEvent } from './animation';
import { AnyObject, EmptyObject } from './basic';
import { Color } from './color';
import { Element } from './element';
-import { ChartArea, Point } from './geometric';
+import { ChartArea, Padding, Point } from './geometric';
import { LayoutItem, LayoutPosition } from './layout';
export { DateAdapter, TimeUnit, _adapters } from './adapters';
@@ -153,17 +153,7 @@ export interface BubbleControllerDatasetOptions
ScriptableAndArrayOptions<PointOptions, ScriptableContext<'bubble'>>,
ScriptableAndArrayOptions<PointHoverOptions, ScriptableContext<'bubble'>> {}
-export interface BubbleDataPoint {
- /**
- * X Value
- */
- x: number;
-
- /**
- * Y Value
- */
- y: number;
-
+export interface BubbleDataPoint extends Point {
/**
* Bubble radius in pixels (not scaled).
*/
@@ -224,10 +214,7 @@ export const LineController: ChartComponent & {
export type ScatterControllerDatasetOptions = LineControllerDatasetOptions;
-export interface ScatterDataPoint {
- x: number;
- y: number;
-}
+export interface ScatterDataPoint extends Point {}
export type ScatterControllerChartOptions = LineControllerChartOptions;
@@ -1533,7 +1520,7 @@ export interface CoreChartOptions<TType extends ChartType> extends ParsingOption
layout: Partial<{
autoPadding: boolean;
- padding: Scriptable<number | Partial<ChartArea>, ScriptableContext<TType>>;
+ padding: Scriptable<Padding, ScriptableContext<TType>>;
}>;
}
@@ -1676,7 +1663,7 @@ export interface VisualElement {
inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): boolean;
inXRange(mouseX: number, useFinalPosition?: boolean): boolean;
inYRange(mouseY: number, useFinalPosition?: boolean): boolean;
- getCenterPoint(useFinalPosition?: boolean): { x: number; y: number };
+ getCenterPoint(useFinalPosition?: boolean): Point;
getRange?(axis: 'x' | 'y'): number;
}
@@ -1698,9 +1685,7 @@ export interface Segment {
loop: boolean;
}
-export interface ArcProps {
- x: number;
- y: number;
+export interface ArcProps extends Point {
startAngle: number;
endAngle: number;
innerRadius: number;
@@ -1847,10 +1832,7 @@ export const LineElement: ChartComponent & {
new (cfg: AnyObject): LineElement;
};
-export interface PointProps {
- x: number;
- y: number;
-}
+export interface PointProps extends Point {}
export type PointStyle =
| 'circle'
@@ -1964,9 +1946,7 @@ export const PointElement: ChartComponent & {
new (cfg: AnyObject): PointElement;
};
-export interface BarProps {
- x: number;
- y: number;
+export interface BarProps extends Point {
base: number;
horizontal: boolean;
width: number;
@@ -2515,9 +2495,7 @@ export interface TooltipModel<TType extends ChartType> extends Element<AnyObject
setActiveElements(active: ActiveDataPoint[], eventPosition: Point): void;
}
-export interface TooltipPosition {
- x: number;
- y: number;
+export interface TooltipPosition extends Point {
xAlign?: TooltipXAlignment;
yAlign?: TooltipYAlignment;
}
@@ -2709,7 +2687,7 @@ export interface TooltipOptions<TType extends ChartType = ChartType> extends Cor
* Padding to add to the tooltip
* @default 6
*/
- padding: Scriptable<number | ChartArea, ScriptableTooltipContext<TType>>;
+ padding: Scriptable<Padding, ScriptableTooltipContext<TType>>;
/**
* Extra distance to move the end of the tooltip arrow away from the tooltip point.
* @default 2
@@ -3500,10 +3478,7 @@ export interface ScaleTypeRegistry extends CartesianScaleTypeRegistry, RadialSca
export type ScaleType = keyof ScaleTypeRegistry;
-interface CartesianParsedData {
- x: number;
- y: number;
-
+interface CartesianParsedData extends Point {
// Only specified when stacked bars are enabled
_stacks?: {
// Key is the stack ID which is generally the axis ID | true |
Other | chartjs | Chart.js | 1551537a40acb09a9652eae3c3886b5c120008d9.json | Add integration test(s) for Web (#10563)
Adds a basic react integration test | .eslintignore | @@ -1 +1,2 @@
dist/*
+test/integration/react-browser/* | true |
Other | chartjs | Chart.js | 1551537a40acb09a9652eae3c3886b5c120008d9.json | Add integration test(s) for Web (#10563)
Adds a basic react integration test | test/integration/integration-test.cjs | @@ -7,6 +7,11 @@ const childProcess = require('child_process');
const {describe, it} = require('mocha');
+const platforms = [
+ 'node',
+ 'react-browser'
+];
+
function exec(command, options = {}) {
const output = childProcess.execSync(command, {
encoding: 'utf-8',
@@ -27,7 +32,7 @@ describe('Integration Tests', () => {
path.join(tmpDir, 'package.tgz'),
);
- function testOnNodeProject(projectName) {
+ function testProjectOnPlatform(projectName) {
const projectPath = path.join(__dirname, projectName);
const packageJSONPath = path.join(projectPath, 'package.json');
@@ -42,5 +47,7 @@ describe('Integration Tests', () => {
}).timeout(5 * 60 * 1000);
}
- testOnNodeProject('node');
+ for (const platform of platforms) {
+ testProjectOnPlatform(platform)
+ }
}); | true |
Other | chartjs | Chart.js | 1551537a40acb09a9652eae3c3886b5c120008d9.json | Add integration test(s) for Web (#10563)
Adds a basic react integration test | test/integration/react-browser/package.json | @@ -0,0 +1,26 @@
+{
+ "private": true,
+ "description": "chart.js should work in react-browser (Web)",
+ "dependencies": {
+ "chart.js": "file:../package.tgz",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
+ "react-scripts": "5.0.1",
+ "web-vitals": "^2.1.4"
+ },
+ "scripts": {
+ "test": "react-scripts build"
+ },
+ "browserslist": {
+ "production": [
+ ">0.2%",
+ "not dead",
+ "not op_mini all"
+ ],
+ "development": [
+ "last 1 chrome version",
+ "last 1 firefox version",
+ "last 1 safari version"
+ ]
+ }
+} | true |
Other | chartjs | Chart.js | 1551537a40acb09a9652eae3c3886b5c120008d9.json | Add integration test(s) for Web (#10563)
Adds a basic react integration test | test/integration/react-browser/public/index.html | @@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="theme-color" content="#000000" />
+ <meta
+ name="description"
+ content="Web site created using create-react-app"
+ />
+ <!--
+ Notice the use of %PUBLIC_URL% in the tags above.
+ It will be replaced with the URL of the `public` folder during the build.
+ Only files inside the `public` folder can be referenced from the HTML.
+
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
+ work correctly both with client-side routing and a non-root public URL.
+ Learn how to configure a non-root public URL by running `npm run build`.
+ -->
+ <title>Chartjs test React App</title>
+ </head>
+ <body>
+ <noscript>You need to enable JavaScript to run this app.</noscript>
+ <div id="root"></div>
+ <!--
+ This HTML file is a template.
+ If you open it directly in the browser, you will see an empty page.
+
+ You can add webfonts, meta tags, or analytics to this file.
+ The build step will place the bundled scripts into the <body> tag.
+
+ To begin the development, run `npm start` or `yarn start`.
+ To create a production bundle, use `npm run build` or `yarn build`.
+ -->
+ </body>
+</html> | true |
Other | chartjs | Chart.js | 1551537a40acb09a9652eae3c3886b5c120008d9.json | Add integration test(s) for Web (#10563)
Adds a basic react integration test | test/integration/react-browser/src/App.js | @@ -0,0 +1,30 @@
+import { useEffect } from 'react';
+import {Chart, DoughnutController, ArcElement} from 'chart.js';
+import {merge} from 'chart.js/helpers';
+
+Chart.register(DoughnutController, ArcElement);
+
+function App() {
+ useEffect(() => {
+ const c = Chart.getChart('myChart');
+ if(c) c.destroy();
+
+ new Chart('myChart', {
+ type: 'doughnut',
+ data: {
+ labels: ['Chart', 'JS'],
+ datasets: [{
+ data: [2, 3]
+ }]
+ }
+ })
+ }, [])
+
+ return (
+ <div className="App">
+ <canvas id="myChart"></canvas>
+ </div>
+ );
+}
+
+export default App; | true |
Other | chartjs | Chart.js | 1551537a40acb09a9652eae3c3886b5c120008d9.json | Add integration test(s) for Web (#10563)
Adds a basic react integration test | test/integration/react-browser/src/index.js | @@ -0,0 +1,10 @@
+import React from 'react';
+import ReactDOM from 'react-dom/client';
+import App from './App';
+
+const root = ReactDOM.createRoot(document.getElementById('root'));
+root.render(
+ <React.StrictMode>
+ <App />
+ </React.StrictMode>
+); | true |
Other | chartjs | Chart.js | e798defcde01bdda13f8ae0a8149859b4c7ce57d.json | Use ESM config file for Rollup (#10564) | rollup.config.js | @@ -1,17 +1,17 @@
-const cleanup = require('rollup-plugin-cleanup');
-const json = require('@rollup/plugin-json');
-const resolve = require('@rollup/plugin-node-resolve').default;
-const terser = require('rollup-plugin-terser').terser;
-const pkg = require('./package.json');
+import cleanup from 'rollup-plugin-cleanup';
+import json from '@rollup/plugin-json';
+import resolve from '@rollup/plugin-node-resolve';
+import {terser} from 'rollup-plugin-terser';
+import {version, homepage} from './package.json';
const banner = `/*!
- * Chart.js v${pkg.version}
- * ${pkg.homepage}
+ * Chart.js v${version}
+ * ${homepage}
* (c) ${(new Date(process.env.SOURCE_DATE_EPOCH ? (process.env.SOURCE_DATE_EPOCH * 1000) : new Date().getTime())).getFullYear()} Chart.js Contributors
* Released under the MIT License
*/`;
-module.exports = [
+export default [
// UMD build
// dist/chart.umd.js
{ | false |
Other | chartjs | Chart.js | b19fc0169facffc2a9a6715d98ccfc3dfba00e09.json | fix: pass timestamp to ticks callback (#10540)
* fix: pass timestamp to ticks callback
* docs: edit labelling page
* docs: additions to the migration guide | docs/axes/labelling.md | @@ -22,7 +22,7 @@ To do this, you need to override the `ticks.callback` method in the axis configu
The method receives 3 arguments:
-* `value` - the tick value in the **internal data format** of the associated scale.
+* `value` - the tick value in the **internal data format** of the associated scale. For time scale, it is a timestamp.
* `index` - the tick index in the ticks array.
* `ticks` - the array containing all of the [tick objects](../api/interfaces/Tick).
| true |
Other | chartjs | Chart.js | b19fc0169facffc2a9a6715d98ccfc3dfba00e09.json | fix: pass timestamp to ticks callback (#10540)
* fix: pass timestamp to ticks callback
* docs: edit labelling page
* docs: additions to the migration guide | docs/migration/v4-migration.md | @@ -11,6 +11,7 @@ A number of changes were made to the configuration options passed to the `Chart`
#### Specific changes
* The radialLinear grid indexable and scriptable options don't decrease the index of the specified grid line anymore.
+* Ticks callback on time scale now receives timestamp instead of a formatted label.
#### Type changes
* The order of the `ChartMeta` parameters have been changed from `<Element, DatasetElement, Type>` to `<Type, Element, DatasetElement>` | true |
Other | chartjs | Chart.js | b19fc0169facffc2a9a6715d98ccfc3dfba00e09.json | fix: pass timestamp to ticks callback (#10540)
* fix: pass timestamp to ticks callback
* docs: edit labelling page
* docs: additions to the migration guide | src/scales/scale.time.js | @@ -232,6 +232,8 @@ export default class TimeScale extends Scale {
*/
source: 'auto',
+ callback: false,
+
major: {
enabled: false
}
@@ -510,16 +512,21 @@ export default class TimeScale extends Scale {
*/
_tickFormatFunction(time, index, ticks, format) {
const options = this.options;
+ const formatter = options.ticks.callback;
+
+ if (formatter) {
+ return call(formatter, [time, index, ticks], this);
+ }
+
const formats = options.time.displayFormats;
const unit = this._unit;
const majorUnit = this._majorUnit;
const minorFormat = unit && formats[unit];
const majorFormat = majorUnit && formats[majorUnit];
const tick = ticks[index];
const major = majorUnit && majorFormat && tick && tick.major;
- const label = this._adapter.format(time, format || (major ? majorFormat : minorFormat));
- const formatter = options.ticks.callback;
- return formatter ? call(formatter, [label, index, ticks], this) : label;
+
+ return this._adapter.format(time, format || (major ? majorFormat : minorFormat));
}
/** | true |
Other | chartjs | Chart.js | b19fc0169facffc2a9a6715d98ccfc3dfba00e09.json | fix: pass timestamp to ticks callback (#10540)
* fix: pass timestamp to ticks callback
* docs: edit labelling page
* docs: additions to the migration guide | test/specs/scale.time.tests.js | @@ -73,6 +73,7 @@ describe('Time scale tests', function() {
},
ticks: {
source: 'auto',
+ callback: false,
major: {
enabled: false
}
@@ -353,8 +354,8 @@ describe('Time scale tests', function() {
}
},
ticks: {
- callback: function(value) {
- return '<' + value + '>';
+ callback: function(_, i) {
+ return '<' + i + '>';
}
}
}
@@ -368,21 +369,21 @@ describe('Time scale tests', function() {
var labels = getLabels(this.scale);
expect(labels.length).toEqual(21);
- expect(labels[0]).toEqual('<8:00:00>');
- expect(labels[labels.length - 1]).toEqual('<8:01:00>');
+ expect(labels[0]).toEqual('<0>');
+ expect(labels[labels.length - 1]).toEqual('<60>');
});
it('should update ticks.callback correctly', function() {
var chart = this.chart;
- chart.options.scales.x.ticks.callback = function(value) {
- return '{' + value + '}';
+ chart.options.scales.x.ticks.callback = function(_, i) {
+ return '{' + i + '}';
};
chart.update();
var labels = getLabels(this.scale);
expect(labels.length).toEqual(21);
- expect(labels[0]).toEqual('{8:00:00}');
- expect(labels[labels.length - 1]).toEqual('{8:01:00}');
+ expect(labels[0]).toEqual('{0}');
+ expect(labels[labels.length - 1]).toEqual('{60}');
});
});
@@ -1260,4 +1261,33 @@ describe('Time scale tests', function() {
expect(chartOptions).toEqual(chart.options);
});
+
+ it('should pass timestamp to ticks callback', () => {
+ let callbackValue;
+ window.acquireChart({
+ type: 'line',
+ data: {
+ datasets: [{
+ xAxisID: 'x',
+ data: [0, 0]
+ }],
+ labels: ['2015-01-01T20:00:00', '2015-01-01T20:01:00']
+ },
+ options: {
+ scales: {
+ x: {
+ type: 'time',
+ ticks: {
+ callback(value) {
+ callbackValue = value;
+ return value;
+ }
+ }
+ }
+ }
+ }
+ });
+
+ expect(typeof callbackValue).toBe('number');
+ });
}); | true |
Other | chartjs | Chart.js | 9224e57d93287212ae018745ac629a1d925ba5be.json | Add integration test(s) for Node (#10554) | package-lock.json | @@ -47,6 +47,7 @@
"karma-spec-reporter": "0.0.32",
"luxon": "^2.2.0",
"markdown-it-include": "^2.0.0",
+ "mocha": "^10.0.0",
"moment": "^2.29.1",
"moment-timezone": "^0.5.34",
"pixelmatch": "^5.2.1",
@@ -2454,6 +2455,12 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
+ "node_modules/@ungap/promise-all-settled": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
+ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==",
+ "dev": true
+ },
"node_modules/@vue/babel-helper-vue-jsx-merge-props": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@vue/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-1.2.1.tgz",
@@ -4827,6 +4834,12 @@
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
"dev": true
},
+ "node_modules/browser-stdout": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
+ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
+ "dev": true
+ },
"node_modules/browserify-aes": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
@@ -5503,10 +5516,16 @@
}
},
"node_modules/chokidar": {
- "version": "3.5.2",
- "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz",
- "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==",
+ "version": "3.5.3",
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
+ "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
"dev": true,
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://paulmillr.com/funding/"
+ }
+ ],
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
@@ -6972,9 +6991,9 @@
"dev": true
},
"node_modules/debug": {
- "version": "4.3.3",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz",
- "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==",
+ "version": "4.3.4",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
+ "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dev": true,
"dependencies": {
"ms": "2.1.2"
@@ -7224,6 +7243,15 @@
"integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=",
"dev": true
},
+ "node_modules/diff": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz",
+ "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.3.1"
+ }
+ },
"node_modules/diffie-hellman": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
@@ -8647,6 +8675,15 @@
"node": ">=8"
}
},
+ "node_modules/flat": {
+ "version": "5.0.2",
+ "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz",
+ "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==",
+ "dev": true,
+ "bin": {
+ "flat": "cli.js"
+ }
+ },
"node_modules/flat-cache": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz",
@@ -10611,6 +10648,18 @@
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true
},
+ "node_modules/is-unicode-supported": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz",
+ "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==",
+ "dev": true,
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/is-weakref": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz",
@@ -11371,6 +11420,22 @@
"node": ">=0.8.6"
}
},
+ "node_modules/log-symbols": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
+ "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==",
+ "dev": true,
+ "dependencies": {
+ "chalk": "^4.1.0",
+ "is-unicode-supported": "^0.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/log4js": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/log4js/-/log4js-6.4.1.tgz",
@@ -11955,6 +12020,198 @@
"mkdirp": "bin/cmd.js"
}
},
+ "node_modules/mocha": {
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.0.0.tgz",
+ "integrity": "sha512-0Wl+elVUD43Y0BqPZBzZt8Tnkw9CMUdNYnUsTfOM1vuhJVZL+kiesFYsqwBkEEuEixaiPe5ZQdqDgX2jddhmoA==",
+ "dev": true,
+ "dependencies": {
+ "@ungap/promise-all-settled": "1.1.2",
+ "ansi-colors": "4.1.1",
+ "browser-stdout": "1.3.1",
+ "chokidar": "3.5.3",
+ "debug": "4.3.4",
+ "diff": "5.0.0",
+ "escape-string-regexp": "4.0.0",
+ "find-up": "5.0.0",
+ "glob": "7.2.0",
+ "he": "1.2.0",
+ "js-yaml": "4.1.0",
+ "log-symbols": "4.1.0",
+ "minimatch": "5.0.1",
+ "ms": "2.1.3",
+ "nanoid": "3.3.3",
+ "serialize-javascript": "6.0.0",
+ "strip-json-comments": "3.1.1",
+ "supports-color": "8.1.1",
+ "workerpool": "6.2.1",
+ "yargs": "16.2.0",
+ "yargs-parser": "20.2.4",
+ "yargs-unparser": "2.0.0"
+ },
+ "bin": {
+ "_mocha": "bin/_mocha",
+ "mocha": "bin/mocha.js"
+ },
+ "engines": {
+ "node": ">= 14.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/mochajs"
+ }
+ },
+ "node_modules/mocha/node_modules/argparse": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
+ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
+ "dev": true
+ },
+ "node_modules/mocha/node_modules/brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dev": true,
+ "dependencies": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "node_modules/mocha/node_modules/find-up": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
+ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
+ "dev": true,
+ "dependencies": {
+ "locate-path": "^6.0.0",
+ "path-exists": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/mocha/node_modules/js-yaml": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
+ "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
+ "dev": true,
+ "dependencies": {
+ "argparse": "^2.0.1"
+ },
+ "bin": {
+ "js-yaml": "bin/js-yaml.js"
+ }
+ },
+ "node_modules/mocha/node_modules/locate-path": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
+ "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
+ "dev": true,
+ "dependencies": {
+ "p-locate": "^5.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/mocha/node_modules/minimatch": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
+ "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==",
+ "dev": true,
+ "dependencies": {
+ "brace-expansion": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/mocha/node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+ "dev": true
+ },
+ "node_modules/mocha/node_modules/p-limit": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
+ "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
+ "dev": true,
+ "dependencies": {
+ "yocto-queue": "^0.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/mocha/node_modules/p-locate": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
+ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
+ "dev": true,
+ "dependencies": {
+ "p-limit": "^3.0.2"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/mocha/node_modules/serialize-javascript": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz",
+ "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==",
+ "dev": true,
+ "dependencies": {
+ "randombytes": "^2.1.0"
+ }
+ },
+ "node_modules/mocha/node_modules/y18n": {
+ "version": "5.0.8",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
+ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
+ "dev": true,
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/mocha/node_modules/yargs": {
+ "version": "16.2.0",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",
+ "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",
+ "dev": true,
+ "dependencies": {
+ "cliui": "^7.0.2",
+ "escalade": "^3.1.1",
+ "get-caller-file": "^2.0.5",
+ "require-directory": "^2.1.1",
+ "string-width": "^4.2.0",
+ "y18n": "^5.0.5",
+ "yargs-parser": "^20.2.2"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/mocha/node_modules/yargs-parser": {
+ "version": "20.2.4",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz",
+ "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==",
+ "dev": true,
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
@@ -12034,6 +12291,18 @@
"dev": true,
"optional": true
},
+ "node_modules/nanoid": {
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz",
+ "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==",
+ "dev": true,
+ "bin": {
+ "nanoid": "bin/nanoid.cjs"
+ },
+ "engines": {
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+ }
+ },
"node_modules/nanomatch": {
"version": "1.2.13",
"resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
@@ -19028,6 +19297,12 @@
"errno": "~0.1.7"
}
},
+ "node_modules/workerpool": {
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz",
+ "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==",
+ "dev": true
+ },
"node_modules/wrap-ansi": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz",
@@ -19215,6 +19490,42 @@
"node": ">=12"
}
},
+ "node_modules/yargs-unparser": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz",
+ "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==",
+ "dev": true,
+ "dependencies": {
+ "camelcase": "^6.0.0",
+ "decamelize": "^4.0.0",
+ "flat": "^5.0.2",
+ "is-plain-obj": "^2.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/yargs-unparser/node_modules/decamelize": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz",
+ "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==",
+ "dev": true,
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/yargs-unparser/node_modules/is-plain-obj": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz",
+ "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==",
+ "dev": true,
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/yargs/node_modules/y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
@@ -19224,6 +19535,18 @@
"node": ">=10"
}
},
+ "node_modules/yocto-queue": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
+ "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
+ "dev": true,
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/zepto": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/zepto/-/zepto-1.2.0.tgz",
@@ -20950,6 +21273,12 @@
"eslint-visitor-keys": "^3.0.0"
}
},
+ "@ungap/promise-all-settled": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
+ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==",
+ "dev": true
+ },
"@vue/babel-helper-vue-jsx-merge-props": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@vue/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-1.2.1.tgz",
@@ -22944,6 +23273,12 @@
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
"dev": true
},
+ "browser-stdout": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
+ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
+ "dev": true
+ },
"browserify-aes": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
@@ -23481,9 +23816,9 @@
}
},
"chokidar": {
- "version": "3.5.2",
- "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz",
- "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==",
+ "version": "3.5.3",
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
+ "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
"dev": true,
"requires": {
"anymatch": "~3.1.2",
@@ -24680,9 +25015,9 @@
"dev": true
},
"debug": {
- "version": "4.3.3",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz",
- "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==",
+ "version": "4.3.4",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
+ "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dev": true,
"requires": {
"ms": "2.1.2"
@@ -24877,6 +25212,12 @@
"integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=",
"dev": true
},
+ "diff": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz",
+ "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
+ "dev": true
+ },
"diffie-hellman": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
@@ -26024,6 +26365,12 @@
"path-exists": "^4.0.0"
}
},
+ "flat": {
+ "version": "5.0.2",
+ "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz",
+ "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==",
+ "dev": true
+ },
"flat-cache": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz",
@@ -27511,6 +27858,12 @@
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true
},
+ "is-unicode-supported": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz",
+ "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==",
+ "dev": true
+ },
"is-weakref": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz",
@@ -28141,6 +28494,16 @@
"integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==",
"dev": true
},
+ "log-symbols": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
+ "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==",
+ "dev": true,
+ "requires": {
+ "chalk": "^4.1.0",
+ "is-unicode-supported": "^0.1.0"
+ }
+ },
"log4js": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/log4js/-/log4js-6.4.1.tgz",
@@ -28600,6 +28963,150 @@
"minimist": "^1.2.5"
}
},
+ "mocha": {
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.0.0.tgz",
+ "integrity": "sha512-0Wl+elVUD43Y0BqPZBzZt8Tnkw9CMUdNYnUsTfOM1vuhJVZL+kiesFYsqwBkEEuEixaiPe5ZQdqDgX2jddhmoA==",
+ "dev": true,
+ "requires": {
+ "@ungap/promise-all-settled": "1.1.2",
+ "ansi-colors": "4.1.1",
+ "browser-stdout": "1.3.1",
+ "chokidar": "3.5.3",
+ "debug": "4.3.4",
+ "diff": "5.0.0",
+ "escape-string-regexp": "4.0.0",
+ "find-up": "5.0.0",
+ "glob": "7.2.0",
+ "he": "1.2.0",
+ "js-yaml": "4.1.0",
+ "log-symbols": "4.1.0",
+ "minimatch": "5.0.1",
+ "ms": "2.1.3",
+ "nanoid": "3.3.3",
+ "serialize-javascript": "6.0.0",
+ "strip-json-comments": "3.1.1",
+ "supports-color": "8.1.1",
+ "workerpool": "6.2.1",
+ "yargs": "16.2.0",
+ "yargs-parser": "20.2.4",
+ "yargs-unparser": "2.0.0"
+ },
+ "dependencies": {
+ "argparse": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
+ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
+ "dev": true
+ },
+ "brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dev": true,
+ "requires": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "find-up": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
+ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
+ "dev": true,
+ "requires": {
+ "locate-path": "^6.0.0",
+ "path-exists": "^4.0.0"
+ }
+ },
+ "js-yaml": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
+ "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
+ "dev": true,
+ "requires": {
+ "argparse": "^2.0.1"
+ }
+ },
+ "locate-path": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
+ "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
+ "dev": true,
+ "requires": {
+ "p-locate": "^5.0.0"
+ }
+ },
+ "minimatch": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
+ "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "^2.0.1"
+ }
+ },
+ "ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+ "dev": true
+ },
+ "p-limit": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
+ "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
+ "dev": true,
+ "requires": {
+ "yocto-queue": "^0.1.0"
+ }
+ },
+ "p-locate": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
+ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
+ "dev": true,
+ "requires": {
+ "p-limit": "^3.0.2"
+ }
+ },
+ "serialize-javascript": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz",
+ "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==",
+ "dev": true,
+ "requires": {
+ "randombytes": "^2.1.0"
+ }
+ },
+ "y18n": {
+ "version": "5.0.8",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
+ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
+ "dev": true
+ },
+ "yargs": {
+ "version": "16.2.0",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",
+ "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",
+ "dev": true,
+ "requires": {
+ "cliui": "^7.0.2",
+ "escalade": "^3.1.1",
+ "get-caller-file": "^2.0.5",
+ "require-directory": "^2.1.1",
+ "string-width": "^4.2.0",
+ "y18n": "^5.0.5",
+ "yargs-parser": "^20.2.2"
+ }
+ },
+ "yargs-parser": {
+ "version": "20.2.4",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz",
+ "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==",
+ "dev": true
+ }
+ }
+ },
"moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
@@ -28669,6 +29176,12 @@
"dev": true,
"optional": true
},
+ "nanoid": {
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz",
+ "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==",
+ "dev": true
+ },
"nanomatch": {
"version": "1.2.13",
"resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
@@ -34365,6 +34878,12 @@
"errno": "~0.1.7"
}
},
+ "workerpool": {
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz",
+ "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==",
+ "dev": true
+ },
"wrap-ansi": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz",
@@ -34518,6 +35037,38 @@
"integrity": "sha512-z9kApYUOCwoeZ78rfRYYWdiU/iNL6mwwYlkkZfJoyMR1xps+NEBX5X7XmRpxkZHhXJ6+Ey00IwKxBBSW9FIjyA==",
"dev": true
},
+ "yargs-unparser": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz",
+ "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==",
+ "dev": true,
+ "requires": {
+ "camelcase": "^6.0.0",
+ "decamelize": "^4.0.0",
+ "flat": "^5.0.2",
+ "is-plain-obj": "^2.1.0"
+ },
+ "dependencies": {
+ "decamelize": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz",
+ "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==",
+ "dev": true
+ },
+ "is-plain-obj": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz",
+ "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==",
+ "dev": true
+ }
+ }
+ },
+ "yocto-queue": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
+ "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
+ "dev": true
+ },
"zepto": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/zepto/-/zepto-1.2.0.tgz", | true |
Other | chartjs | Chart.js | 9224e57d93287212ae018745ac629a1d925ba5be.json | Add integration test(s) for Node (#10554) | package.json | @@ -43,7 +43,9 @@
"lint-types": "eslint \"types/**/*.ts\" && node -r esm types/tests/autogen.js && tsc -p types/tests/",
"lint": "concurrently \"npm:lint-*\"",
"test": "npm run lint && npm run test-ci",
- "test-ci": "cross-env NODE_ENV=test karma start --auto-watch --single-run --coverage --grep"
+ "test-ci": "concurrently \"npm:test-ci-*\"",
+ "test-ci-karma": "cross-env NODE_ENV=test karma start --auto-watch --single-run --coverage --grep",
+ "test-ci-integration": "mocha --full-trace test/integration/*-test.js"
},
"devDependencies": {
"@kurkle/color": "^0.2.1",
@@ -84,6 +86,7 @@
"karma-spec-reporter": "0.0.32",
"luxon": "^2.2.0",
"markdown-it-include": "^2.0.0",
+ "mocha": "^10.0.0",
"moment": "^2.29.1",
"moment-timezone": "^0.5.34",
"pixelmatch": "^5.2.1", | true |
Other | chartjs | Chart.js | 9224e57d93287212ae018745ac629a1d925ba5be.json | Add integration test(s) for Node (#10554) | test/integration/integration-test.js | @@ -0,0 +1,46 @@
+'use strict';
+
+const os = require('os');
+const fs = require('fs-extra');
+const path = require('path');
+const childProcess = require('child_process');
+
+const {describe, it} = require('mocha');
+
+function exec(command, options = {}) {
+ const output = childProcess.execSync(command, {
+ encoding: 'utf-8',
+ ...options,
+ });
+ return output && output.trimEnd();
+}
+
+describe('Integration Tests', () => {
+ const tmpDir = path.join(os.tmpdir(), 'chart.js-tmp');
+ fs.rmSync(tmpDir, {recursive: true, force: true});
+ fs.mkdirSync(tmpDir);
+
+ const distDir = path.resolve('./');
+ const archiveName = exec(`npm --quiet pack ${distDir}`, {cwd: tmpDir});
+ fs.renameSync(
+ path.join(tmpDir, archiveName),
+ path.join(tmpDir, 'package.tgz'),
+ );
+
+ function testOnNodeProject(projectName) {
+ const projectPath = path.join(__dirname, projectName);
+
+ const packageJSONPath = path.join(projectPath, 'package.json');
+ const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'));
+
+ it(packageJSON.description, () => {
+ const cwd = path.join(tmpDir, projectName);
+ fs.copySync(projectPath, cwd);
+
+ exec('npm --quiet install', {cwd, stdio: 'inherit'});
+ exec('npm --quiet test', {cwd, stdio: 'inherit'});
+ }).timeout(5 * 60 * 1000);
+ }
+
+ testOnNodeProject('node');
+}); | true |
Other | chartjs | Chart.js | 9224e57d93287212ae018745ac629a1d925ba5be.json | Add integration test(s) for Node (#10554) | test/integration/node/package-lock.json | @@ -0,0 +1,24 @@
+{
+ "name": "node",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "": {
+ "dependencies": {
+ "chart.js": "^3.8.2"
+ }
+ },
+ "node_modules/chart.js": {
+ "version": "3.8.2",
+ "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.8.2.tgz",
+ "integrity": "sha512-7rqSlHWMUKFyBDOJvmFGW2lxULtcwaPLegDjX/Nu5j6QybY+GCiQkEY+6cqHw62S5tcwXMD8Y+H5OBGoR7d+ZQ=="
+ }
+ },
+ "dependencies": {
+ "chart.js": {
+ "version": "3.8.2",
+ "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.8.2.tgz",
+ "integrity": "sha512-7rqSlHWMUKFyBDOJvmFGW2lxULtcwaPLegDjX/Nu5j6QybY+GCiQkEY+6cqHw62S5tcwXMD8Y+H5OBGoR7d+ZQ=="
+ }
+ }
+} | true |
Other | chartjs | Chart.js | 9224e57d93287212ae018745ac629a1d925ba5be.json | Add integration test(s) for Node (#10554) | test/integration/node/package.json | @@ -0,0 +1,13 @@
+{
+ "private": true,
+ "description": "chart.js should work in Node",
+ "scripts": {
+ "test": "npm run test-cjs",
+ "test-cjs": "node test.cjs",
+ "test-mjs": "node test.mjs",
+ "TODO": "test-mjs should be enambled for chart.js v4"
+ },
+ "dependencies": {
+ "chart.js": "file:../package.tgz"
+ }
+} | true |
Other | chartjs | Chart.js | 9224e57d93287212ae018745ac629a1d925ba5be.json | Add integration test(s) for Node (#10554) | test/integration/node/test.cjs | @@ -0,0 +1,7 @@
+const Chart = require('chart.js');
+const valueOrDefault = Chart.helpers.valueOrDefault;
+
+Chart.register({
+ id: 'TEST_PLUGIN',
+ dummyValue: valueOrDefault(0, 1)
+}); | true |
Other | chartjs | Chart.js | 9224e57d93287212ae018745ac629a1d925ba5be.json | Add integration test(s) for Node (#10554) | test/integration/node/test.mjs | @@ -0,0 +1,7 @@
+import {Chart} from 'chart.js';
+import {valueOrDefault} from 'chart.js/helpers';
+
+Chart.register({
+ id: 'TEST_PLUGIN',
+ dummyValue: valueOrDefault(0, 1)
+}); | true |
Other | chartjs | Chart.js | 03e9194be5e899e36ac077d8e33be6921d1eae2a.json | feat: remove line element from scatter controller (#10439)
* feat: remove line element from scatter controller default config
* feat: move common controllers methods to helpers and add types
* feat: mark methods for scatter and line conntrollers as private
* fix: fix error when showline is true at root options and add tests
* feat: remove else inside scatter controller update
* fix: update getStartAndCountOFVisiblePoints helper code | src/controllers/controller.line.js | @@ -1,7 +1,7 @@
import DatasetController from '../core/core.datasetController';
import {isNullOrUndef} from '../helpers';
-import {_limitValue, isNumber} from '../helpers/helpers.math';
-import {_lookupByKey} from '../helpers/helpers.collection';
+import {isNumber} from '../helpers/helpers.math';
+import {_getStartAndCountOfVisiblePoints, _scaleRangesChanged} from '../helpers/helpers.extras';
export default class LineController extends DatasetController {
@@ -16,12 +16,12 @@ export default class LineController extends DatasetController {
const {dataset: line, data: points = [], _dataset} = meta;
// @ts-ignore
const animationsDisabled = this.chart._animationsDisabled;
- let {start, count} = getStartAndCountOfVisiblePoints(meta, points, animationsDisabled);
+ let {start, count} = _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled);
this._drawStart = start;
this._drawCount = count;
- if (scaleRangesChanged(meta)) {
+ if (_scaleRangesChanged(meta)) {
start = 0;
count = points.length;
}
@@ -133,54 +133,3 @@ LineController.overrides = {
},
}
};
-
-function getStartAndCountOfVisiblePoints(meta, points, animationsDisabled) {
- const pointCount = points.length;
-
- let start = 0;
- let count = pointCount;
-
- if (meta._sorted) {
- const {iScale, _parsed} = meta;
- const axis = iScale.axis;
- const {min, max, minDefined, maxDefined} = iScale.getUserBounds();
-
- if (minDefined) {
- start = _limitValue(Math.min(
- _lookupByKey(_parsed, iScale.axis, min).lo,
- animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo),
- 0, pointCount - 1);
- }
- if (maxDefined) {
- count = _limitValue(Math.max(
- _lookupByKey(_parsed, iScale.axis, max, true).hi + 1,
- animationsDisabled ? 0 : _lookupByKey(points, axis, iScale.getPixelForValue(max), true).hi + 1),
- start, pointCount) - start;
- } else {
- count = pointCount - start;
- }
- }
-
- return {start, count};
-}
-
-function scaleRangesChanged(meta) {
- const {xScale, yScale, _scaleRanges} = meta;
- const newRanges = {
- xmin: xScale.min,
- xmax: xScale.max,
- ymin: yScale.min,
- ymax: yScale.max
- };
- if (!_scaleRanges) {
- meta._scaleRanges = newRanges;
- return true;
- }
- const changed = _scaleRanges.xmin !== xScale.min
- || _scaleRanges.xmax !== xScale.max
- || _scaleRanges.ymin !== yScale.min
- || _scaleRanges.ymax !== yScale.max;
-
- Object.assign(_scaleRanges, newRanges);
- return changed;
-} | true |
Other | chartjs | Chart.js | 03e9194be5e899e36ac077d8e33be6921d1eae2a.json | feat: remove line element from scatter controller (#10439)
* feat: remove line element from scatter controller default config
* feat: move common controllers methods to helpers and add types
* feat: mark methods for scatter and line conntrollers as private
* fix: fix error when showline is true at root options and add tests
* feat: remove else inside scatter controller update
* fix: update getStartAndCountOFVisiblePoints helper code | src/controllers/controller.scatter.js | @@ -1,7 +1,125 @@
-import LineController from './controller.line';
+import DatasetController from '../core/core.datasetController';
+import {isNullOrUndef} from '../helpers';
+import {isNumber} from '../helpers/helpers.math';
+import {_getStartAndCountOfVisiblePoints, _scaleRangesChanged} from '../helpers/helpers.extras';
+import registry from '../core/core.registry';
-export default class ScatterController extends LineController {
+export default class ScatterController extends DatasetController {
+ update(mode) {
+ const meta = this._cachedMeta;
+ const {data: points = []} = meta;
+ // @ts-ignore
+ const animationsDisabled = this.chart._animationsDisabled;
+ let {start, count} = _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled);
+ this._drawStart = start;
+ this._drawCount = count;
+
+ if (_scaleRangesChanged(meta)) {
+ start = 0;
+ count = points.length;
+ }
+
+ if (this.options.showLine) {
+
+ const {dataset: line, _dataset} = meta;
+
+ // Update Line
+ line._chart = this.chart;
+ line._datasetIndex = this.index;
+ line._decimated = !!_dataset._decimated;
+ line.points = points;
+
+ const options = this.resolveDatasetElementOptions(mode);
+ options.segment = this.options.segment;
+ this.updateElement(line, undefined, {
+ animated: !animationsDisabled,
+ options
+ }, mode);
+ }
+
+ // Update Points
+ this.updateElements(points, start, count, mode);
+ }
+
+ addElements() {
+ const {showLine} = this.options;
+
+ if (!this.datasetElementType && showLine) {
+ this.datasetElementType = registry.getElement('line');
+ }
+
+ super.addElements();
+ }
+
+ updateElements(points, start, count, mode) {
+ const reset = mode === 'reset';
+ const {iScale, vScale, _stacked, _dataset} = this._cachedMeta;
+ const firstOpts = this.resolveDataElementOptions(start, mode);
+ const sharedOptions = this.getSharedOptions(firstOpts);
+ const includeOptions = this.includeOptions(mode, sharedOptions);
+ const iAxis = iScale.axis;
+ const vAxis = vScale.axis;
+ const {spanGaps, segment} = this.options;
+ const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
+ const directUpdate = this.chart._animationsDisabled || reset || mode === 'none';
+ let prevParsed = start > 0 && this.getParsed(start - 1);
+
+ for (let i = start; i < start + count; ++i) {
+ const point = points[i];
+ const parsed = this.getParsed(i);
+ const properties = directUpdate ? point : {};
+ const nullData = isNullOrUndef(parsed[vAxis]);
+ const iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);
+ const vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);
+
+ properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;
+ properties.stop = i > 0 && (Math.abs(parsed[iAxis] - prevParsed[iAxis])) > maxGapLength;
+ if (segment) {
+ properties.parsed = parsed;
+ properties.raw = _dataset.data[i];
+ }
+
+ if (includeOptions) {
+ properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);
+ }
+
+ if (!directUpdate) {
+ this.updateElement(point, i, properties, mode);
+ }
+
+ prevParsed = parsed;
+ }
+
+ this.updateSharedOptions(sharedOptions, mode, firstOpts);
+ }
+
+ /**
+ * @protected
+ */
+ getMaxOverflow() {
+ const meta = this._cachedMeta;
+ const data = meta.data || [];
+
+ if (!this.options.showLine) {
+ let max = 0;
+ for (let i = data.length - 1; i >= 0; --i) {
+ max = Math.max(max, data[i].size(this.resolveDataElementOptions(i)) / 2);
+ }
+ return max > 0 && max;
+ }
+
+ const dataset = meta.dataset;
+ const border = dataset.options && dataset.options.borderWidth || 0;
+
+ if (!data.length) {
+ return border;
+ }
+
+ const firstPoint = data[0].size(this.resolveDataElementOptions(0));
+ const lastPoint = data[data.length - 1].size(this.resolveDataElementOptions(data.length - 1));
+ return Math.max(border, firstPoint, lastPoint) / 2;
+ }
}
ScatterController.id = 'scatter';
@@ -10,6 +128,8 @@ ScatterController.id = 'scatter';
* @type {any}
*/
ScatterController.defaults = {
+ datasetElementType: false,
+ dataElementType: 'point',
showLine: false,
fill: false
}; | true |
Other | chartjs | Chart.js | 03e9194be5e899e36ac077d8e33be6921d1eae2a.json | feat: remove line element from scatter controller (#10439)
* feat: remove line element from scatter controller default config
* feat: move common controllers methods to helpers and add types
* feat: mark methods for scatter and line conntrollers as private
* fix: fix error when showline is true at root options and add tests
* feat: remove else inside scatter controller update
* fix: update getStartAndCountOFVisiblePoints helper code | src/helpers/helpers.extras.js | @@ -1,3 +1,5 @@
+import {_limitValue} from './helpers.math';
+import {_lookupByKey} from './helpers.collection';
export function fontString(pixelSize, fontStyle, fontFamily) {
return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;
@@ -87,3 +89,68 @@ export const _textX = (align, left, right, rtl) => {
const check = rtl ? 'left' : 'right';
return align === check ? right : align === 'center' ? (left + right) / 2 : left;
};
+
+/**
+ * Return start and count of visible points.
+ * @param {object} meta - dataset meta.
+ * @param {array} points - array of point elements.
+ * @param {boolean} animationsDisabled - if true animation is disabled.
+ * @returns {{start: number; count: number}}
+ * @private
+ */
+export function _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled) {
+ const pointCount = points.length;
+
+ let start = 0;
+ let count = pointCount;
+
+ if (meta._sorted) {
+ const {iScale, _parsed} = meta;
+ const axis = iScale.axis;
+ const {min, max, minDefined, maxDefined} = iScale.getUserBounds();
+
+ if (minDefined) {
+ start = _limitValue(Math.min(
+ _lookupByKey(_parsed, iScale.axis, min).lo,
+ animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo),
+ 0, pointCount - 1);
+ }
+ if (maxDefined) {
+ count = _limitValue(Math.max(
+ _lookupByKey(_parsed, iScale.axis, max, true).hi + 1,
+ animationsDisabled ? 0 : _lookupByKey(points, axis, iScale.getPixelForValue(max), true).hi + 1),
+ start, pointCount) - start;
+ } else {
+ count = pointCount - start;
+ }
+ }
+
+ return {start, count};
+}
+
+/**
+ * Checks if the scale ranges have changed.
+ * @param {object} meta - dataset meta.
+ * @returns {boolean}
+ * @private
+ */
+export function _scaleRangesChanged(meta) {
+ const {xScale, yScale, _scaleRanges} = meta;
+ const newRanges = {
+ xmin: xScale.min,
+ xmax: xScale.max,
+ ymin: yScale.min,
+ ymax: yScale.max
+ };
+ if (!_scaleRanges) {
+ meta._scaleRanges = newRanges;
+ return true;
+ }
+ const changed = _scaleRanges.xmin !== xScale.min
+ || _scaleRanges.xmax !== xScale.max
+ || _scaleRanges.ymin !== yScale.min
+ || _scaleRanges.ymax !== yScale.max;
+
+ Object.assign(_scaleRanges, newRanges);
+ return changed;
+} | true |
Other | chartjs | Chart.js | 03e9194be5e899e36ac077d8e33be6921d1eae2a.json | feat: remove line element from scatter controller (#10439)
* feat: remove line element from scatter controller default config
* feat: move common controllers methods to helpers and add types
* feat: mark methods for scatter and line conntrollers as private
* fix: fix error when showline is true at root options and add tests
* feat: remove else inside scatter controller update
* fix: update getStartAndCountOFVisiblePoints helper code | test/specs/controller.scatter.tests.js | @@ -61,4 +61,107 @@ describe('Chart.controllers.scatter', function() {
await jasmine.triggerMouseEvent(chart, 'mousemove', point);
expect(chart.tooltip.body.length).toEqual(1);
});
+
+ it('should not create line element by default', function() {
+ var chart = window.acquireChart({
+ type: 'scatter',
+ data: {
+ datasets: [{
+ data: [{
+ x: 10,
+ y: 15
+ },
+ {
+ x: 12,
+ y: 10
+ }],
+ label: 'dataset1'
+ },
+ {
+ data: [{
+ x: 20,
+ y: 10
+ },
+ {
+ x: 4,
+ y: 8
+ }],
+ label: 'dataset2'
+ }]
+ },
+ });
+
+ var meta = chart.getDatasetMeta(0);
+ expect(meta.dataset instanceof Chart.elements.LineElement).toBe(false);
+ });
+
+ it('should create line element if showline is true at datasets options', function() {
+ var chart = window.acquireChart({
+ type: 'scatter',
+ data: {
+ datasets: [{
+ showLine: true,
+ data: [{
+ x: 10,
+ y: 15
+ },
+ {
+ x: 12,
+ y: 10
+ }],
+ label: 'dataset1'
+ },
+ {
+ data: [{
+ x: 20,
+ y: 10
+ },
+ {
+ x: 4,
+ y: 8
+ }],
+ label: 'dataset2'
+ }]
+ },
+ });
+
+ var meta = chart.getDatasetMeta(0);
+ expect(meta.dataset instanceof Chart.elements.LineElement).toBe(true);
+ });
+
+ it('should create line element if showline is true at root options', function() {
+ var chart = window.acquireChart({
+ type: 'scatter',
+ data: {
+ datasets: [{
+ data: [{
+ x: 10,
+ y: 15
+ },
+ {
+ x: 12,
+ y: 10
+ }],
+ label: 'dataset1'
+ },
+ {
+ data: [{
+ x: 20,
+ y: 10
+ },
+ {
+ x: 4,
+ y: 8
+ }],
+ label: 'dataset2'
+ }]
+ },
+ options: {
+ showLine: true
+ }
+ });
+
+ var meta = chart.getDatasetMeta(0);
+ expect(meta.dataset instanceof Chart.elements.LineElement).toBe(true);
+ });
}); | true |
Other | chartjs | Chart.js | 844270eb5ec5d14b1786760fe288bfa0351d9d62.json | feat: pass some chart options to DateAdapter (#10528)
feat: pass some chart options to DateAdapter | src/core/core.adapters.js | @@ -4,6 +4,10 @@
* @private
*/
+/**
+ * @typedef { import("../../types/index.esm").ChartOptions } ChartOptions
+ */
+
/**
* @return {*}
*/
@@ -30,6 +34,13 @@ export class DateAdapter {
this.options = options || {};
}
+ /**
+ * Will called with chart options after adapter creation.
+ * @param {ChartOptions} chartOptions
+ */
+ // eslint-disable-next-line no-unused-vars
+ init(chartOptions) {}
+
/**
* Returns a map of time formats for the supported formatting units defined
* in Unit as well as 'datetime' representing a detailed date/time string. | true |
Other | chartjs | Chart.js | 844270eb5ec5d14b1786760fe288bfa0351d9d62.json | feat: pass some chart options to DateAdapter (#10528)
feat: pass some chart options to DateAdapter | src/scales/scale.time.js | @@ -223,6 +223,8 @@ export default class TimeScale extends Scale {
const time = scaleOpts.time || (scaleOpts.time = {});
const adapter = this._adapter = new adapters._date(scaleOpts.adapters.date);
+ adapter.init(opts);
+
// Backward compatibility: before introducing adapter, `displayFormats` was
// supposed to contain *all* unit/string pairs but this can't be resolved
// when loading the scale (adapters are loaded afterward), so let's populate | true |
Other | chartjs | Chart.js | 844270eb5ec5d14b1786760fe288bfa0351d9d62.json | feat: pass some chart options to DateAdapter (#10528)
feat: pass some chart options to DateAdapter | test/specs/scale.time.tests.js | @@ -1235,4 +1235,29 @@ describe('Time scale tests', function() {
});
});
});
+
+ it('should pass chart options to date adapter', function() {
+ let chartOptions;
+
+ Chart._adapters._date.override({
+ init(options) {
+ chartOptions = options;
+ }
+ });
+
+ var chart = window.acquireChart({
+ type: 'line',
+ data: {},
+ options: {
+ locale: 'es',
+ scales: {
+ x: {
+ type: 'time'
+ },
+ }
+ }
+ });
+
+ expect(chartOptions).toEqual(chart.options);
+ });
}); | true |
Other | chartjs | Chart.js | 844270eb5ec5d14b1786760fe288bfa0351d9d62.json | feat: pass some chart options to DateAdapter (#10528)
feat: pass some chart options to DateAdapter | types/adapters.d.ts | @@ -1,10 +1,17 @@
+import type { ChartOptions } from './index.esm';
+
export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
export interface DateAdapter {
// Override one or multiple of the methods to adjust to the logic of the current date library.
override(members: Partial<DateAdapter>): void;
readonly options: unknown;
+ /**
+ * Will called with chart options after adapter creation.
+ * @param {ChartOptions} chartOptions
+ */
+ init(chartOptions: ChartOptions): void;
/**
* Returns a map of time formats for the supported formatting units defined
* in Unit as well as 'datetime' representing a detailed date/time string. | true |
Other | chartjs | Chart.js | f0be17c85993aff79db293d6bdf5c7e07f90169f.json | Add circular prop to arc element (#10405)
* feat: add circular prop to arc element draw actions
* test: add test for arc element with circular:false prop
* feat: add circular prop to Arc element options
* docs: add decriptiption for new Polar area chart prop
* docs: fix circular prop description
* docs: add info about arc element circular prop to elements docs
* docs: move circular prop from general options to styling | docs/charts/polar.md | @@ -66,6 +66,7 @@ The following options can be included in a polar area chart dataset to configure
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderJoinStyle`](#interactions) | `'round'`\|`'bevel'`\|`'miter'` | Yes | Yes | `undefined`
| [`hoverBorderWidth`](#interactions) | `number` | Yes | Yes | `undefined`
+| [`circular`](#styling) | `boolean` | Yes | Yes | `true`
All these values, if `undefined`, fallback to the scopes described in [option resolution](../general/options)
@@ -85,6 +86,7 @@ The style of each arc can be controlled with the following properties:
| `borderColor` | arc border color.
| `borderJoinStyle` | arc border join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin).
| `borderWidth` | arc border width (in pixels).
+| `circular` | By default the Arc is curved. If `circular: false` the Arc will be flat.
All these values, if `undefined`, fallback to the associated [`elements.arc.*`](../configuration/elements.md#arc-configuration) options.
| true |
Other | chartjs | Chart.js | f0be17c85993aff79db293d6bdf5c7e07f90169f.json | Add circular prop to arc element (#10405)
* feat: add circular prop to arc element draw actions
* test: add test for arc element with circular:false prop
* feat: add circular prop to Arc element options
* docs: add decriptiption for new Polar area chart prop
* docs: fix circular prop description
* docs: add info about arc element circular prop to elements docs
* docs: move circular prop from general options to styling | docs/configuration/elements.md | @@ -101,3 +101,4 @@ Namespace: `options.elements.arc`, global arc options: `Chart.defaults.elements.
| `borderColor` | [`Color`](/general/colors.md) | `'#fff'` | Arc stroke color.
| `borderJoinStyle` | `'round'`\|`'bevel'`\|`'miter'` | `'bevel'`\|`'round'` | Line join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin). The default is `'round'` when `borderAlign` is `'inner'`
| `borderWidth`| `number` | `2` | Arc stroke width.
+| `circular` | `boolean` | `true` | By default the Arc is curved. If `circular: false` the Arc will be flat | true |
Other | chartjs | Chart.js | f0be17c85993aff79db293d6bdf5c7e07f90169f.json | Add circular prop to arc element (#10405)
* feat: add circular prop to arc element draw actions
* test: add test for arc element with circular:false prop
* feat: add circular prop to Arc element options
* docs: add decriptiption for new Polar area chart prop
* docs: fix circular prop description
* docs: add info about arc element circular prop to elements docs
* docs: move circular prop from general options to styling | src/elements/element.arc.js | @@ -93,7 +93,7 @@ function rThetaToXY(r, theta, x, y) {
* @param {CanvasRenderingContext2D} ctx
* @param {ArcElement} element
*/
-function pathArc(ctx, element, offset, spacing, end) {
+function pathArc(ctx, element, offset, spacing, end, circular) {
const {x, y, startAngle: start, pixelMargin, innerRadius: innerR} = element;
const outerRadius = Math.max(element.outerRadius + spacing + offset - pixelMargin, 0);
@@ -131,52 +131,64 @@ function pathArc(ctx, element, offset, spacing, end) {
ctx.beginPath();
- // The first arc segment from point 1 to point 2
- ctx.arc(x, y, outerRadius, outerStartAdjustedAngle, outerEndAdjustedAngle);
+ if (circular) {
+ // The first arc segment from point 1 to point 2
+ ctx.arc(x, y, outerRadius, outerStartAdjustedAngle, outerEndAdjustedAngle);
- // The corner segment from point 2 to point 3
- if (outerEnd > 0) {
- const pCenter = rThetaToXY(outerEndAdjustedRadius, outerEndAdjustedAngle, x, y);
- ctx.arc(pCenter.x, pCenter.y, outerEnd, outerEndAdjustedAngle, endAngle + HALF_PI);
- }
+ // The corner segment from point 2 to point 3
+ if (outerEnd > 0) {
+ const pCenter = rThetaToXY(outerEndAdjustedRadius, outerEndAdjustedAngle, x, y);
+ ctx.arc(pCenter.x, pCenter.y, outerEnd, outerEndAdjustedAngle, endAngle + HALF_PI);
+ }
- // The line from point 3 to point 4
- const p4 = rThetaToXY(innerEndAdjustedRadius, endAngle, x, y);
- ctx.lineTo(p4.x, p4.y);
+ // The line from point 3 to point 4
+ const p4 = rThetaToXY(innerEndAdjustedRadius, endAngle, x, y);
+ ctx.lineTo(p4.x, p4.y);
- // The corner segment from point 4 to point 5
- if (innerEnd > 0) {
- const pCenter = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);
- ctx.arc(pCenter.x, pCenter.y, innerEnd, endAngle + HALF_PI, innerEndAdjustedAngle + Math.PI);
- }
+ // The corner segment from point 4 to point 5
+ if (innerEnd > 0) {
+ const pCenter = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);
+ ctx.arc(pCenter.x, pCenter.y, innerEnd, endAngle + HALF_PI, innerEndAdjustedAngle + Math.PI);
+ }
- // The inner arc from point 5 to point 6
- ctx.arc(x, y, innerRadius, endAngle - (innerEnd / innerRadius), startAngle + (innerStart / innerRadius), true);
+ // The inner arc from point 5 to point 6
+ ctx.arc(x, y, innerRadius, endAngle - (innerEnd / innerRadius), startAngle + (innerStart / innerRadius), true);
- // The corner segment from point 6 to point 7
- if (innerStart > 0) {
- const pCenter = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);
- ctx.arc(pCenter.x, pCenter.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - HALF_PI);
- }
+ // The corner segment from point 6 to point 7
+ if (innerStart > 0) {
+ const pCenter = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);
+ ctx.arc(pCenter.x, pCenter.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - HALF_PI);
+ }
- // The line from point 7 to point 8
- const p8 = rThetaToXY(outerStartAdjustedRadius, startAngle, x, y);
- ctx.lineTo(p8.x, p8.y);
+ // The line from point 7 to point 8
+ const p8 = rThetaToXY(outerStartAdjustedRadius, startAngle, x, y);
+ ctx.lineTo(p8.x, p8.y);
- // The corner segment from point 8 to point 1
- if (outerStart > 0) {
- const pCenter = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);
- ctx.arc(pCenter.x, pCenter.y, outerStart, startAngle - HALF_PI, outerStartAdjustedAngle);
+ // The corner segment from point 8 to point 1
+ if (outerStart > 0) {
+ const pCenter = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);
+ ctx.arc(pCenter.x, pCenter.y, outerStart, startAngle - HALF_PI, outerStartAdjustedAngle);
+ }
+ } else {
+ ctx.moveTo(x, y);
+
+ const outerStartX = Math.cos(outerStartAdjustedAngle) * outerRadius + x;
+ const outerStartY = Math.sin(outerStartAdjustedAngle) * outerRadius + y;
+ ctx.lineTo(outerStartX, outerStartY);
+
+ const outerEndX = Math.cos(outerEndAdjustedAngle) * outerRadius + x;
+ const outerEndY = Math.sin(outerEndAdjustedAngle) * outerRadius + y;
+ ctx.lineTo(outerEndX, outerEndY);
}
ctx.closePath();
}
-function drawArc(ctx, element, offset, spacing) {
+function drawArc(ctx, element, offset, spacing, circular) {
const {fullCircles, startAngle, circumference} = element;
let endAngle = element.endAngle;
if (fullCircles) {
- pathArc(ctx, element, offset, spacing, startAngle + TAU);
+ pathArc(ctx, element, offset, spacing, startAngle + TAU, circular);
for (let i = 0; i < fullCircles; ++i) {
ctx.fill();
@@ -189,8 +201,7 @@ function drawArc(ctx, element, offset, spacing) {
}
}
}
-
- pathArc(ctx, element, offset, spacing, endAngle);
+ pathArc(ctx, element, offset, spacing, endAngle, circular);
ctx.fill();
return endAngle;
}
@@ -219,7 +230,7 @@ function drawFullCircleBorders(ctx, element, inner) {
}
}
-function drawBorder(ctx, element, offset, spacing, endAngle) {
+function drawBorder(ctx, element, offset, spacing, endAngle, circular) {
const {options} = element;
const {borderWidth, borderJoinStyle} = options;
const inner = options.borderAlign === 'inner';
@@ -244,7 +255,7 @@ function drawBorder(ctx, element, offset, spacing, endAngle) {
clipArc(ctx, element, endAngle);
}
- pathArc(ctx, element, offset, spacing, endAngle);
+ pathArc(ctx, element, offset, spacing, endAngle, circular);
ctx.stroke();
}
@@ -323,6 +334,7 @@ export default class ArcElement extends Element {
const {options, circumference} = this;
const offset = (options.offset || 0) / 2;
const spacing = (options.spacing || 0) / 2;
+ const circular = options.circular;
this.pixelMargin = (options.borderAlign === 'inner') ? 0.33 : 0;
this.fullCircles = circumference > TAU ? Math.floor(circumference / TAU) : 0;
@@ -345,8 +357,8 @@ export default class ArcElement extends Element {
ctx.fillStyle = options.backgroundColor;
ctx.strokeStyle = options.borderColor;
- const endAngle = drawArc(ctx, this, radiusOffset, spacing);
- drawBorder(ctx, this, radiusOffset, spacing, endAngle);
+ const endAngle = drawArc(ctx, this, radiusOffset, spacing, circular);
+ drawBorder(ctx, this, radiusOffset, spacing, endAngle, circular);
ctx.restore();
}
@@ -366,6 +378,7 @@ ArcElement.defaults = {
offset: 0,
spacing: 0,
angle: undefined,
+ circular: true,
};
/** | true |
Other | chartjs | Chart.js | f0be17c85993aff79db293d6bdf5c7e07f90169f.json | Add circular prop to arc element (#10405)
* feat: add circular prop to arc element draw actions
* test: add test for arc element with circular:false prop
* feat: add circular prop to Arc element options
* docs: add decriptiption for new Polar area chart prop
* docs: fix circular prop description
* docs: add info about arc element circular prop to elements docs
* docs: move circular prop from general options to styling | test/specs/element.arc.tests.js | @@ -218,4 +218,36 @@ describe('Arc element tests', function() {
expect(ctx.getCalls().length).toBe(0);
});
+
+ it('should draw when circular: false', function() {
+ var arc = new Chart.elements.ArcElement({
+ startAngle: 0,
+ endAngle: Math.PI * 2,
+ x: 2,
+ y: 2,
+ innerRadius: 0,
+ outerRadius: 2,
+ options: {
+ spacing: 0,
+ offset: 0,
+ scales: {
+ r: {
+ grid: {
+ circular: false,
+ },
+ },
+ },
+ elements: {
+ arc: {
+ circular: false
+ },
+ },
+ }
+ });
+
+ var ctx = window.createMockContext();
+ arc.draw(ctx);
+
+ expect(ctx.getCalls().length).toBeGreaterThan(0);
+ });
}); | true |
Other | chartjs | Chart.js | f0be17c85993aff79db293d6bdf5c7e07f90169f.json | Add circular prop to arc element (#10405)
* feat: add circular prop to arc element draw actions
* test: add test for arc element with circular:false prop
* feat: add circular prop to Arc element options
* docs: add decriptiption for new Polar area chart prop
* docs: fix circular prop description
* docs: add info about arc element circular prop to elements docs
* docs: move circular prop from general options to styling | types/index.esm.d.ts | @@ -1746,6 +1746,12 @@ export interface ArcOptions extends CommonElementOptions {
* Arc offset (in pixels).
*/
offset: number;
+
+ /**
+ * If false, Arc will be flat.
+ * @default true
+ */
+ circular: boolean;
}
export interface ArcHoverOptions extends CommonHoverOptions { | true |
Other | chartjs | Chart.js | 1fef75d990ccdb557f19d9be5e67f217d8b5c90d.json | Skip all borders if borderSkipped === true (#10530)
* Skip all borders if borderSkipped === true
This will allow you to skip all borders (not just one side) if you set borderSkipped to boolean true and so allow you to have a consistent legend marker even for bars without borders. Reason is that even if same colored borders are set there are artifacts that make the bar look bad and also even with inflateAmount the bars do look good when big but when only a few pixel in size they start to look bad too so this was the only way for me to make it work so legends are looking good and bars too.
* fix failing test, update docs and typings
* update typing comment
Co-authored-by: Istvan Petres <pijulius@users.noreply.github.com> | docs/charts/bar.md | @@ -74,7 +74,7 @@ Only the `data` option needs to be specified in the dataset namespace.
| [`barPercentage`](#barpercentage) | `number` | - | - | `0.9` |
| [`barThickness`](#barthickness) | `number`\|`string` | - | - | |
| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
-| [`borderSkipped`](#borderskipped) | `string` | Yes | Yes | `'start'`
+| [`borderSkipped`](#borderskipped) | `string`\|`boolean` | Yes | Yes | `'start'`
| [`borderWidth`](#borderwidth) | `number`\|`object` | Yes | Yes | `0`
| [`borderRadius`](#borderradius) | `number`\|`object` | Yes | Yes | `0`
| [`categoryPercentage`](#categorypercentage) | `number` | - | - | `0.8` |
@@ -163,7 +163,8 @@ Options are:
* `'left'`
* `'top'`
* `'right'`
-* `false`
+* `false` (don't skip any borders)
+* `true` (skip all borders)
#### borderWidth
| true |
Other | chartjs | Chart.js | 1fef75d990ccdb557f19d9be5e67f217d8b5c90d.json | Skip all borders if borderSkipped === true (#10530)
* Skip all borders if borderSkipped === true
This will allow you to skip all borders (not just one side) if you set borderSkipped to boolean true and so allow you to have a consistent legend marker even for bars without borders. Reason is that even if same colored borders are set there are artifacts that make the bar look bad and also even with inflateAmount the bars do look good when big but when only a few pixel in size they start to look bad too so this was the only way for me to make it work so legends are looking good and bars too.
* fix failing test, update docs and typings
* update typing comment
Co-authored-by: Istvan Petres <pijulius@users.noreply.github.com> | src/controllers/controller.bar.js | @@ -208,6 +208,11 @@ function setBorderSkipped(properties, options, stack, index) {
return;
}
+ if (edge === true) {
+ properties.borderSkipped = {top: true, right: true, bottom: true, left: true};
+ return;
+ }
+
const {start, end, reverse, top, bottom} = borderProps(properties);
if (edge === 'middle' && stack) { | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.