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
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/fixtures/plugin.legend/legend-doughnut-right-center-mulitiline.json
@@ -10,9 +10,11 @@ }] }, "options": { - "legend": { - "position": "right", - "align": "center" + "plugins": { + "legend": { + "position": "right", + "align": "center" + } } } },
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/fixtures/plugin.legend/legend-doughnut-right-center-single.json
@@ -10,9 +10,11 @@ }] }, "options": { - "legend": { - "position": "right", - "align": "center" + "plugins": { + "legend": { + "position": "right", + "align": "center" + } } } },
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/fixtures/plugin.legend/legend-doughnut-right-default-center.json
@@ -10,8 +10,10 @@ }] }, "options": { - "legend": { - "position": "right" + "plugins": { + "legend": { + "position": "right" + } } } },
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/fixtures/plugin.legend/legend-doughnut-right-end-mulitiline.json
@@ -10,9 +10,11 @@ }] }, "options": { - "legend": { - "position": "right", - "align": "end" + "plugins": { + "legend": { + "position": "right", + "align": "end" + } } } },
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/fixtures/plugin.legend/legend-doughnut-right-start-mulitiline.json
@@ -10,9 +10,11 @@ }] }, "options": { - "legend": { - "position": "right", - "align": "start" + "plugins": { + "legend": { + "position": "right", + "align": "start" + } } } },
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/fixtures/plugin.legend/legend-doughnut-top-center-mulitiline.json
@@ -10,9 +10,11 @@ }] }, "options": { - "legend": { - "position": "top", - "align": "center" + "plugins": { + "legend": { + "position": "top", + "align": "center" + } } } },
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/fixtures/plugin.legend/legend-doughnut-top-center-single.json
@@ -10,9 +10,11 @@ }] }, "options": { - "legend": { - "position": "top", - "align": "center" + "plugins": { + "legend": { + "position": "top", + "align": "center" + } } } },
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/fixtures/plugin.legend/legend-doughnut-top-end-mulitiline.json
@@ -10,9 +10,11 @@ }] }, "options": { - "legend": { - "position": "top", - "align": "end" + "plugins": { + "legend": { + "position": "top", + "align": "end" + } } } },
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/fixtures/plugin.legend/legend-doughnut-top-start-mulitiline.json
@@ -10,9 +10,11 @@ }] }, "options": { - "legend": { - "position": "top", - "align": "start" + "plugins": { + "legend": { + "position": "top", + "align": "start" + } } } },
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/controller.bar.tests.js
@@ -590,8 +590,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, elements: { bar: { backgroundColor: 'red', @@ -664,8 +666,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category', @@ -704,8 +708,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category', @@ -748,8 +754,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category', @@ -807,8 +815,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category', @@ -868,8 +878,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category', @@ -927,8 +939,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category', @@ -988,8 +1002,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category', @@ -1047,8 +1063,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category', @@ -1093,8 +1111,10 @@ describe('Chart.controllers.bar', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category', @@ -1542,8 +1562,10 @@ describe('Chart.controllers.bar', function() { labels: ['A', 'B', 'C', 'D'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category',
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/controller.bubble.tests.js
@@ -115,8 +115,10 @@ describe('Chart.controllers.bubble', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { type: 'category',
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/controller.doughnut.tests.js
@@ -61,8 +61,10 @@ describe('Chart.controllers.doughnut', function() { labels: ['label0', 'label1', 'label2', 'label3'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false, + }, animation: { duration: 0, animateRotate: true, @@ -163,8 +165,10 @@ describe('Chart.controllers.doughnut', function() { labels: ['label0', 'label1', 'label2'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false, + }, cutoutPercentage: 50, rotation: 270, circumference: 90, @@ -207,8 +211,10 @@ describe('Chart.controllers.doughnut', function() { labels: ['label0', 'label1'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, cutoutPercentage: 50, rotation: 270, circumference: 90, @@ -281,8 +287,10 @@ describe('Chart.controllers.doughnut', function() { labels: ['label0', 'label1'] }, options: { - legend: false, - title: false + plugins: { + legend: false, + title: false + } } });
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/controller.line.tests.js
@@ -110,8 +110,10 @@ describe('Chart.controllers.line', function() { }, options: { showLine: true, - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, elements: { point: { backgroundColor: 'red', @@ -167,8 +169,10 @@ describe('Chart.controllers.line', function() { }] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, hover: { mode: 'nearest', intersect: true @@ -238,8 +242,10 @@ describe('Chart.controllers.line', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { display: false, @@ -296,8 +302,10 @@ describe('Chart.controllers.line', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false, + }, scales: { x: { display: false, @@ -379,8 +387,10 @@ describe('Chart.controllers.line', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { display: false, @@ -433,8 +443,10 @@ describe('Chart.controllers.line', function() { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, scales: { x: { display: false,
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/controller.polarArea.tests.js
@@ -87,8 +87,10 @@ describe('Chart.controllers.polarArea', function() { }, options: { showLine: true, - legend: false, - title: false, + plugins: { + legend: false, + title: false + }, elements: { arc: { backgroundColor: 'rgb(255, 0, 0)', @@ -154,8 +156,10 @@ describe('Chart.controllers.polarArea', function() { }, options: { showLine: true, - legend: false, - title: false, + plugins: { + legend: false, + title: false, + }, startAngle: 90, // default is 0 elements: { arc: {
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/controller.radar.tests.js
@@ -85,8 +85,10 @@ describe('Chart.controllers.radar', function() { }, options: { showLine: true, - legend: false, - title: false, + plugins: { + legend: false, + title: false, + }, elements: { line: { backgroundColor: 'rgb(255, 0, 0)',
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/core.controller.tests.js
@@ -153,8 +153,10 @@ describe('Chart', function() { hover: { mode: 'dataset', }, - title: { - position: 'bottom' + plugins: { + title: { + position: 'bottom' + } } } }); @@ -163,7 +165,7 @@ describe('Chart', function() { expect(options.showLine).toBe(defaults.showLine); expect(options.spanGaps).toBe(false); expect(options.hover.mode).toBe('dataset'); - expect(options.title.position).toBe('bottom'); + expect(options.plugins.title.position).toBe('bottom'); defaults.hover.onHover = null; delete defaults.controllers.line.hover.mode; @@ -1298,7 +1300,7 @@ describe('Chart', function() { mode: 'dataset', intersect: false }; - chart.options.tooltips = newTooltipConfig; + chart.options.plugins.tooltip = newTooltipConfig; chart.update(); expect(chart.tooltip.options).toEqual(jasmine.objectContaining(newTooltipConfig));
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/core.layouts.tests.js
@@ -262,11 +262,9 @@ describe('Chart.layouts', function() { display: false } }, - legend: { - display: false - }, - title: { - display: false + plugins: { + legend: false, + title: false }, layout: { padding: 10 @@ -307,11 +305,9 @@ describe('Chart.layouts', function() { display: false } }, - legend: { - display: false - }, - title: { - display: false + plugins: { + legend: false, + title: false }, layout: { padding: { @@ -357,11 +353,9 @@ describe('Chart.layouts', function() { display: false } }, - legend: { - display: false - }, - title: { - display: false + plugins: { + legend: false, + title: false }, layout: { padding: {} @@ -394,14 +388,16 @@ describe('Chart.layouts', function() { labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5', 'tick6'] }, options: { - legend: { - display: true, - position: 'left', - }, - title: { - display: true, - position: 'bottom', - }, + plugins: { + legend: { + display: true, + position: 'left', + }, + title: { + display: true, + position: 'bottom', + }, + } }, }, { canvas: { @@ -555,8 +551,8 @@ describe('Chart.layouts', function() { }], }, options: { - legend: { - display: false, + plugins: { + legend: false }, }, }, {
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/core.scale.tests.js
@@ -143,8 +143,8 @@ describe('Core.scale', function() { display: false } }, - legend: { - display: false + plugins: { + legend: false } } }); @@ -188,8 +188,8 @@ describe('Core.scale', function() { offset: test.offset } }, - legend: { - display: false + plugins: { + legend: false } } }); @@ -224,8 +224,8 @@ describe('Core.scale', function() { display: false } }, - legend: { - display: false + plugins: { + legend: false } } }, {
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/core.ticks.tests.js
@@ -20,8 +20,8 @@ describe('Test tick generators', function() { }], }, options: { - legend: { - display: false, + plugins: { + legend: false }, scales: { x: { @@ -61,8 +61,8 @@ describe('Test tick generators', function() { }], }, options: { - legend: { - display: false, + plugins: { + legend: false }, scales: { x: {
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/global.defaults.tests.js
@@ -147,12 +147,12 @@ describe('Default Configs', function() { spyOn(chart, 'update').and.callThrough(); var legendItem = chart.legend.legendItems[0]; - config.legend.onClick(null, legendItem, chart.legend); + config.plugins.legend.onClick(null, legendItem, chart.legend); expect(chart.getDataVisibility(0)).toBe(false); expect(chart.update).toHaveBeenCalled(); - config.legend.onClick(null, legendItem, chart.legend); + config.plugins.legend.onClick(null, legendItem, chart.legend); expect(chart.getDataVisibility(0)).toBe(true); }); }); @@ -243,12 +243,12 @@ describe('Default Configs', function() { spyOn(chart, 'update').and.callThrough(); var legendItem = chart.legend.legendItems[0]; - config.legend.onClick(null, legendItem, chart.legend); + config.plugins.legend.onClick(null, legendItem, chart.legend); expect(chart.getDataVisibility(0)).toBe(false); expect(chart.update).toHaveBeenCalled(); - config.legend.onClick(null, legendItem, chart.legend); + config.plugins.legend.onClick(null, legendItem, chart.legend); expect(chart.getDataVisibility(0)).toBe(true); }); });
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/plugin.legend.tests.js
@@ -196,8 +196,10 @@ describe('Legend block tests', function() { labels: [] }, options: { - legend: { - reverse: true + plugins: { + legend: { + reverse: true + } } } }); @@ -271,11 +273,13 @@ describe('Legend block tests', function() { labels: [] }, options: { - legend: { - labels: { - filter: function(legendItem, data) { - var dataset = data.datasets[legendItem.datasetIndex]; - return !dataset.legendHidden; + plugins: { + legend: { + labels: { + filter: function(legendItem, data) { + var dataset = data.datasets[legendItem.datasetIndex]; + return !dataset.legendHidden; + } } } } @@ -338,10 +342,12 @@ describe('Legend block tests', function() { labels: [] }, options: { - legend: { - labels: { - sort: function(a, b) { - return b.datasetIndex > a.datasetIndex ? 1 : -1; + plugins: { + legend: { + labels: { + sort: function(a, b) { + return b.datasetIndex > a.datasetIndex ? 1 : -1; + } } } } @@ -406,8 +412,10 @@ describe('Legend block tests', function() { labels: [] }, options: { - legend: { - labels: false, + plugins: { + legend: { + labels: false, + } } } }); @@ -429,8 +437,10 @@ describe('Legend block tests', function() { labels: [] }, options: { - legend: { - position: 'right' + plugins: { + legend: { + position: 'right' + } } } }, @@ -464,10 +474,12 @@ describe('Legend block tests', function() { labels: [] }, options: { - legend: { - position: 'right', - labels: { - boxHeight: 40 + plugins: { + legend: { + position: 'right', + labels: { + boxHeight: 40 + } } } } @@ -585,9 +597,11 @@ describe('Legend block tests', function() { labels: [] }, options: { - legend: { - labels: { - usePointStyle: true + plugins: { + legend: { + labels: { + usePointStyle: true + } } } } @@ -652,10 +666,12 @@ describe('Legend block tests', function() { labels: [] }, options: { - legend: { - labels: { - usePointStyle: true, - pointStyle: 'star' + plugins: { + legend: { + labels: { + usePointStyle: true, + pointStyle: 'star' + } } } } @@ -701,14 +717,16 @@ describe('Legend block tests', function() { }] }, options: { - legend: { - display: true + plugins: { + legend: { + display: true + } } } }); expect(chart.legend.options.display).toBe(true); - chart.options.legend.display = false; + chart.options.plugins.legend.display = false; chart.update(); expect(chart.legend.options.display).toBe(false); }); @@ -718,10 +736,12 @@ describe('Legend block tests', function() { type: 'line', data: {}, options: { - legend: { - fullWidth: true, - position: 'top', - weight: 150 + plugins: { + legend: { + fullWidth: true, + position: 'top', + weight: 150 + } } } }); @@ -730,17 +750,17 @@ describe('Legend block tests', function() { expect(chart.legend.position).toBe('top'); expect(chart.legend.weight).toBe(150); - chart.options.legend.fullWidth = false; - chart.options.legend.position = 'left'; - chart.options.legend.weight = 42; + chart.options.plugins.legend.fullWidth = false; + chart.options.plugins.legend.position = 'left'; + chart.options.plugins.legend.weight = 42; chart.update(); expect(chart.legend.fullWidth).toBe(false); expect(chart.legend.position).toBe('left'); expect(chart.legend.weight).toBe(42); }); - it ('should remove the legend if the new options are false', function() { + xit ('should remove the legend if the new options are false', function() { var chart = acquireChart({ type: 'line', data: { @@ -752,7 +772,7 @@ describe('Legend block tests', function() { }); expect(chart.legend).not.toBe(undefined); - chart.options.legend = false; + chart.options.plugins.legend = false; chart.update(); expect(chart.legend).toBe(undefined); }); @@ -767,12 +787,14 @@ describe('Legend block tests', function() { }] }, options: { - legend: false + plugins: { + legend: false + } } }); expect(chart.legend).toBe(undefined); - chart.options.legend = {}; + chart.options.plugins.legend = {}; chart.update(); expect(chart.legend).not.toBe(undefined); expect(chart.legend.options).toEqual(jasmine.objectContaining(Chart.defaults.plugins.legend)); @@ -794,15 +816,17 @@ describe('Legend block tests', function() { }] }, options: { - legend: { - onClick: function(_, item) { - clickItem = item; - }, - onHover: function(_, item) { - hoverItem = item; - }, - onLeave: function(_, item) { - leaveItem = item; + plugins: { + legend: { + onClick: function(_, item) { + clickItem = item; + }, + onHover: function(_, item) { + hoverItem = item; + }, + onLeave: function(_, item) { + leaveItem = item; + } } } }
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/plugin.title.tests.js
@@ -252,14 +252,16 @@ describe('Title block tests', function() { }] }, options: { - title: { - display: true + plugins: { + title: { + display: true + } } } }); expect(chart.titleBlock.options.display).toBe(true); - chart.options.title.display = false; + chart.options.plugins.title.display = false; chart.update(); expect(chart.titleBlock.options.display).toBe(false); }); @@ -269,10 +271,12 @@ describe('Title block tests', function() { type: 'line', data: {}, options: { - title: { - fullWidth: true, - position: 'top', - weight: 150 + plugins: { + title: { + fullWidth: true, + position: 'top', + weight: 150 + } } } }); @@ -281,17 +285,17 @@ describe('Title block tests', function() { expect(chart.titleBlock.position).toBe('top'); expect(chart.titleBlock.weight).toBe(150); - chart.options.title.fullWidth = false; - chart.options.title.position = 'left'; - chart.options.title.weight = 42; + chart.options.plugins.title.fullWidth = false; + chart.options.plugins.title.position = 'left'; + chart.options.plugins.title.weight = 42; chart.update(); expect(chart.titleBlock.fullWidth).toBe(false); expect(chart.titleBlock.position).toBe('left'); expect(chart.titleBlock.weight).toBe(42); }); - it ('should remove the title if the new options are false', function() { + xit ('should remove the title if the new options are false', function() { var chart = acquireChart({ type: 'line', data: { @@ -303,7 +307,7 @@ describe('Title block tests', function() { }); expect(chart.titleBlock).not.toBe(undefined); - chart.options.title = false; + chart.options.plugins.title = false; chart.update(); expect(chart.titleBlock).toBe(undefined); }); @@ -318,12 +322,14 @@ describe('Title block tests', function() { }] }, options: { - title: false + plugins: { + title: false + } } }); expect(chart.titleBlock).toBe(undefined); - chart.options.title = {}; + chart.options.plugins.title = {}; chart.update(); expect(chart.titleBlock).not.toBe(undefined); expect(chart.titleBlock.options).toEqual(jasmine.objectContaining(Chart.defaults.plugins.title));
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/plugin.tooltip.tests.js
@@ -51,9 +51,11 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'index', - intersect: false, + plugins: { + tooltip: { + mode: 'index', + intersect: false, + } }, hover: { mode: 'index', @@ -176,9 +178,11 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'index', - intersect: true + plugins: { + tooltip: { + mode: 'index', + intersect: true + } } } }); @@ -219,9 +223,11 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'nearest', - intersect: true + plugins: { + tooltip: { + mode: 'nearest', + intersect: true + } } } }); @@ -328,50 +334,52 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'index', - callbacks: { - beforeTitle: function() { - return 'beforeTitle'; - }, - title: function() { - return 'title'; - }, - afterTitle: function() { - return 'afterTitle'; - }, - beforeBody: function() { - return 'beforeBody'; - }, - beforeLabel: function() { - return 'beforeLabel'; - }, - label: function() { - return 'label'; - }, - afterLabel: function() { - return 'afterLabel'; - }, - afterBody: function() { - return 'afterBody'; - }, - beforeFooter: function() { - return 'beforeFooter'; - }, - footer: function() { - return 'footer'; - }, - afterFooter: function() { - return 'afterFooter'; - }, - labelTextColor: function() { - return 'labelTextColor'; - }, - labelPointStyle: function() { - return { - pointStyle: 'labelPointStyle', - rotation: 42 - }; + plugins: { + tooltip: { + mode: 'index', + callbacks: { + beforeTitle: function() { + return 'beforeTitle'; + }, + title: function() { + return 'title'; + }, + afterTitle: function() { + return 'afterTitle'; + }, + beforeBody: function() { + return 'beforeBody'; + }, + beforeLabel: function() { + return 'beforeLabel'; + }, + label: function() { + return 'label'; + }, + afterLabel: function() { + return 'afterLabel'; + }, + afterBody: function() { + return 'afterBody'; + }, + beforeFooter: function() { + return 'beforeFooter'; + }, + footer: function() { + return 'footer'; + }, + afterFooter: function() { + return 'afterFooter'; + }, + labelTextColor: function() { + return 'labelTextColor'; + }, + labelPointStyle: function() { + return { + pointStyle: 'labelPointStyle', + rotation: 42 + }; + } } } } @@ -493,11 +501,13 @@ describe('Plugin.Tooltip', function() { type: 'linear' } }, - tooltips: { - mode: 'index', - callbacks: { - beforeLabel: function(ctx) { - return ctx.dataPoint.x + ',' + ctx.dataPoint.y; + plugins: { + tooltip: { + mode: 'index', + callbacks: { + beforeLabel: function(ctx) { + return ctx.dataPoint.x + ',' + ctx.dataPoint.y; + } } } } @@ -536,10 +546,12 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'index', - itemSort: function(a, b) { - return a.datasetIndex > b.datasetIndex ? -1 : 1; + plugins: { + tooltip: { + mode: 'index', + itemSort: function(a, b) { + return a.datasetIndex > b.datasetIndex ? -1 : 1; + } } } } @@ -609,9 +621,11 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'index', - reverse: true + plugins: { + tooltip: { + mode: 'index', + reverse: true + } } } }); @@ -682,8 +696,10 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'index' + plugins: { + tooltip: { + mode: 'index' + } } } }); @@ -753,11 +769,13 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'index', - filter: function(tooltipItem, index, tooltipItems, data) { - // For testing purposes remove the first dataset that has a tooltipHidden property - return !data.datasets[tooltipItem.datasetIndex].tooltipHidden; + plugins: { + tooltip: { + mode: 'index', + filter: function(tooltipItem, index, tooltipItems, data) { + // For testing purposes remove the first dataset that has a tooltipHidden property + return !data.datasets[tooltipItem.datasetIndex].tooltipHidden; + } } } } @@ -818,8 +836,10 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - caretPadding: 10 + plugins: { + tooltip: { + caretPadding: 10 + } } } }); @@ -862,9 +882,11 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'nearest', - intersect: true + plugins: { + tooltip: { + mode: 'nearest', + intersect: true + } } } }); @@ -916,12 +938,14 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'nearest', - intersect: true, - callbacks: { - title: function() { - return 'registering callback...'; + plugins: { + tooltip: { + mode: 'nearest', + intersect: true, + callbacks: { + title: function() { + return 'registering callback...'; + } } } } @@ -979,13 +1003,15 @@ describe('Plugin.Tooltip', function() { stacked: true } }, - tooltips: { - mode: 'nearest', - position: 'nearest', - intersect: true, - callbacks: { - title: function() { - return 'registering callback...'; + plugins: { + tooltip: { + mode: 'nearest', + position: 'nearest', + intersect: true, + callbacks: { + title: function() { + return 'registering callback...'; + } } } } @@ -1047,9 +1073,11 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'nearest', - position: 'test' + plugins: { + tooltip: { + mode: 'nearest', + position: 'test' + } } } }); @@ -1100,8 +1128,10 @@ describe('Plugin.Tooltip', function() { // without this slice center point is calculated wrong animateRotate: false }, - tooltips: { - animation: false + plugins: { + tooltip: { + animation: false + } } } }); @@ -1164,44 +1194,46 @@ describe('Plugin.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { - tooltips: { - mode: 'index', - callbacks: { - beforeTitle: function() { - return 'beforeTitle\nnewline'; - }, - title: function() { - return 'title\nnewline'; - }, - afterTitle: function() { - return 'afterTitle\nnewline'; - }, - beforeBody: function() { - return 'beforeBody\nnewline'; - }, - beforeLabel: function() { - return 'beforeLabel\nnewline'; - }, - label: function() { - return 'label'; - }, - afterLabel: function() { - return 'afterLabel\nnewline'; - }, - afterBody: function() { - return 'afterBody\nnewline'; - }, - beforeFooter: function() { - return 'beforeFooter\nnewline'; - }, - footer: function() { - return 'footer\nnewline'; - }, - afterFooter: function() { - return 'afterFooter\nnewline'; - }, - labelTextColor: function() { - return 'labelTextColor'; + plugins: { + tooltip: { + mode: 'index', + callbacks: { + beforeTitle: function() { + return 'beforeTitle\nnewline'; + }, + title: function() { + return 'title\nnewline'; + }, + afterTitle: function() { + return 'afterTitle\nnewline'; + }, + beforeBody: function() { + return 'beforeBody\nnewline'; + }, + beforeLabel: function() { + return 'beforeLabel\nnewline'; + }, + label: function() { + return 'label'; + }, + afterLabel: function() { + return 'afterLabel\nnewline'; + }, + afterBody: function() { + return 'afterBody\nnewline'; + }, + beforeFooter: function() { + return 'beforeFooter\nnewline'; + }, + footer: function() { + return 'footer\nnewline'; + }, + afterFooter: function() { + return 'afterFooter\nnewline'; + }, + labelTextColor: function() { + return 'labelTextColor'; + } } } } @@ -1407,8 +1439,10 @@ describe('Plugin.Tooltip', function() { var tooltip = new Tooltip({ _chart: { options: { - tooltips: { - animation: false, + plugins: { + tooltip: { + animation: false, + } } } }
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
test/specs/scale.time.tests.js
@@ -1107,7 +1107,9 @@ describe('Time scale tests', function() { } } }, - legend: false + plugins: { + legend: false + } }); const scale = chart.scales.x; expect(scale.getPixelForDecimal(0)).toBeCloseToPixel(29);
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
types/core/index.d.ts
@@ -25,7 +25,7 @@ import { ScaleType } from '../interfaces'; import { ElementChartOptions } from '../elements'; -import { PluginOptions, PluginChartOptions } from '../plugins'; +import { PluginOptions } from '../plugins'; export interface DateAdapterBase { /** @@ -338,7 +338,6 @@ export interface Defaults extends CoreChartOptions, ElementChartOptions { controllers: { [key in ChartType]: DeepPartial< CoreChartOptions & - PluginChartOptions & ElementChartOptions & DatasetChartOptions<key>[key] & ScaleChartOptions<key> & @@ -377,7 +376,7 @@ export interface Defaults extends CoreChartOptions, ElementChartOptions { route(scope: string, name: string, targetScope: string, targetName: string): void; } -export const defaults: Defaults & DeepPartial<PluginChartOptions>; +export const defaults: Defaults; export interface Element<T = {}, O = {}> { readonly x: number;
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
types/interfaces.d.ts
@@ -22,7 +22,7 @@ import { } from './controllers'; import { CoreChartOptions } from './core/interfaces'; import { ElementChartOptions } from './elements'; -import { FillerControllerDatasetOptions, PluginChartOptions } from './plugins'; +import { FillerControllerDatasetOptions } from './plugins'; import { Plugin } from './core'; import { LinearScaleOptions, @@ -140,7 +140,6 @@ export type ScaleChartOptions<TType extends ChartType = ChartType> = { export type ChartOptions<TType extends ChartType = ChartType> = DeepPartial< CoreChartOptions & - PluginChartOptions & ElementChartOptions & DatasetChartOptions<TType> & ScaleChartOptions<TType> &
true
Other
chartjs
Chart.js
913a01a3a629c5249850c66857ca5f7c76b9f322.json
Move title, tooltip and legend to options.plugins (#8089) * Move title, tooltip and legend to options.plugins * Update tooltip.md * Update legend.md and title.md * Add migration notes * typo * Types * Restore plurals * One more s, restore tabs * All plugins disabled * lint * cc
types/plugins/index.d.ts
@@ -201,10 +201,6 @@ export interface LegendOptions { }; } -export interface LegendChartOptions { - legend: LegendOptions; -} - export const Title: Plugin; export interface TitleOptions { @@ -235,10 +231,6 @@ export interface TitleOptions { text: string | string[]; } -export interface TitleChartOptions { - title: TitleOptions; -} - export type TooltipAlignment = 'start' | 'center' | 'end'; export interface TooltipModel { @@ -506,10 +498,6 @@ export interface TooltipOptions extends CoreInteractionOptions { callbacks: TooltipCallbacks; } -export interface TooltipChartOptions { - tooltips: TooltipOptions; -} - export interface TooltipItem { /** * The chart the tooltip is being shown on @@ -558,6 +546,3 @@ export interface PluginOptions { title: TitleOptions; tooltip: TooltipOptions; } - -export interface PluginChartOptions extends LegendChartOptions, TitleChartOptions, TooltipChartOptions { -}
true
Other
chartjs
Chart.js
2efffb8ae4b86045100252186cadaf41a1b1d93e.json
Improve test coverage (#8087) * Remove usage of currentStyle (IE only) * Nothing is registered in root scope anymore * Add some more tests for animations * Add some more tests to defaults
src/core/core.typedRegistry.js
@@ -70,8 +70,6 @@ export default class TypedRegistry { if (scope && id in defaults[scope]) { delete defaults[scope][id]; - } else if (id in defaults) { - delete defaults[id]; } } }
true
Other
chartjs
Chart.js
2efffb8ae4b86045100252186cadaf41a1b1d93e.json
Improve test coverage (#8087) * Remove usage of currentStyle (IE only) * Nothing is registered in root scope anymore * Add some more tests for animations * Add some more tests to defaults
src/helpers/helpers.dom.js
@@ -34,9 +34,7 @@ function parseMaxStyle(styleValue, node, parentProperty) { const getComputedStyle = (element) => window.getComputedStyle(element, null); export function getStyle(el, property) { - return el.currentStyle ? - el.currentStyle[property] : - getComputedStyle(el).getPropertyValue(property); + return getComputedStyle(el).getPropertyValue(property); } const positions = ['top', 'right', 'bottom', 'left'];
true
Other
chartjs
Chart.js
2efffb8ae4b86045100252186cadaf41a1b1d93e.json
Improve test coverage (#8087) * Remove usage of currentStyle (IE only) * Nothing is registered in root scope anymore * Add some more tests for animations * Add some more tests to defaults
test/specs/core.animations.tests.js
@@ -44,6 +44,23 @@ describe('Chart.animations', function() { })).toBeUndefined(); }); + it('should assing options directly, if target does not have previous options', function() { + const chart = {}; + const anims = new Chart.Animations(chart, {option: {duration: 200}}); + const target = {}; + expect(anims.update(target, {options: {option: 1}})).toBeUndefined(); + }); + + it('should clone the target options, if those are shared and new options are not', function() { + const chart = {}; + const anims = new Chart.Animations(chart, {option: {duration: 200}}); + const options = {option: 0, $shared: true}; + const target = {options}; + expect(anims.update(target, {options: {option: 1}})).toBeTrue(); + expect(target.options.$shared).not.toBeTrue(); + expect(target.options !== options).toBeTrue(); + }); + it('should assign shared options to target after animations complete', function(done) { const chart = { draw: function() {},
true
Other
chartjs
Chart.js
2efffb8ae4b86045100252186cadaf41a1b1d93e.json
Improve test coverage (#8087) * Remove usage of currentStyle (IE only) * Nothing is registered in root scope anymore * Add some more tests for animations * Add some more tests to defaults
test/specs/core.defaults.tests.js
@@ -0,0 +1,38 @@ +describe('Chart.defaults', function() { + describe('.set', function() { + it('Should set defaults directly to root when scope is not provided', function() { + expect(Chart.defaults.test).toBeUndefined(); + Chart.defaults.set({test: true}); + expect(Chart.defaults.test).toEqual(true); + delete Chart.defaults.test; + }); + + it('Should create scope when it does not exist', function() { + expect(Chart.defaults.test).toBeUndefined(); + Chart.defaults.set('test', {value: true}); + expect(Chart.defaults.test.value).toEqual(true); + delete Chart.defaults.test; + }); + }); + + describe('.route', function() { + it('Should read the source, but not change it', function() { + expect(Chart.defaults.testscope).toBeUndefined(); + + Chart.defaults.set('testscope', {test: true}); + Chart.defaults.route('testscope', 'test2', 'testscope', 'test'); + + expect(Chart.defaults.testscope.test).toEqual(true); + expect(Chart.defaults.testscope.test2).toEqual(true); + + Chart.defaults.set('testscope', {test2: false}); + expect(Chart.defaults.testscope.test).toEqual(true); + expect(Chart.defaults.testscope.test2).toEqual(false); + + Chart.defaults.set('testscope', {test2: undefined}); + expect(Chart.defaults.testscope.test2).toEqual(true); + + delete Chart.defaults.testscope; + }); + }); +});
true
Other
chartjs
Chart.js
f96fa2b96dc3e5a0b55a95351fe7bf80876873d4.json
Allow single parameter to Defaults.set (#8050) * Allow single parameter to Defaults.set * Review update * Record
src/core/core.defaults.js
@@ -59,14 +59,21 @@ export class Defaults { this.scales = {}; this.controllers = {}; } + /** - * @param {string} scope - * @param {*} values + * @param {string|object} scope + * @param {object} [values] */ set(scope, values) { - return merge(getScope(this, scope), values); + if (typeof scope === 'string') { + return merge(getScope(this, scope), values); + } + return merge(getScope(this, ''), scope); } + /** + * @param {string} scope + */ get(scope) { return getScope(this, scope); }
true
Other
chartjs
Chart.js
f96fa2b96dc3e5a0b55a95351fe7bf80876873d4.json
Allow single parameter to Defaults.set (#8050) * Allow single parameter to Defaults.set * Review update * Record
types/core/index.d.ts
@@ -333,6 +333,7 @@ export interface DatasetControllerChartComponent extends ChartComponent { }; } +export type AnyObject = Record<string, unknown>; export interface Defaults extends CoreChartOptions, ElementChartOptions { controllers: { [key in ChartType]: DeepPartial< @@ -352,8 +353,9 @@ export interface Defaults extends CoreChartOptions, ElementChartOptions { plugins: PluginOptions; - set(scope: string, values: any): any; - get(scope: string): any; + set(values: AnyObject): AnyObject; + set(scope: string, values: AnyObject): AnyObject; + get(scope: string): AnyObject; /** * Routes the named defaults to fallback to another scope/name.
true
Other
chartjs
Chart.js
065fc117afd342e1cf0f896d208c540caca76922.json
Fix url bug (#8072)
docs/docs/charts/polar.mdx
@@ -116,7 +116,7 @@ These are the customisation options specific to Polar Area charts. These options | `animation.animateRotate` | `boolean` | `true` | If true, the chart will animate in with a rotation animation. This property is in the `options.animation` object. | `animation.animateScale` | `boolean` | `true` | If true, will animate scaling the chart from the center outwards. -The polar area chart uses the [radialLinear](../axes/radial/linear.md) scale. Additional configuration is provided via the scale. +The polar area chart uses the [radialLinear](../axes/radial/linear.mdx) scale. Additional configuration is provided via the scale. ## Default Options
false
Other
chartjs
Chart.js
200c04db99ceec68272eeec57609739be47c940b.json
fix broken url in docs (#8070)
docs/docs/axes/cartesian/timeseries.md
@@ -22,4 +22,4 @@ var chart = new Chart(ctx, { ## More details -Please see [the time scale documentation](./time.md) for all other details. +Please see [the time scale documentation](./time.mdx) for all other details.
true
Other
chartjs
Chart.js
200c04db99ceec68272eeec57609739be47c940b.json
fix broken url in docs (#8070)
docs/docs/axes/radial/index.md
@@ -4,4 +4,4 @@ title: Radial Axes Radial axes are used specifically for the radar and polar area chart types. These axes overlay the chart area, rather than being positioned on one of the edges. One radial axis is included by default in Chart.js. -* [radialLinear](./linear.md#linear-radial-axis) +* [radialLinear](./linear.mdx)
true
Other
chartjs
Chart.js
7610def1c4709467b2a9136e62a8e54d1a529aef.json
Remove set-env from actions (#8063) * Remove set-env from CI * Eanble macOs * Another try on macOs, update npmpublish * No xvfb-run on macOs * Remove macos
.github/workflows/ci.yml
@@ -23,27 +23,18 @@ jobs: - uses: actions/checkout@v2 - name: Use Node.js uses: actions/setup-node@v1 - - name: Setup xvfb - run: | - Xvfb :99 -screen 0 1024x768x24 & - echo "::set-env name=DISPLAY:::99.0" - if: runner.os == 'Linux' - - name: Install chrome - run: | - brew update - brew cask install google-chrome - if: runner.os == 'macOS' - - name: Select browsers - run: | - if [ "${{ runner.os }}" == "macOS" ]; then - echo "::set-env name=BROWSERS::--browsers chrome" - fi - shell: bash - name: Build and Test run: | npm ci npm run build - npm test + if [ "${{ runner.os }}" == "Windows" ]; then + npm test + elif [ "${{ runner.os }}" == "macOS" ]; then + npm test --browsers chrome,safari + else + xvfb-run --auto-servernum npm test + fi + shell: bash - name: Package run: | npm run docs
true
Other
chartjs
Chart.js
7610def1c4709467b2a9136e62a8e54d1a529aef.json
Remove set-env from actions (#8063) * Remove set-env from CI * Eanble macOs * Another try on macOs, update npmpublish * No xvfb-run on macOs * Remove macos
.github/workflows/npmpublish.yml
@@ -12,10 +12,10 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.trim.outputs.version }} - steps: + steps: - id: trim run: echo "::set-output name=version::${TAG:1}" - env: + env: TAG: ${{ github.event.release.tag_name }} test: @@ -24,14 +24,10 @@ jobs: - uses: actions/checkout@v2 - name: Use Node.js uses: actions/setup-node@v1 - - name: Setup xvfb - run: | - Xvfb :99 -screen 0 1024x768x24 & - echo "::set-env name=DISPLAY:::99.0" - name: Test run: | npm ci - npm test + xvfb-run --auto-servernum npm test publish-npm: needs: [test, setup]
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/_common.md
@@ -0,0 +1,14 @@ +### Common to all axes + +| Name | Type | Default | Description +| ---- | ---- | ------- | ----------- +| `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. +| `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. +| `gridLines` | `object` | | Grid line configuration. [more...](./styling.mdx#grid-line-configuration) +| `min` | `number` | | User defined minimum number for the scale, overrides minimum value from data. [more...](./index.mdx#axis-range-settings) +| `max` | `number` | | User defined maximum number for the scale, overrides maximum value from data. [more...](./index.mdx#axis-range-settings) +| `reverse` | `boolean` | `false` | Reverse the scale. +| `suggestedMax` | `number` | | Adjustment used when calculating the maximum data value. [more...](./index.mdx#axis-range-settings) +| `suggestedMin` | `number` | | Adjustment used when calculating the minimum data value. [more...](./index.mdx#axis-range-settings) +| `ticks` | `object` | | Tick configuration. [more...](#tick-configuration) +| `weight` | `number` | `0` | The weight used to sort the axis. Higher weights are further away from the chart area.
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/_common_ticks.md
@@ -0,0 +1,10 @@ +### Common to all axes + +| Name | Type | Scriptable | Default | Description +| ---- | ---- | :-------------------------------: | ------- | ----------- +| `callback` | `function` | | | Returns the string representation of the tick value as it should be displayed on the chart. See [callback](../axes/labelling.md#creating-custom-tick-formats). +| `display` | `boolean` | | `true` | If true, show tick labels. +| `font` | `Font` | Yes | `defaults.font` | See [Fonts](../general/fonts.md) +| `major` | `object` | | `{}` | [Major ticks configuration](./styling.mdx#major-tick-configuration). +| `padding` | `number` | | `0` | Sets the offset of the tick labels from the axis +| `z` | `number` | | `0` | z-index of tick layer. Useful when ticks are drawn on chart area. Values &lt;= 0 are drawn under datasets, &gt; 0 on top.
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/cartesian/_common.md
@@ -0,0 +1,9 @@ +### Common options to all cartesian axes + +| Name | Type | Default | Description +| ---- | ---- | ------- | ----------- +| `bounds` | `string` | `'ticks'` | Determines the scale bounds. [more...](./index.mdx#scale-bounds) +| `position` | `string` | | Position of the axis. [more...](./index.mdx#axis-position) +| `axis` | `string` | | Which type of axis this is. Possible values are: `'x'`, `'y'`. If not set, this is inferred from the first character of the ID which should be `'x'` or `'y'`. +| `offset` | `boolean` | `false` | If true, extra space is added to the both edges and the axis is scaled to fit into the chart area. This is set to `true` for a bar chart by default. +| `scaleLabel` | `object` | | Scale title configuration. [more...](../labelling.md#scale-title-configuration)
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/cartesian/_common_ticks.md
@@ -0,0 +1,14 @@ +### Common options to all cartesian axes + +| Name | Type | Default | Description +| ---- | ---- | ------- | ----------- +| `align` | `string` | `'center'` | The tick alignment along the axis. Can be `'start'`, `'center'`, or `'end'`. +| `crossAlign` | `string` | `'near'` | The tick alignment perpendicular to the axis. Can be `'near'`, `'center'`, or `'far'`. See [Tick Alignment](./index#tick-alignment) +| `sampleSize` | `number` | `ticks.length` | The number of ticks to examine when deciding how many labels will fit. Setting a smaller value will be faster, but may be less accurate when there is large variability in label length. +| `autoSkip` | `boolean` | `true` | If true, automatically calculates how many labels can be shown and hides labels accordingly. Labels will be rotated up to `maxRotation` before skipping any. Turn `autoSkip` off to show all labels no matter what. +| `autoSkipPadding` | `number` | `0` | Padding between the ticks on the horizontal axis when `autoSkip` is enabled. +| `labelOffset` | `number` | `0` | Distance in pixels to offset the label from the centre point of the tick (in the x-direction for the x-axis, and the y-direction for the y-axis). *Note: this can cause labels at the edges to be cropped by the edge of the canvas* +| `maxRotation` | `number` | `50` | Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn't occur until necessary. *Note: Only applicable to horizontal scales.* +| `minRotation` | `number` | `0` | Minimum rotation for tick labels. *Note: Only applicable to horizontal scales.* +| `mirror` | `boolean` | `false` | Flips tick labels around axis, displaying the labels inside the chart instead of outside. *Note: Only applicable to vertical scales.* +| `padding` | `number` | `0` | Padding between the tick label and the axis. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/cartesian/category.mdx
@@ -2,6 +2,11 @@ title: Category Axis --- +import CommonAll from '../_common.md' +import CommonCartesian from './_common.md' +import CommonTicks from './_common_ticks.md' +import CommonTicksAll from '../_common_ticks.md' + If the global configuration is used, labels are drawn from one of the label arrays included in the chart data. If only `data.labels` is defined, this will be used. If `data.xLabels` is defined and the axis is horizontal, this will be used. Similarly, if `data.yLabels` is defined and the axis is vertical, this property will be used. Using both `xLabels` and `yLabels` together can create a chart that uses strings for both the X and Y axes. Specifying any of the settings above defines the x-axis as `type: 'category'` if not defined otherwise. For more fine-grained control of category labels, it is also possible to add `labels` as part of the category axis definition. Doing so does not apply the global defaults. @@ -39,13 +44,21 @@ let chart = new Chart(ctx, { ## Configuration Options -These options extend the [common configuration for all cartesian axes](index.md#configuration-options). +### Category Axis specific options | Name | Type | Description | ---- | ---- | ----------- -| `min` | `string`\|`number` | | The minimum item to display. [more...](#min-max-configuration) -| `max` | `string`\|`number` | | The maximum item to display. [more...](#min-max-configuration) -| `labels` | `string[]|string[][]` | - | An array of labels to display. When an individual label is an array of strings, each item is rendered on a new line. +| `min` | `string`\|`number` | The minimum item to display. [more...](#min-max-configuration) +| `max` | `string`\|`number` | The maximum item to display. [more...](#min-max-configuration) +| `labels` | `string[]`\|`string[][]` | An array of labels to display. When an individual label is an array of strings, each item is rendered on a new line. + +<CommonCartesian /> +<CommonAll /> + +## Tick Configuration + +<CommonTicks /> +<CommonTicksAll /> ## Min Max Configuration
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/cartesian/index.mdx
@@ -2,30 +2,26 @@ title: Cartesian Axes --- +import CommonAll from '../_common.md' +import CommonCartesian from './_common.md' +import CommonTicks from './_common_ticks.md' +import CommonTicksAll from '../_common_ticks.md' + import { useEffect } from 'react'; Axes that follow a cartesian grid are known as 'Cartesian Axes'. Cartesian axes are used for line, bar, and bubble charts. Four cartesian axes are included in Chart.js by default. -* [linear](./linear.md#linear-cartesian-axis) -* [logarithmic](./logarithmic.md#logarithmic-cartesian-axis) -* [category](./category.md#category-cartesian-axis) -* [time](./time.md#time-cartesian-axis) +* [linear](./linear) +* [logarithmic](./logarithmic) +* [category](./category) +* [time](./time) +* [timeseries](./timeseries) ## Common Configuration -All of the included cartesian axes support a number of common options. These options extend the [common configuration available to all types of axes](../index.md#common-configuration). +<CommonCartesian /> -| Name | Type | Default | Description -| ---- | ---- | ------- | ----------- -| `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. -| `position` | `string` | | Position of the axis. [more...](#axis-position) -| `axis` | `string` | | Which type of axis this is. Possible values are: `'x'`, `'y'`. If not set, this is inferred from the first character of the ID which should be `'x'` or `'y'`. -| `min` | `number` | | User-defined minimum value for the scale, overrides minimum value from data. -| `max` | `number` | | User-defined maximum value for the scale, overrides maximum value from data. -| `offset` | `boolean` | `false` | If true, extra space is added to the both edges and the axis is scaled to fit into the chart area. This is set to `true` for a bar chart by default. -| `gridLines` | `object` | | Grid line configuration. [more...](../styling.md#grid-line-configuration) -| `scaleLabel` | `object` | | Scale title configuration. [more...](../labelling.md#scale-title-configuration) -| `ticks` | `object` | | Tick configuration. [more...](#tick-configuration) +<CommonAll /> ### Axis Position @@ -43,22 +39,17 @@ To position the axis with respect to a data value, set the `position` option to This will position the axis at a value of -20 on the axis with ID "x". For cartesian axes, only 1 axis may be specified. +### Scale Bounds + +The `bounds` property controls the scale boundary strategy (bypassed by `min`/`max` options). + +* `'data'`: makes sure data are fully visible, labels outside are removed +* `'ticks'`: makes sure ticks are fully visible, data outside are truncated + ### Tick Configuration -The following options are common to all cartesian axes but do not apply to other axes. - -| Name | Type | Default | Description -| ---- | ---- | ------- | ----------- -| `align` | `string` | | `'center'` | The tick alignment along the axis. Can be `'start'`, `'center'`, or `'end'`. -| `crossAlign` | `string` | | `'near'` | The tick alignment perpendicular to the axis. Can be `'near'`, `'center'`, or `'far'`. See [Tick Alignment](#tick-alignment) -| `sampleSize` | `number` | `ticks.length` | The number of ticks to examine when deciding how many labels will fit. Setting a smaller value will be faster, but may be less accurate when there is large variability in label length. -| `autoSkip` | `boolean` | `true` | If true, automatically calculates how many labels can be shown and hides labels accordingly. Labels will be rotated up to `maxRotation` before skipping any. Turn `autoSkip` off to show all labels no matter what. -| `autoSkipPadding` | `number` | `0` | Padding between the ticks on the horizontal axis when `autoSkip` is enabled. -| `labelOffset` | `number` | `0` | Distance in pixels to offset the label from the centre point of the tick (in the x-direction for the x-axis, and the y-direction for the y-axis). *Note: this can cause labels at the edges to be cropped by the edge of the canvas* -| `maxRotation` | `number` | `50` | Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn't occur until necessary. *Note: Only applicable to horizontal scales.* -| `minRotation` | `number` | `0` | Minimum rotation for tick labels. *Note: Only applicable to horizontal scales.* -| `mirror` | `boolean` | `false` | Flips tick labels around axis, displaying the labels inside the chart instead of outside. *Note: Only applicable to vertical scales.* -| `padding` | `number` | `0` | Padding between the tick label and the axis. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction. +<CommonTicks /> +<CommonTicksAll /> ### Tick Alignment @@ -75,7 +66,6 @@ function exampleAlignment() { axis: 'y', label: 'My First Dataset', data: [65, 59, 80, 81, 56, 55, 40], - fill: false, backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(255, 159, 64, 0.2)', @@ -100,9 +90,6 @@ function exampleAlignment() { options: { indexAxis: 'y', scales: { - x: { - beginAtZero: true - }, y: { ticks: { crossAlign: 'far',
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/cartesian/linear.md
@@ -1,86 +0,0 @@ ---- -title: Linear Axis ---- - -The linear scale is used to chart numerical data. It can be placed on either the x or y-axis. The scatter chart type automatically configures a line chart to use one of these scales for the x-axis. As the name suggests, linear interpolation is used to determine where a value lies on the axis. - -## Configuration Options - -These options extend the [common configuration for all cartesian axes](index.md#configuration-options). - -| Name | Type | Description -| ---- | ---- | ----------- -| `beginAtZero` | `boolean` | if true, scale will include 0 if it is not already included. -| `suggestedMax` | `number` | Adjustment used when calculating the maximum data value. [more...](#axis-range-settings) -| `suggestedMin` | `number` | Adjustment used when calculating the minimum data value. [more...](#axis-range-settings) - -## Tick Configuration Options - -The following tick options are provided by the linear scale. They are all located in the `ticks` sub-options. These options extend the [common tick configuration](index.md#tick-configuration). - -| Name | Type | Default | Description -| ---- | ---- | ------- | ----------- -| `format` | `object` | | The [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) options used by the default label formatter -| `maxTicksLimit` | `number` | `11` | Maximum number of ticks and gridlines to show. -| `precision` | `number` | | if defined and `stepSize` is not specified, the step size will be rounded to this many decimal places. -| `stepSize` | `number` | | User-defined fixed step size for the scale. [more...](#step-size) - -## Axis Range Settings - -Given the number of axis range settings, it is important to understand how they all interact with each other. - -The `suggestedMax` and `suggestedMin` settings only change the data values that are used to scale the axis. These are useful for extending the range of the axis while maintaining the auto fit behaviour. - -```javascript -let minDataValue = Math.min(mostNegativeValue, options.suggestedMin); -let maxDataValue = Math.max(mostPositiveValue, options.suggestedMax); -``` - -In this example, the largest positive value is 50, but the data maximum is expanded out to 100. However, because the lowest data value is below the `suggestedMin` setting, it is ignored. - -```javascript -let chart = new Chart(ctx, { - type: 'line', - data: { - datasets: [{ - label: 'First dataset', - data: [0, 20, 40, 50] - }], - labels: ['January', 'February', 'March', 'April'] - }, - options: { - scales: { - y: { - suggestedMin: 50, - suggestedMax: 100 - } - } - } -}); -``` - -In contrast to the `suggested*` settings, the `min` and `max` settings set explicit ends to the axes. When these are set, some data points may not be visible. - -## Step Size - -If set, the scale ticks will be enumerated by multiple of `stepSize`, having one tick per increment. If not set, the ticks are labeled automatically using the nice numbers algorithm. - -This example sets up a chart with a y axis that creates ticks at `0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5`. - -```javascript -let options = { - scales: { - y: { - max: 5, - min: 0, - ticks: { - stepSize: 0.5 - } - } - } -}; -``` - -## Internal data format - -Internally, the linear scale uses numeric data
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/cartesian/linear.mdx
@@ -0,0 +1,59 @@ +--- +title: Linear Axis +--- + +import CommonAll from '../_common.md' +import CommonCartesian from './_common.md' +import CommonTicks from './_common_ticks.md' +import CommonTicksAll from '../_common_ticks.md' + +The linear scale is used to chart numerical data. It can be placed on either the x or y-axis. The scatter chart type automatically configures a line chart to use one of these scales for the x-axis. As the name suggests, linear interpolation is used to determine where a value lies on the axis. + +## Configuration Options + +### Linear Axis specific options + +| Name | Type | Description +| ---- | ---- | ----------- +| `beginAtZero` | `boolean` | if true, scale will include 0 if it is not already included. + +<CommonCartesian /> +<CommonAll /> + +## Tick Configuration + +### Linear Axis specific options + +| Name | Type | Default | Description +| ---- | ---- | ------- | ----------- +| `format` | `object` | | The [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) options used by the default label formatter +| `maxTicksLimit` | `number` | `11` | Maximum number of ticks and gridlines to show. +| `precision` | `number` | | if defined and `stepSize` is not specified, the step size will be rounded to this many decimal places. +| `stepSize` | `number` | | User-defined fixed step size for the scale. [more...](#step-size) + +<CommonTicks /> +<CommonTicksAll /> + +## Step Size + +If set, the scale ticks will be enumerated by multiple of `stepSize`, having one tick per increment. If not set, the ticks are labeled automatically using the nice numbers algorithm. + +This example sets up a chart with a y axis that creates ticks at `0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5`. + +```javascript +let options = { + scales: { + y: { + max: 5, + min: 0, + ticks: { + stepSize: 0.5 + } + } + } +}; +``` + +## Internal data format + +Internally, the linear scale uses numeric data
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/cartesian/logarithmic.md
@@ -1,26 +0,0 @@ ---- -title: Logarithmic Axis ---- - -The logarithmic scale is used to chart numerical data. It can be placed on either the x or y-axis. As the name suggests, logarithmic interpolation is used to determine where a value lies on the axis. - -## Configuration Options - -These options extend the [common configuration for all cartesian axes](index.md#configuration-options). - -| Name | Type | Description -| ---- | ---- | ----------- -| `suggestedMax` | `number` | Adjustment used when calculating the maximum data value. [more...](#axis-range-settings) -| `suggestedMin` | `number` | Adjustment used when calculating the minimum data value. [more...](#axis-range-settings) - -## Tick Configuration Options - -The following options are provided by the logarithmic scale. They are all located in the `ticks` sub-options. These options extend the [common tick configuration](index.md#tick-configuration). - -| Name | Type | Default | Description -| ---- | ---- | ------- | ----------- -| `format` | `object` | | The [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) options used by the default label formatter - -## Internal data format - -Internally, the logarithmic scale uses numeric data.
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/cartesian/logarithmic.mdx
@@ -0,0 +1,30 @@ +--- +title: Logarithmic Axis +--- + +import CommonAll from '../_common.md' +import CommonCartesian from './_common.md' +import CommonTicks from './_common_ticks.md' +import CommonTicksAll from '../_common_ticks.md' + +The logarithmic scale is used to chart numerical data. It can be placed on either the x or y-axis. As the name suggests, logarithmic interpolation is used to determine where a value lies on the axis. + +## Configuration Options + +<CommonCartesian /> +<CommonAll /> + +## Tick Configuration + +### Logarithmic Axis specific options + +| Name | Type | Default | Description +| ---- | ---- | ------- | ----------- +| `format` | `object` | | The [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) options used by the default label formatter + +<CommonTicks /> +<CommonTicksAll /> + +## Internal data format + +Internally, the logarithmic scale uses numeric data.
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/cartesian/time.mdx
@@ -2,6 +2,10 @@ title: Time Cartesian Axis --- +import CommonAll from '../_common.md' +import CommonCartesian from './_common.md' +import CommonTicks from './_common_ticks.md' + The time scale is used to display times and dates. Data are spread according to the amount of time between data points. When building its ticks, it will automatically calculate the most comfortable unit base on the size of the scale. ## Date Adapters @@ -20,12 +24,12 @@ When providing data for the time scale, Chart.js uses timestamps defined as mill ## Configuration Options -The following options are provided by the time scale. You may also set options provided by the [common tick configuration](index.md#tick-configuration). +### Time Axis specific options | Name | Type | Default | Description | ---- | ---- | ------- | ----------- | `adapters.date` | `object` | `{}` | Options for adapter for external date library if that adapter needs or supports options -| `bounds` | `string` | `'data'` | Determines the scale bounds. [more...](#scale-bounds) +| `bounds` | `string` | `'data'` | Determines the scale bounds. [more...](./index.mdx#scale-bounds) | `ticks.source` | `string` | `'auto'` | How ticks are generated. [more...](#ticks-source) | `time.displayFormats` | `object` | | Sets how different time units are displayed. [more...](#display-formats) | `time.isoWeekday` | `boolean`\|`number` | `false` | If `boolean` and true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday. If `number`, the index of the first day of the week (0 - Sunday, 6 - Saturday) @@ -36,7 +40,10 @@ The following options are provided by the time scale. You may also set options p | `time.stepSize` | `number` | `1` | The number of units between grid lines. | `time.minUnit` | `string` | `'millisecond'` | The minimum display format to be used for a time unit. -### Time Units +<CommonCartesian /> +<CommonAll /> + +#### Time Units The following time measurements are supported. The names can be passed as strings to the `time.unit` config option to force a certain unit. @@ -69,7 +76,7 @@ var chart = new Chart(ctx, { }); ``` -### Display Formats +#### Display Formats You may specify a map of display formats with a key for each unit: @@ -106,27 +113,20 @@ var chart = new Chart(ctx, { }); ``` -### Scale Bounds - -The `bounds` property controls the scale boundary strategy (bypassed by `min`/`max` time options). - -* `'data'`: makes sure data are fully visible, labels outside are removed -* `'ticks'`: makes sure ticks are fully visible, data outside are truncated - -### Ticks Source +#### Ticks Source The `ticks.source` property controls the ticks generation. * `'auto'`: generates "optimal" ticks based on scale size and time options * `'data'`: generates ticks from data (including labels from data `{x|y}` objects) * `'labels'`: generates ticks from user given `labels` ONLY -### Parser +#### Parser If this property is defined as a string, it is interpreted as a custom format to be used by the date adapter to parse the date. If this is a function, it must return a type that can be handled by your date adapter's `parse` method. -### Internal data format +## Internal data format Internally time scale uses milliseconds since epoch
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/index.mdx
@@ -2,9 +2,12 @@ title: Axes --- -Axes are an integral part of a chart. They are used to determine how data maps to a pixel value on the chart. In a cartesian chart, there is 1 or more X-axis and 1 or more Y-axis to map points onto the 2-dimensional canvas. These axes are known as ['cartesian axes'](./cartesian/index.md#cartesian-axes). +import Common from './_common.md' +import CommonTicks from './_common_ticks.md' -In a radial chart, such as a radar chart or a polar area chart, there is a single axis that maps points in the angular and radial directions. These are known as ['radial axes'](./radial/index.md#radial-axes). +Axes are an integral part of a chart. They are used to determine how data maps to a pixel value on the chart. In a cartesian chart, there is 1 or more X-axis and 1 or more Y-axis to map points onto the 2-dimensional canvas. These axes are known as ['cartesian axes'](./cartesian/index#cartesian-axes). + +In a radial chart, such as a radar chart or a polar area chart, there is a single axis that maps points in the angular and radial directions. These are known as ['radial axes'](./radial/index#radial-axes). Scales in Chart.js >v2.0 are significantly more powerful, but also different than those of v1.0. @@ -15,13 +18,47 @@ Scales in Chart.js >v2.0 are significantly more powerful, but also different tha ## Common Configuration -The following options are common to all axes provided by Chart.js. +<Common /> + +## Tick Configuration + +<CommonTicks /> + +## Axis Range Settings + +Given the number of axis range settings, it is important to understand how they all interact with each other. + +The `suggestedMax` and `suggestedMin` settings only change the data values that are used to scale the axis. These are useful for extending the range of the axis while maintaining the auto fit behaviour. + +```javascript +let minDataValue = Math.min(mostNegativeValue, options.suggestedMin); +let maxDataValue = Math.max(mostPositiveValue, options.suggestedMax); +``` + +In this example, the largest positive value is 50, but the data maximum is expanded out to 100. However, because the lowest data value is below the `suggestedMin` setting, it is ignored. + +```javascript +let chart = new Chart(ctx, { + type: 'line', + data: { + datasets: [{ + label: 'First dataset', + data: [0, 20, 40, 50] + }], + labels: ['January', 'February', 'March', 'April'] + }, + options: { + scales: { + y: { + suggestedMin: 50, + suggestedMax: 100 + } + } + } +}); +``` -| Name | Type | Default | Description -| ---- | ---- | ------- | ----------- -| `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. -| `reverse` | `boolean` | `false` | Reverse the scale. -| `weight` | `number` | `0` | The weight used to sort the axis. Higher weights are further away from the chart area. +In contrast to the `suggested*` settings, the `min` and `max` settings set explicit ends to the axes. When these are set, some data points may not be visible. ### Callbacks
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/radial/linear.mdx
@@ -2,29 +2,28 @@ title: Linear Radial Axis --- +import CommonAll from '../_common.md' +import CommonTicksAll from '../_common_ticks.md' + The linear radial scale is used to chart numerical data. As the name suggests, linear interpolation is used to determine where a value lies in relation to the center of the axis. The following additional configuration options are provided by the radial linear scale. ## Configuration Options -The axis has configuration properties for ticks, angle lines (lines that appear in a radar chart outward from the center), pointLabels (labels around the edge in a radar chart). The following sections define each of the properties in those sections. +### Linear Radial Axis specific options | Name | Type | Default | Description | ---- | ---- | ------- | ----------- | `angleLines` | `object` | | Angle line configuration. [more...](#angle-line-options) | `beginAtZero` | `boolean` | `false` | if true, scale will include 0 if it is not already included. -| `gridLines` | `object` | | Grid line configuration. [more...](../styling.md#grid-line-configuration) -| `min` | `number` | | User defined minimum number for the scale, overrides minimum value from data. [more...](#axis-range-settings) -| `max` | `number` | | User defined maximum number for the scale, overrides maximum value from data. [more...](#axis-range-settings) | `pointLabels` | `object` | | Point label configuration. [more...](#point-label-options) -| `suggestedMax` | `number` | | Adjustment used when calculating the maximum data value. [more...](#axis-range-settings) -| `suggestedMin` | `number` | | Adjustment used when calculating the minimum data value. [more...](#axis-range-settings) -| `ticks` | `object` | | Tick configuration. [more...](#tick-options) -## Tick Options +<CommonAll /> + +## Tick Configuration -The following options are provided by the linear radial scale. They are all located in the `ticks` sub-options. The [common tick configuration](../styling.md#tick-configuration) options are supported by this axis. +### Linear Radial Axis specific options | Name | Type | Scriptable | Default | Description | ---- | ---- | ------- | ------- | ----------- @@ -37,6 +36,8 @@ The following options are provided by the linear radial scale. They are all loca | `stepSize` | `number` | | | User defined fixed step size for the scale. [more...](#step-size) | `showLabelBackdrop` | `boolean` | Yes | `true` | If true, draw a background behind the tick labels. +<CommonTicksAll /> + The scriptable context has the following form: ```javascript
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/axes/styling.mdx
@@ -38,16 +38,7 @@ The scriptable context has the following form: ## Tick Configuration -The tick configuration is nested under the scale configuration in the `ticks` key. It defines options for the tick marks that are generated by the axis. - -| Name | Type | Scriptable | Default | Description -| ---- | ---- | :-------------------------------: | ------- | ----------- -| `callback` | `function` | | | Returns the string representation of the tick value as it should be displayed on the chart. See [callback](../axes/labelling.md#creating-custom-tick-formats). -| `display` | `boolean` | | `true` | If true, show tick labels. -| `font` | `Font` | Yes | `defaults.font` | See [Fonts](../general/fonts.md) -| `major` | `object` | | `{}` | [Major ticks configuration](#major-tick-configuration). -| `padding` | `number` | | `0` | Sets the offset of the tick labels from the axis -| `z` | `number` | | `0` | z-index of tick layer. Useful when ticks are drawn on chart area. Values &lt;= 0 are drawn under datasets, &gt; 0 on top. +<CommonTicks /> The scriptable context is the same as for the [Grid Line Configuration](#grid-line-configuration).
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/docs/general/fonts.md
@@ -32,8 +32,8 @@ let chart = new Chart(ctx, { | `style` | `string` | `'normal'` | Default font style. Does not apply to tooltip title or footer. Does not apply to chart title. Follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit). | `weight` | `string` | `undefined` | Default font weight (boldness). (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)). | `lineHeight` | <code>number&#124;string</code> | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)). -| `lineWidth` | `number` | `0` | Stroke width around the text. Currently only supported by [ticks](../axes/styling.md#tick-configuration). -| `strokeStyle` | `string` | `` | The color of the stroke around the text. Currently only supported by [ticks](../axes/styling.md#tick-configuration). +| `lineWidth` | `number` | `0` | Stroke width around the text. Currently only supported by [ticks](../axes/styling#tick-configuration). +| `strokeStyle` | `string` | `` | The color of the stroke around the text. Currently only supported by [ticks](../axes/styling#tick-configuration). ## Missing Fonts
true
Other
chartjs
Chart.js
ed846f62f7ef61cdc9bf3855506b2bcaeb5fc91b.json
Update axis documentation (#8061)
docs/sidebars.js
@@ -49,7 +49,8 @@ module.exports = { 'axes/cartesian/category', 'axes/cartesian/linear', 'axes/cartesian/logarithmic', - 'axes/cartesian/time' + 'axes/cartesian/time', + 'axes/cartesian/timeseries' ]}, {Radial: [ 'axes/radial/index',
true
Other
chartjs
Chart.js
988c86559924d412139aab71a60a616c6f718955.json
Add plugins to CoreChartOptions (#8048)
types/core/interfaces.d.ts
@@ -1,6 +1,7 @@ import { Chart, Element, InteractionMode } from '.'; import { ChartDataset } from '../interfaces'; import { ParsingOptions } from '../controllers'; +import { PluginOptions } from '../plugins'; export type Color = string | CanvasGradient | CanvasPattern; @@ -155,6 +156,8 @@ export interface CoreChartOptions extends ParsingOptions { layout: { padding: Scriptable<number | ChartArea>; }; + + plugins: PluginOptions; } export type EasingFunction =
false
Other
chartjs
Chart.js
fde84f272acf441fbfb8d51931c2484e1d34c805.json
Chart.register: preserve existing defaults (#8052)
src/core/core.typedRegistry.js
@@ -42,10 +42,6 @@ export default class TypedRegistry { return scope; } - if (Object.keys(defaults.get(scope)).length) { - throw new Error('Can not register "' + id + '", because "defaults.' + scope + '" would collide with existing defaults'); - } - items[id] = item; registerDefaults(item, scope, parentScope); @@ -81,10 +77,13 @@ export default class TypedRegistry { } function registerDefaults(item, scope, parentScope) { - // Inherit the parent's defaults - const itemDefaults = parentScope - ? Object.assign({}, defaults.get(parentScope), item.defaults) - : item.defaults; + // Inherit the parent's defaults and keep existing defaults + const itemDefaults = Object.assign( + Object.create(null), + parentScope && defaults.get(parentScope), + item.defaults, + defaults.get(scope) + ); defaults.set(scope, itemDefaults);
true
Other
chartjs
Chart.js
fde84f272acf441fbfb8d51931c2484e1d34c805.json
Chart.register: preserve existing defaults (#8052)
test/specs/core.registry.tests.js
@@ -284,14 +284,18 @@ describe('Chart.registry', function() { expect(afterUnregisterCount).withContext('afterUnregister').toBe(4); }); - it('should not register anything that would collide with existing defaults', function() { - Chart.defaults.controllers.test = {test: true}; + it('should preserve existing defaults', function() { + Chart.defaults.controllers.test = {test1: true}; + class testController extends Chart.DatasetController {} testController.id = 'test'; - expect(function() { - Chart.register(testController); - }).toThrow(new Error('Can not register "test", because "defaults.controllers.test" would collide with existing defaults')); - delete Chart.defaults.controllers.test; + testController.defaults = {test1: false, test2: true}; + + Chart.register(testController); + expect(Chart.defaults.controllers.test).toEqual({test1: true, test2: true}); + + Chart.unregister(testController); + expect(Chart.defaults.controllers.test).not.toBeDefined(); }); describe('should handle multiple items', function() {
true
Other
chartjs
Chart.js
7718d5fd56e14ac26af14f8c74aaeb5cbfcd32ee.json
Fix broken link (#8041)
samples/samples.js
@@ -195,7 +195,7 @@ path: 'tooltips/positioning.html' }, { title: 'Custom Positioning', - path: 'tooltips/position-custom.html' + path: 'tooltips/positioning-custom.html' }, { title: 'Interactions', path: 'tooltips/interactions.html'
false
Other
chartjs
Chart.js
d063f654cfd1b2f4e17f9bcd810680fcb5efbded.json
Fix import names in integration example (#8039)
docs/docs/getting-started/integration.md
@@ -25,9 +25,9 @@ var myChart = new Chart(ctx, {...}); Chart.js 3 is tree-shakeable, so it is necessary to import and register the controllers, elements, scales and plugins you are going to use. ```javascript -import { Chart, LineController, Line, Point, LinearScale, CategoryScale, Title, Tooltip, Filler, Legend } from 'chart.js'; +import { Chart, LineController, LineElement, PointElement, LinearScale, CategoryScale, Title, Tooltip, Filler, Legend } from 'chart.js'; -Chart.register(LineController, Line, Point, LinearScale, CategoryScale, Title, Tooltip, Filler, Legend); +Chart.register(LineController, LineElement, PointElement, LinearScale, CategoryScale, Title, Tooltip, Filler, Legend); var myChart = new Chart(ctx, {...}); ```
false
Other
chartjs
Chart.js
e00dc1e9147057db0e1b034f060440fa983b478e.json
Improve helpers.color test coverage (#8034)
test/specs/helpers.color.tests.js
@@ -11,6 +11,14 @@ describe('Color helper', function() { }); describe('Background hover color helper', function() { + it('should return a modified version of color when called with a color', function() { + var originalColorRGB = 'rgb(70, 191, 189)'; + + expect(getHoverColor('#46BFBD')).not.toEqual(originalColorRGB); + }); +}); + +describe('color and getHoverColor helpers', function() { it('should return a CanvasPattern when called with a CanvasPattern', function(done) { var dots = new Image(); dots.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAAD1BMVEUAAAD///////////////+PQt5oAAAABXRSTlMAHlFhZsfk/BEAAAAqSURBVHgBY2BgZGJmYmSAAUYWEIDzmcBcJhiXGcxlRpPFrhdmMiqgvX0AcGIBEUAo6UAAAAAASUVORK5CYII='; @@ -20,10 +28,10 @@ describe('Background hover color helper', function() { var patternContext = patternCanvas.getContext('2d'); var pattern = patternContext.createPattern(dots, 'repeat'); patternContext.fillStyle = pattern; + var chartPattern = chartContext.createPattern(patternCanvas, 'repeat'); - var backgroundColor = getHoverColor(chartContext.createPattern(patternCanvas, 'repeat')); - - expect(backgroundColor instanceof CanvasPattern).toBe(true); + expect(color(chartPattern) instanceof CanvasPattern).toBe(true); + expect(getHoverColor(chartPattern) instanceof CanvasPattern).toBe(true); done(); }; @@ -33,12 +41,7 @@ describe('Background hover color helper', function() { var context = document.createElement('canvas').getContext('2d'); var gradient = context.createLinearGradient(0, 1, 2, 3); + expect(color(gradient) instanceof CanvasGradient).toBe(true); expect(getHoverColor(gradient) instanceof CanvasGradient).toBe(true); }); - - it('should return a modified version of color when called with a color', function() { - var originalColorRGB = 'rgb(70, 191, 189)'; - - expect(getHoverColor('#46BFBD')).not.toEqual(originalColorRGB); - }); });
false
Other
chartjs
Chart.js
183637b87f928c3d62991de764d15228f1a19338.json
Add tests and clean up resolveObjectKey helper (#8028) * Add tests and clean up resolveObjectKey helper * Change the optimized path to comply with thests
src/helpers/helpers.core.js
@@ -274,17 +274,21 @@ export function _deprecated(scope, value, previous, current) { } export function resolveObjectKey(obj, key) { - if (key.length < 3) { - return obj[key]; + // Special cases for `x` and `y` keys. It's quite a lot faster to aceess this way. + // Those are the default keys Chart.js is resolving, so it makes sense to be fast. + if (key === 'x') { + return obj.x; + } + if (key === 'y') { + return obj.y; } const keys = key.split('.'); - for (let i = 0, n = keys.length; i < n; ++i) { + for (let i = 0, n = keys.length; i < n && obj; ++i) { const k = keys[i]; - if (k in obj) { - obj = obj[k]; - } else { - return; + if (!k) { + break; } + obj = obj[k]; } return obj; }
true
Other
chartjs
Chart.js
183637b87f928c3d62991de764d15228f1a19338.json
Add tests and clean up resolveObjectKey helper (#8028) * Add tests and clean up resolveObjectKey helper * Change the optimized path to comply with thests
test/specs/helpers.core.tests.js
@@ -374,4 +374,87 @@ describe('Chart.helpers.core', function() { expect(output.o.a).not.toBe(a1); }); }); + + describe('resolveObjectKey', function() { + it('should resolve empty key to root object', function() { + const obj = {test: true}; + expect(helpers.resolveObjectKey(obj, '')).toEqual(obj); + }); + it('should resolve one level', function() { + const obj = { + bool: true, + str: 'test', + int: 42, + obj: {name: 'object'} + }; + expect(helpers.resolveObjectKey(obj, 'bool')).toEqual(true); + expect(helpers.resolveObjectKey(obj, 'str')).toEqual('test'); + expect(helpers.resolveObjectKey(obj, 'int')).toEqual(42); + expect(helpers.resolveObjectKey(obj, 'obj')).toEqual(obj.obj); + }); + it('should resolve multiple levels', function() { + const obj = { + child: { + level: 1, + child: { + level: 2, + child: { + level: 3 + } + } + } + }; + expect(helpers.resolveObjectKey(obj, 'child.level')).toEqual(1); + expect(helpers.resolveObjectKey(obj, 'child.child.level')).toEqual(2); + expect(helpers.resolveObjectKey(obj, 'child.child.child.level')).toEqual(3); + }); + it('should resolve circular reference', function() { + const root = {}; + const child = {root}; + child.child = child; + root.child = child; + expect(helpers.resolveObjectKey(root, 'child')).toEqual(child); + expect(helpers.resolveObjectKey(root, 'child.child.child.child.child.child')).toEqual(child); + expect(helpers.resolveObjectKey(root, 'child.child.root')).toEqual(root); + }); + it('should break at empty key', function() { + const obj = { + child: { + level: 1, + child: { + level: 2, + child: { + level: 3 + } + } + } + }; + expect(helpers.resolveObjectKey(obj, 'child..level')).toEqual(obj.child); + expect(helpers.resolveObjectKey(obj, 'child.child.level...')).toEqual(2); + expect(helpers.resolveObjectKey(obj, '.')).toEqual(obj); + expect(helpers.resolveObjectKey(obj, '..')).toEqual(obj); + }); + it('should resolve undefined', function() { + const obj = { + child: { + level: 1, + child: { + level: 2, + child: { + level: 3 + } + } + } + }; + expect(helpers.resolveObjectKey(obj, 'level')).toEqual(undefined); + expect(helpers.resolveObjectKey(obj, 'child.level.a')).toEqual(undefined); + }); + it('should throw on invalid input', function() { + expect(() => helpers.resolveObjectKey(undefined, undefined)).toThrow(); + expect(() => helpers.resolveObjectKey({}, null)).toThrow(); + expect(() => helpers.resolveObjectKey({}, false)).toThrow(); + expect(() => helpers.resolveObjectKey({}, true)).toThrow(); + expect(() => helpers.resolveObjectKey({}, 1)).toThrow(); + }); + }); });
true
Other
chartjs
Chart.js
3f413c7bcf40e1dcda2982105917fd5fd271f711.json
Fix inconsistency in types for LABEL (#8027) Co-authored-by: Sergey Khomushin <sergey@placer.io>
types/core/index.d.ts
@@ -172,7 +172,7 @@ export interface ActiveElement extends ActiveDataPoint { export declare class Chart< TYPE extends ChartType = ChartType, DATA extends unknown[] = DefaultDataPoint<TYPE>, - LABEL = string + LABEL = unknown > { readonly platform: BasePlatform; readonly id: string;
true
Other
chartjs
Chart.js
3f413c7bcf40e1dcda2982105917fd5fd271f711.json
Fix inconsistency in types for LABEL (#8027) Co-authored-by: Sergey Khomushin <sergey@placer.io>
types/interfaces.d.ts
@@ -175,7 +175,7 @@ export interface ChartData< export interface ChartConfiguration< TYPE extends ChartType = ChartType, DATA extends unknown[] = DefaultDataPoint<TYPE>, - LABEL = string + LABEL = unknown > { type: TYPE; data: ChartData<TYPE, DATA, LABEL>;
true
Other
chartjs
Chart.js
91fec4a3970a91baa534c585f4301aebfb18ee37.json
Bubble: Use point.size() in getMaxOverflow (#8018)
src/controllers/controller.bubble.js
@@ -34,10 +34,10 @@ export default class BubbleController extends DatasetController { getMaxOverflow() { const me = this; const meta = me._cachedMeta; - let i = (meta.data || []).length - 1; + const data = meta.data; let max = 0; - for (; i >= 0; --i) { - max = Math.max(max, me.getStyle(i, true).radius); + for (let i = data.length - 1; i >= 0; --i) { + max = Math.max(max, data[i].size()); } return max > 0 && max; }
false
Other
chartjs
Chart.js
d74a5d7552c8cecd895de1edb92ed7e54a8250a0.json
Add type to context objects (#8007)
docs/docs/general/options.md
@@ -54,6 +54,7 @@ The context object contains the following properties: ### chart - `chart`: the associated chart +- `type`: `'chart'` ### dataset @@ -63,6 +64,7 @@ In addition to [chart](#chart) - `dataset`: dataset at index `datasetIndex` - `datasetIndex`: index of the current dataset - `index`: getter for `datasetIndex` +- `type`: `'dataset'` ### data @@ -73,16 +75,19 @@ In addition to [dataset](#dataset) - `dataPoint`: the parsed data values for the given `dataIndex` and `datasetIndex` - `element`: the element (point, arc, bar, etc.) for this data - `index`: getter for `dataIndex` +- `type`: `'data'` ### scale In addition to [chart](#chart) - `scale`: the associated scale +- `type`: `'scale'` ### tick In addition to [scale](#scale) - `tick`: the associated tick object - `index`: tick index +- `type`: `'tick'`
true
Other
chartjs
Chart.js
d74a5d7552c8cecd895de1edb92ed7e54a8250a0.json
Add type to context objects (#8007)
src/core/core.controller.js
@@ -735,6 +735,9 @@ class Chart { return this.$context || (this.$context = Object.create(null, { chart: { value: this + }, + type: { + value: 'chart' } })); }
true
Other
chartjs
Chart.js
d74a5d7552c8cecd895de1edb92ed7e54a8250a0.json
Add type to context objects (#8007)
src/core/core.datasetController.js
@@ -164,6 +164,9 @@ function createDatasetContext(parent, index, dataset) { get() { return this.datasetIndex; } + }, + type: { + value: 'dataset' } }); } @@ -187,6 +190,9 @@ function createDataContext(parent, index, point, element) { get() { return this.dataIndex; } + }, + type: { + value: 'data', } }); }
true
Other
chartjs
Chart.js
d74a5d7552c8cecd895de1edb92ed7e54a8250a0.json
Add type to context objects (#8007)
src/core/core.scale.js
@@ -274,6 +274,9 @@ function createScaleContext(parent, scale) { scale: { value: scale }, + type: { + value: 'scale' + } }); } @@ -284,6 +287,9 @@ function createTickContext(parent, index, tick) { }, index: { value: index + }, + type: { + value: 'tick' } }); }
true
Other
chartjs
Chart.js
aae53c835e51be732b6600d7cd982de5a5f28312.json
Use same merging logic for init and update (#8006) * Use same merging logic for init and update * Add test
src/core/core.config.js
@@ -101,25 +101,12 @@ function mergeConfig(...args/* config objects ... */) { }); } -function includeDefaults(options, type) { - return mergeConfig( +function includeDefaults(config, options) { + const scaleConfig = mergeScaleConfig(config, options); + options = mergeConfig( defaults, - defaults.controllers[type], + defaults.controllers[config.type], options || {}); -} - -function initConfig(config) { - config = config || {}; - - // Do NOT use mergeConfig for the data object because this method merges arrays - // and so would change references to labels and datasets, preventing data updates. - const data = config.data = config.data || {datasets: [], labels: []}; - data.datasets = data.datasets || []; - data.labels = data.labels || []; - - const scaleConfig = mergeScaleConfig(config, config.options); - - const options = config.options = includeDefaults(config.options, config.type); options.hover = merge(Object.create(null), [ defaults.interaction, @@ -140,6 +127,19 @@ function initConfig(config) { options.interaction, options.tooltips ]); + return options; +} + +function initConfig(config) { + config = config || {}; + + // Do NOT use mergeConfig for the data object because this method merges arrays + // and so would change references to labels and datasets, preventing data updates. + const data = config.data = config.data || {datasets: [], labels: []}; + data.datasets = data.datasets || []; + data.labels = data.labels || []; + + config.options = includeDefaults(config, config.options); return config; } @@ -171,11 +171,6 @@ export default class Config { update(options) { const config = this._config; - const scaleConfig = mergeScaleConfig(config, options); - - options = includeDefaults(options, config.type); - - options.scales = scaleConfig; - config.options = options; + config.options = includeDefaults(config, options); } }
true
Other
chartjs
Chart.js
aae53c835e51be732b6600d7cd982de5a5f28312.json
Use same merging logic for init and update (#8006) * Use same merging logic for init and update * Add test
test/specs/core.controller.tests.js
@@ -355,6 +355,28 @@ describe('Chart', function() { }); }); + describe('Updating options', function() { + it('update should result to same set of options as construct', function() { + var chart = acquireChart({ + type: 'line', + data: [], + options: { + animation: false, + locale: 'en-US', + responsive: false + } + }); + const options = chart.options; + chart.options = { + animation: false, + locale: 'en-US', + responsive: false + }; + chart.update(); + expect(chart.options).toEqual(jasmine.objectContaining(options)); + }); + }); + describe('config.options.responsive: true (maintainAspectRatio: false)', function() { it('should fill parent width and height', function() { var chart = acquireChart({
true
Other
chartjs
Chart.js
aae53c835e51be732b6600d7cd982de5a5f28312.json
Use same merging logic for init and update (#8006) * Use same merging logic for init and update * Add test
test/utils.js
@@ -58,7 +58,6 @@ function acquireChart(config, options) { config.options = config.options || {}; config.options.animation = config.options.animation === undefined ? false : config.options.animation; config.options.responsive = config.options.responsive === undefined ? false : config.options.responsive; - config.options.fontFamily = config.options.fontFamily || 'Arial'; config.options.locale = config.options.locale || 'en-US'; wrapper.appendChild(canvas);
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
.editorconfig
@@ -16,3 +16,7 @@ indent_size = 2 [*.json] indent_style = space indent_size = 2 + +[*.mdx] +indent_style = space +indent_size = 2
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/axes/cartesian/index.mdx
@@ -111,7 +111,8 @@ function exampleAlignment() { } } }; - new Chart(document.getElementById('chartjs-1').getContext('2d'), cfg); + const chart = new Chart(document.getElementById('chartjs-1').getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-1" className="chartjs"></canvas></div>; }
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/charts/bar.mdx
@@ -53,7 +53,8 @@ export const ExampleChart0 = () => { } } }; - new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + const chart = new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-0" className="chartjs"></canvas></div>; } @@ -335,7 +336,8 @@ export const ExampleChart1 = () => { } } }; - new Chart(document.getElementById('chartjs-1').getContext('2d'), cfg); + const chart = new Chart(document.getElementById('chartjs-1').getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-1" className="chartjs"></canvas></div>; }
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/charts/bubble.mdx
@@ -26,7 +26,8 @@ export const ExampleChart = () => { }] } }; - new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + const chart = new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-0" className="chartjs"></canvas></div>; }
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/charts/doughnut.mdx
@@ -47,7 +47,8 @@ function example() { }] } }; - new Chart(canvas.current.getContext('2d'), cfg); + const chart = new Chart(canvas.current.getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas ref={canvas} className="chartjs"></canvas></div>; } @@ -81,7 +82,8 @@ function example() { }] } }; - new Chart(canvas.current.getContext('2d'), cfg); + const chart = new Chart(canvas.current.getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas ref={canvas} className="chartjs"></canvas></div>; }
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/charts/line.mdx
@@ -31,7 +31,8 @@ export const ExampleChart = () => { options: { } }; - new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + const chart = new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-0" className="chartjs"></canvas></div>; }
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/charts/mixed.mdx
@@ -60,7 +60,8 @@ export const ExampleChart = () => { } } }; - new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + const chart = new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-0" className="chartjs"></canvas></div>; }
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/charts/polar.mdx
@@ -33,7 +33,8 @@ export const ExampleChart = () => { }] } }; - new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + const chart = new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-0" className="chartjs"></canvas></div>; }
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/charts/radar.mdx
@@ -55,7 +55,8 @@ export const ExampleChart = () => { } } }; - new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + const chart = new Chart(document.getElementById('chartjs-0').getContext('2d'), cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-0" className="chartjs"></canvas></div>; }
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/charts/scatter.md
@@ -1,56 +0,0 @@ ---- -title: Scatter Chart ---- - -Scatter charts are based on basic line charts with the x axis changed to a linear axis. To use a scatter chart, data must be passed as objects containing X and Y properties. The example below creates a scatter chart with 3 points. - -```javascript -var scatterChart = new Chart(ctx, { - type: 'scatter', - data: { - datasets: [{ - label: 'Scatter Dataset', - data: [{ - x: -10, - y: 0 - }, { - x: 0, - y: 10 - }, { - x: 10, - y: 5 - }] - }] - }, - options: { - scales: { - x: { - type: 'linear', - position: 'bottom' - } - } - } -}); -``` - -## Dataset Properties - -The scatter chart supports all of the same properties as the [line chart](./charts/line.mdx#dataset-properties). - -## Data Structure - -Unlike the line chart where data can be supplied in two different formats, the scatter chart only accepts data in a point format. - -```javascript -data: [{ - x: 10, - y: 20 - }, { - x: 15, - y: 10 - }] -``` - -## Internal data format - -`{x, y}`
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/charts/scatter.mdx
@@ -0,0 +1,66 @@ +--- +title: Scatter Chart +--- + +Scatter charts are based on basic line charts with the x axis changed to a linear axis. To use a scatter chart, data must be passed as objects containing X and Y properties. The example below creates a scatter chart with 3 points. + +import { useEffect, useRef } from 'react'; + +```jsx live +function example() { + const canvas = useRef(null); + useEffect(() => { + const cfg = { + type: 'scatter', + data: { + datasets: [{ + label: 'Scatter Dataset', + data: [{ + x: -10, + y: 0 + }, { + x: 0, + y: 10 + }, { + x: 10, + y: 5 + }] + }] + }, + options: { + scales: { + x: { + type: 'linear', + position: 'bottom' + } + } + } + }; + const chart = new Chart(canvas.current.getContext('2d'), cfg); + return () => chart.destroy(); + }); + return <div className="chartjs-wrapper"><canvas ref={canvas} className="chartjs"></canvas></div>; +} +``` + +## Dataset Properties + +The scatter chart supports all of the same properties as the [line chart](./charts/line.mdx#dataset-properties). + +## Data Structure + +Unlike the line chart where data can be supplied in two different formats, the scatter chart only accepts data in a point format. + +```javascript +data: [{ + x: 10, + y: 20 + }, { + x: 15, + y: 10 + }] +``` + +## Internal data format + +`{x, y}`
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/configuration/animations.mdx
@@ -50,7 +50,8 @@ function example() { } } }; - new Chart(ctx, cfg); + const chart = new Chart(ctx, cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-a0" className="chartjs"></canvas></div>; } @@ -96,7 +97,8 @@ function example() { } } }; - new Chart(ctx, cfg); + const chart = new Chart(ctx, cfg); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="chartjs-a1" className="chartjs"></canvas></div>; } @@ -117,16 +119,16 @@ The default configuration is defined here: <a href="https://github.com/chartjs/C | `debug` | `boolean` | `undefined` | Running animation count + FPS display in upper left corner of the chart. | `delay` | `number` | `undefined` | Delay before starting the animations. | `loop` | `boolean` | `undefined` | If set to `true`, the animations loop endlessly. -| [[mode]](#animation-mode-configuration) | `object` | [defaults...](#default-modes) | Option overrides for update mode. Core modes: `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`. See **Hide and show [mode]** example above. +| [[mode]](#animation-mode-configuration) | `object` | [defaults...](#default-modes) | Option overrides for update mode. Core modes: `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`. See **Hide and show [mode]** example above. | [[property]](#animation-property-configuration) | `object` | `undefined` | Option overrides for a single element `[property]`. These have precedence over `[collection]`. See **Looping tension [property]** example above. | [[collection]](#animation-properties-collection-configuration) | `object` | [defaults...](#default-collections) | Option overrides for multiple properties, identified by `properties` array. These defaults can be overridden in `options.animation` or `dataset.animation` and `tooltip.animation`. These keys are also [Scriptable](../general/options.md#scriptable-options) ## Animation mode configuration -Mode option configures how an update mode animates the chart. -The cores modes are `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`. +Mode option configures how an update mode animates the chart. +The cores modes are `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`. A custom mode can be used by passing a custom `mode` to [update](../developers/api.md#updatemode). A mode option is defined by the same options of the main [animation configuration](#animation-configuration). @@ -181,13 +183,13 @@ These default collections are overridden by most dataset controllers. ## Disabling animation -To disable an animation configuration, the animation node must be set to `false`, with the exception for animation modes which can be disable setting the `duration` to `0`. +To disable an animation configuration, the animation node must be set to `false`, with the exception for animation modes which can be disable setting the `duration` to `0`. ```javascript chart.options.animation = false; // disables the whole animation chart.options.animation.active.duration = 0; // disables the animation for 'active' mode chart.options.animation.colors = false; // disables animation defined by the collection of 'colors' properties -chart.options.animation.x = false; // disables animation defined by the 'x' property +chart.options.animation.x = false; // disables animation defined by the 'x' property ``` ## Easing
true
Other
chartjs
Chart.js
e277aa4c1fb0dffb7e59c31a4913d78687549a7e.json
Destroy example charts on unmount (#8004) * Destroy example charts on unmount * Make scatter live * Use spaces
docs/docs/getting-started/index.mdx
@@ -25,25 +25,26 @@ import { useEffect } from 'react'; ```jsx live function example() { useEffect(() => { - var ctx = document.getElementById('myChart').getContext('2d'); - var chart = new Chart(ctx, { - // The type of chart we want to create - type: 'line', - - // The data for our dataset - data: { - labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], - datasets: [{ - label: 'My First dataset', - backgroundColor: 'rgb(255, 99, 132)', - borderColor: 'rgb(255, 99, 132)', - data: [0, 10, 5, 2, 20, 30, 45] - }] - }, - - // Configuration options go here - options: {} - }); + var ctx = document.getElementById('myChart').getContext('2d'); + var chart = new Chart(ctx, { + // The type of chart we want to create + type: 'line', + + // The data for our dataset + data: { + labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], + datasets: [{ + label: 'My First dataset', + backgroundColor: 'rgb(255, 99, 132)', + borderColor: 'rgb(255, 99, 132)', + data: [0, 10, 5, 2, 20, 30, 45] + }] + }, + + // Configuration options go here + options: {} + }); + return () => chart.destroy(); }); return <div className="chartjs-wrapper"><canvas id="myChart" className="chartjs"></canvas></div>; }
true
Other
chartjs
Chart.js
b54679889710aedc0240631de105ae6de6d6040a.json
Change version to 3.0.0-mater and update deps (#7997)
package-lock.json
@@ -1,6 +1,6 @@ { "name": "chart.js", - "version": "3.0.0-beta.3", + "version": "3.0.0-master", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1937,9 +1937,9 @@ } }, "@eslint/eslintrc": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz", - "integrity": "sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.1.tgz", + "integrity": "sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA==", "dev": true, "requires": { "ajv": "^6.12.4", @@ -2060,9 +2060,9 @@ "dev": true }, "@rollup/plugin-commonjs": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-15.1.0.tgz", - "integrity": "sha512-xCQqz4z/o0h2syQ7d9LskIMvBSH4PX5PjYdpSSvgS+pQik3WahkQVNWg3D8XJeYjZoVWnIUQYDghuEMRGrmQYQ==", + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-16.0.0.tgz", + "integrity": "sha512-LuNyypCP3msCGVQJ7ki8PqYdpjfEkE/xtFa5DqlF+7IBD0JsfMZ87C58heSwIMint58sAUZbt3ITqOmdQv/dXw==", "dev": true, "requires": { "@rollup/pluginutils": "^3.1.0", @@ -2122,9 +2122,9 @@ } }, "@rollup/plugin-node-resolve": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-9.0.0.tgz", - "integrity": "sha512-gPz+utFHLRrd41WMP13Jq5mqqzHL3OXrfj3/MkSyB6UBIcuNt9j60GCbarzMzdf1VHFpOxfQh/ez7wyadLMqkg==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-10.0.0.tgz", + "integrity": "sha512-sNijGta8fqzwA1VwUEtTvWCx2E7qC70NMsDh4ZG13byAXYigBNZMxALhKUSycBks5gupJdq0lFrKumFrRZ8H3A==", "dev": true, "requires": { "@rollup/pluginutils": "^3.1.0", @@ -4011,13 +4011,13 @@ "dev": true }, "eslint": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.11.0.tgz", - "integrity": "sha512-G9+qtYVCHaDi1ZuWzBsOWo2wSwd70TXnU6UHA3cTYHp7gCTXZcpggWFoUVAMRarg68qtPoNfFbzPh+VdOgmwmw==", + "version": "7.12.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.12.1.tgz", + "integrity": "sha512-HlMTEdr/LicJfN08LB3nM1rRYliDXOmfoO4vj39xN6BLpFzF00hbwBoqHk8UcJ2M/3nlARZWy/mslvGEuZFvsg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@eslint/eslintrc": "^0.1.3", + "@eslint/eslintrc": "^0.2.1", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -5236,9 +5236,9 @@ "dev": true }, "is-docker": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.0.0.tgz", - "integrity": "sha512-pJEdRugimx4fBMra5z2/5iRdZ63OhYV0vr0Dwm5+xtW4D1FvRkB8hamMIhnWfyJeDdyr/aa7BDyNbtG38VxgoQ==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.1.1.tgz", + "integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==", "dev": true }, "is-extglob": { @@ -5430,9 +5430,9 @@ } }, "jasmine": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.6.2.tgz", - "integrity": "sha512-Uc0o2MRnC8TS1MjDrB8jE1umKEo2mflzGvdg0Ncs+yuLtOJ+uz/Wz8VmGsNGtuASr8+E0LDgPkOpvdoC76m5WQ==", + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.6.3.tgz", + "integrity": "sha512-Th91zHsbsALWjDUIiU5d/W5zaYQsZFMPTdeNmi8GivZPmAaUAK8MblSG3yQI4VMGC/abF2us7ex60NH1AAIMTA==", "dev": true, "requires": { "glob": "^7.1.6", @@ -5603,6 +5603,21 @@ "yargs": "^15.3.1" }, "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, "chokidar": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.3.tgz", @@ -5619,6 +5634,93 @@ "readdirp": "~3.5.0" } }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, "readdirp": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", @@ -5643,6 +5745,26 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, "tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -5651,6 +5773,46 @@ "requires": { "rimraf": "^3.0.0" } + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } }, @@ -5698,12 +5860,13 @@ } }, "karma-firefox-launcher": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.3.0.tgz", - "integrity": "sha512-Fi7xPhwrRgr+94BnHX0F5dCl1miIW4RHnzjIGxF8GaIEp7rNqX7LSi7ok63VXs3PS/5MQaQMhGxw+bvD+pibBQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.0.tgz", + "integrity": "sha512-dkiyqN2R6fCWt78rciOXJLFDWcQ7QEQi++HgebPJlw1y0ycDjGNDHuSrhdh48QG02fzZKK20WHFWVyBZ6CPngg==", "dev": true, "requires": { - "is-wsl": "^2.1.0" + "is-wsl": "^2.2.0", + "which": "^2.0.1" } }, "karma-jasmine": { @@ -6266,9 +6429,9 @@ "dev": true }, "promise-polyfill": { - "version": "8.1.3", - "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.1.3.tgz", - "integrity": "sha512-MG5r82wBzh7pSKDRa9y+vllNHz3e3d4CNj1PQE4BQYxLme0gKYYBm9YENq+UkEikyZ0XbiGWxYlVw3Rl9O/U8g==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.2.0.tgz", + "integrity": "sha512-k/TC0mIcPVF6yHhUvwAp7cvL6I2fFV7TzF1DuGPI8mBh4QQazf36xCKEHKTZKRysEoTQoQdKyP25J8MPJp7j5g==", "dev": true }, "psl": { @@ -6546,9 +6709,9 @@ } }, "rollup": { - "version": "2.32.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.32.0.tgz", - "integrity": "sha512-0FIG1jY88uhCP2yP4CfvtKEqPDRmsUwfY1kEOOM+DH/KOGATgaIFd/is1+fQOxsvh62ELzcFfKonwKWnHhrqmw==", + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.33.1.tgz", + "integrity": "sha512-uY4O/IoL9oNW8MMcbA5hcOaz6tZTMIh7qJHx/tzIJm+n1wLoY38BLn6fuy7DhR57oNFLMbDQtDeJoFURt5933w==", "dev": true, "requires": { "fsevents": "~2.1.2" @@ -7319,9 +7482,9 @@ "dev": true }, "typescript": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.3.tgz", - "integrity": "sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz", + "integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==", "dev": true }, "ua-parser-js": { @@ -7520,22 +7683,18 @@ "dev": true }, "yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.1.0.tgz", + "integrity": "sha512-upWFJOmDdHN0syLuESuvXDmrRcWd1QafJolHskzaw79uZa7/x53gxQKiR07W59GWY1tFhhU/Th9DrtSfpS782g==", "dev": true, "requires": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" + "y18n": "^5.0.2", + "yargs-parser": "^20.2.2" }, "dependencies": { "ansi-regex": { @@ -7545,24 +7704,23 @@ "dev": true }, "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "requires": { - "@types/color-name": "^1.1.1", "color-convert": "^2.0.1" } }, "cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.3.tgz", + "integrity": "sha512-Gj3QHTkVMPKqwP3f7B4KPkBZRMR9r4rfi5bXFpg1a+Svvj8l7q5CnkBkVQzfxT5DFSsGk2+PascOgL0JYkL2kw==", "dev": true, "requires": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" + "wrap-ansi": "^7.0.0" } }, "color-convert": { @@ -7586,61 +7744,12 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "requires": { - "p-locate": "^4.1.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "requires": { - "p-limit": "^2.2.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, "string-width": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", @@ -7662,25 +7771,27 @@ } }, "wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "requires": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, + "y18n": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz", + "integrity": "sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==", + "dev": true + }, "yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } + "version": "20.2.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.3.tgz", + "integrity": "sha512-emOFRT9WVHw03QSvN5qor9QQT9+sw5vwxfYweivSMHTcAXPefwVae2FjO7JJjj8hCE4CzPOPeFM83VwT29HCww==", + "dev": true } } },
true
Other
chartjs
Chart.js
b54679889710aedc0240631de105ae6de6d6040a.json
Change version to 3.0.0-mater and update deps (#7997)
package.json
@@ -2,7 +2,7 @@ "name": "chart.js", "homepage": "https://www.chartjs.org", "description": "Simple HTML5 charts using the canvas element.", - "version": "3.0.0-beta.3", + "version": "3.0.0-master", "license": "MIT", "jsdelivr": "dist/chart.min.js", "unpkg": "dist/chart.min.js", @@ -48,44 +48,44 @@ "@babel/plugin-transform-object-assign": "^7.12.1", "@babel/preset-env": "^7.12.1", "@kurkle/color": "^0.1.9", - "@rollup/plugin-commonjs": "^15.1.0", + "@rollup/plugin-commonjs": "^16.0.0", "@rollup/plugin-inject": "^4.0.2", "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^9.0.0", + "@rollup/plugin-node-resolve": "^10.0.0", "babel-plugin-istanbul": "^6.0.0", "babel-preset-es2015-rollup": "^3.0.0", "chartjs-adapter-moment": "^0.1.2", "concurrently": "^5.3.0", "coveralls": "^3.1.0", "cross-env": "^7.0.2", - "eslint": "^7.11.0", + "eslint": "^7.12.1", "eslint-config-chartjs": "^0.2.0", "eslint-config-esnext": "^4.1.0", "eslint-plugin-html": "^6.1.0", "glob": "^7.1.6", - "jasmine": "^3.6.2", + "jasmine": "^3.6.3", "jasmine-core": "^3.6.0", "karma": "^5.2.3", "karma-chrome-launcher": "^3.1.0", "karma-coverage": "^2.0.3", "karma-edge-launcher": "^0.4.2", - "karma-firefox-launcher": "^1.3.0", + "karma-firefox-launcher": "^2.1.0", "karma-jasmine": "^4.0.1", "karma-jasmine-html-reporter": "^1.5.4", "karma-rollup-preprocessor": "^7.0.5", "karma-safari-private-launcher": "^1.0.0", "moment": "^2.29.1", "pixelmatch": "^5.2.1", - "promise-polyfill": "^8.1.3", + "promise-polyfill": "^8.2.0", "resize-observer-polyfill": "^1.5.1", - "rollup": "^2.32.0", + "rollup": "^2.33.1", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-cleanup": "^3.2.1", "rollup-plugin-dts": "^1.4.13", "rollup-plugin-terser": "^7.0.2", "typedoc": "^0.19.2", - "typescript": "^4.0.3", - "yargs": "^15.4.1" + "typescript": "^4.0.5", + "yargs": "^16.1.0" }, "dependencies": {} }
true
Other
chartjs
Chart.js
4daf37e864872d7fe244f17f1820798523d9d043.json
Delay resize to just before draw when animating (#7989) * Remove unused properties * Delay resize to just before draw when animating * Remove silent resize, update migration guide * Fix typo in migrations doc Co-authored-by: Evert Timberg <evert.timberg+github@gmail.com>
docs/docs/getting-started/v3-migration.md
@@ -366,6 +366,8 @@ The following public APIs were removed. The following private APIs were removed. +* `Chart._bufferedRender` +* `Chart._updating` * `Chart.data.datasets[datasetIndex]._meta` * `DatasetController._getIndexScaleId` * `DatasetController._getIndexScale` @@ -457,6 +459,7 @@ The APIs listed in this section have changed in signature or behaviour from vers ##### Core Controller * The first parameter to `updateHoverStyle` is now an array of objects containing the `element`, `datasetIndex`, and `index` +* The signature or `resize` changed, the first `silent` parameter was removed. ##### Dataset Controllers @@ -492,3 +495,4 @@ All helpers are now exposed in a flat hierarchy, e.g., `Chart.helpers.canvas.cli * `afterDatasetsUpdate`, `afterUpdate`, `beforeDatasetsUpdate`, and `beforeUpdate` now receive `args` object as second argument. `options` argument is always the last and thus was moved from 2nd to 3rd place. * `afterEvent` and `beforeEvent` now receive a wrapped `event` as the second argument. The native event is available via `event.native`. +* Initial `resize` is no longer silent. Meaning that `resize` event can fire between `beforeInit` and `afterInit`
true
Other
chartjs
Chart.js
4daf37e864872d7fe244f17f1820798523d9d043.json
Delay resize to just before draw when animating (#7989) * Remove unused properties * Delay resize to just before draw when animating * Remove silent resize, update migration guide * Fix typo in migrations doc Co-authored-by: Evert Timberg <evert.timberg+github@gmail.com>
src/core/core.controller.js
@@ -97,7 +97,6 @@ class Chart { this.height = height; this.aspectRatio = height ? width / height : null; this.options = config.options; - this._bufferedRender = false; this._layers = []; this._metasets = []; this.boxes = []; @@ -108,7 +107,6 @@ class Chart { /** @type {{attach?: function, detach?: function, resize?: function}} */ this._listeners = {}; this._sortedMetasets = []; - this._updating = false; this.scales = {}; this.scale = undefined; this._plugins = new PluginService(); @@ -157,8 +155,7 @@ class Chart { me._plugins.notify(me, 'beforeInit'); if (me.options.responsive) { - // Initial resize before chart draws (must be silent to preserve initial animations). - me.resize(true); + me.resize(); } else { retinaScale(me, me.options.devicePixelRatio); } @@ -193,7 +190,15 @@ class Chart { return this; } - resize(silent, width, height) { + resize(width, height) { + if (!animator.running(this)) { + this._resize(width, height); + } else { + this._resizeBeforeDraw = {width, height}; + } + } + + _resize(width, height) { const me = this; const options = me.options; const canvas = me.canvas; @@ -217,14 +222,12 @@ class Chart { retinaScale(me, newRatio); - if (!silent) { - me._plugins.notify(me, 'resize', [newSize]); + me._plugins.notify(me, 'resize', [newSize]); - callCallback(options.onResize, [newSize], me); + callCallback(options.onResize, [newSize], me); - if (me.attached) { - me.update('resize'); - } + if (me.attached) { + me.update('resize'); } } @@ -426,8 +429,6 @@ class Chart { const args = {mode}; let i, ilen; - me._updating = true; - each(me.scales, (scale) => { layouts.removeBox(me, scale); }); @@ -475,8 +476,6 @@ class Chart { } me.render(); - - me._updating = false; } /** @@ -569,7 +568,11 @@ class Chart { draw() { const me = this; let i; - + if (me._resizeBeforeDraw) { + const {width, height} = me._resizeBeforeDraw; + me._resize(width, height); + me._resizeBeforeDraw = null; + } me.clear(); if (me.width <= 0 || me.height <= 0) { @@ -848,7 +851,7 @@ class Chart { if (me.options.responsive) { listener = (width, height) => { if (me.canvas) { - me.resize(false, width, height); + me.resize(width, height); } };
true
Other
chartjs
Chart.js
4daf37e864872d7fe244f17f1820798523d9d043.json
Delay resize to just before draw when animating (#7989) * Remove unused properties * Delay resize to just before draw when animating * Remove silent resize, update migration guide * Fix typo in migrations doc Co-authored-by: Evert Timberg <evert.timberg+github@gmail.com>
test/specs/core.controller.tests.js
@@ -1289,6 +1289,7 @@ describe('Chart', function() { var hooks = { init: [ 'beforeInit', + 'resize', 'afterInit' ], update: [
true
Other
chartjs
Chart.js
4daf37e864872d7fe244f17f1820798523d9d043.json
Delay resize to just before draw when animating (#7989) * Remove unused properties * Delay resize to just before draw when animating * Remove silent resize, update migration guide * Fix typo in migrations doc Co-authored-by: Evert Timberg <evert.timberg+github@gmail.com>
types/core/index.d.ts
@@ -277,7 +277,7 @@ export declare class Chart< clear(): this; stop(): this; - resize(silent: boolean, width: number, height: number): void; + resize(width: number, height: number): void; ensureScalesHaveIDs(): void; buildOrUpdateScales(): void; buildOrUpdateControllers(): void;
true
Other
chartjs
Chart.js
23bf7c0c89bd3e5ed4cbc2709a08eac63ad1c67d.json
Preserve scriptable context (#7981) * Preserve scriptable context * CC, utilize `index` in tests * Update example to utilize context
docs/docs/general/options.md
@@ -37,14 +37,52 @@ color: [ ## Option Context The option context is used to give contextual information when resolving options and currently only applies to [scriptable options](#scriptable-options). +The object is preserved, so it can be used to store and pass information between calls. + +There are multiple levels of context objects: + +- `chart` + - `dataset` + - `data` + - `scale` + - `tick` + +Each level inherits its parent(s) and any contextual information stored in the parent is available through the child. The context object contains the following properties: +### chart + - `chart`: the associated chart -- `dataPoint`: the parsed data values for the given `dataIndex` and `datasetIndex` -- `dataIndex`: index of the current data + +### dataset + +In addition to [chart](#chart) + +- `active`: true if element is active (hovered) - `dataset`: dataset at index `datasetIndex` - `datasetIndex`: index of the current dataset +- `index`: getter for `datasetIndex` + +### data + +In addition to [dataset](#dataset) + - `active`: true if element is active (hovered) +- `dataIndex`: index of the current data +- `dataPoint`: the parsed data values for the given `dataIndex` and `datasetIndex` +- `element`: the element (point, arc, bar, etc.) for this data +- `index`: getter for `dataIndex` + +### scale + +In addition to [chart](#chart) + +- `scale`: the associated scale + +### tick + +In addition to [scale](#scale) -**Important**: since the context can represent different types of entities (dataset, data, ticks, etc.), some properties may be `undefined` so be sure to test any context property before using it. +- `tick`: the associated tick object +- `index`: tick index
true
Other
chartjs
Chart.js
23bf7c0c89bd3e5ed4cbc2709a08eac63ad1c67d.json
Preserve scriptable context (#7981) * Preserve scriptable context * CC, utilize `index` in tests * Update example to utilize context
samples/animations/delay.html
@@ -63,7 +63,6 @@ }; window.onload = function() { var ctx = document.getElementById('canvas').getContext('2d'); - var started = {}; window.myBar = new Chart(ctx, { type: 'bar', data: barChartData, @@ -77,9 +76,9 @@ var delay = 0; var dsIndex = context.datasetIndex; var index = context.dataIndex; - if (!started[index + dsIndex * 1000]) { + if (context.dataPoint && !context.delayed) { delay = index * 300 + dsIndex * 100; - started[index + dsIndex * 1000] = true; + context.delayed = true; } return { easing: 'linear',
true
Other
chartjs
Chart.js
23bf7c0c89bd3e5ed4cbc2709a08eac63ad1c67d.json
Preserve scriptable context (#7981) * Preserve scriptable context * CC, utilize `index` in tests * Update example to utilize context
src/core/core.controller.js
@@ -116,6 +116,7 @@ class Chart { this._hiddenIndices = {}; this.attached = false; this._animationsDisabled = undefined; + this.$context = undefined; // Add the chart instance to the global namespace Chart.instances[me.id] = me; @@ -712,6 +713,14 @@ class Chart { return meta; } + getContext() { + return this.$context || (this.$context = Object.create(null, { + chart: { + value: this + } + })); + } + getVisibleDatasetCount() { return this.getSortedVisibleDatasetMetas().length; }
true
Other
chartjs
Chart.js
23bf7c0c89bd3e5ed4cbc2709a08eac63ad1c67d.json
Preserve scriptable context (#7981) * Preserve scriptable context * CC, utilize `index` in tests * Update example to utilize context
src/core/core.datasetController.js
@@ -148,6 +148,49 @@ function getFirstScaleId(chart, axis) { return Object.keys(scales).filter(key => scales[key].axis === axis).shift(); } +function createDatasetContext(parent, index, dataset) { + return Object.create(parent, { + active: { + writable: true, + value: false + }, + dataset: { + value: dataset + }, + datasetIndex: { + value: index + }, + index: { + get() { + return this.datasetIndex; + } + } + }); +} + +function createDataContext(parent, index, point, element) { + return Object.create(parent, { + active: { + writable: true, + value: false + }, + dataIndex: { + value: index + }, + dataPoint: { + value: point + }, + element: { + value: element + }, + index: { + get() { + return this.dataIndex; + } + } + }); +} + const optionKeys = (optionNames) => isArray(optionNames) ? optionNames : Object.keys(optionNames); const optionKey = (key, active) => active ? 'hover' + _capitalize(key) : key; const isDirectUpdateMode = (mode) => mode === 'reset' || mode === 'none'; @@ -177,6 +220,7 @@ export default class DatasetController { this._drawStart = undefined; this._drawCount = undefined; this.enableOptionSharing = false; + this.$context = undefined; this.initialize(); } @@ -491,6 +535,13 @@ export default class DatasetController { return this._cachedMeta._parsed[index]; } + /** + * @protected + */ + getDataElement(index) { + return this._cachedMeta.data[index]; + } + /** * @protected */ @@ -698,14 +749,18 @@ export default class DatasetController { * @protected */ getContext(index, active) { - return { - chart: this.chart, - dataPoint: this.getParsed(index), - dataIndex: index, - dataset: this.getDataset(), - datasetIndex: this.index, - active - }; + const me = this; + let context; + if (index >= 0 && index < me._cachedMeta.data.length) { + const element = me._cachedMeta.data[index]; + context = element.$context || + (element.$context = createDataContext(me.getContext(), index, me.getParsed(index), element)); + } else { + context = me.$context || (me.$context = createDatasetContext(me.chart.getContext(), me.index, me.getDataset())); + } + + context.active = !!active; + return context; } /**
true
Other
chartjs
Chart.js
23bf7c0c89bd3e5ed4cbc2709a08eac63ad1c67d.json
Preserve scriptable context (#7981) * Preserve scriptable context * CC, utilize `index` in tests * Update example to utilize context
src/core/core.scale.js
@@ -8,7 +8,7 @@ import Ticks from './core.ticks'; /** * @typedef { import("./core.controller").default } Chart - * @typedef {{value:any, label?:string, major?:boolean}} Tick + * @typedef {{value:any, label?:string, major?:boolean, $context?:any}} Tick */ defaults.set('scale', { @@ -269,6 +269,25 @@ function skip(ticks, newTicks, spacing, majorStart, majorEnd) { } } +function createScaleContext(parent, scale) { + return Object.create(parent, { + scale: { + value: scale + }, + }); +} + +function createTickContext(parent, index, tick) { + return Object.create(parent, { + tick: { + value: tick + }, + index: { + value: index + } + }); +} + export default class Scale extends Element { // eslint-disable-next-line max-statements @@ -345,6 +364,7 @@ export default class Scale extends Element { this._ticksLength = 0; this._borderValue = 0; this._cache = {}; + this.$context = undefined; } /** @@ -1043,13 +1063,16 @@ export default class Scale extends Element { * @protected */ getContext(index) { - const ticks = this.ticks || []; - return { - chart: this.chart, - scale: this, - tick: ticks[index], - index - }; + const me = this; + const ticks = me.ticks || []; + + if (index >= 0 && index < ticks.length) { + const tick = ticks[index]; + return tick.$context || + (tick.$context = createTickContext(me.getContext(), index, tick)); + } + return me.$context || + (me.$context = createScaleContext(me.chart.getContext(), me)); } /**
true
Other
chartjs
Chart.js
23bf7c0c89bd3e5ed4cbc2709a08eac63ad1c67d.json
Preserve scriptable context (#7981) * Preserve scriptable context * CC, utilize `index` in tests * Update example to utilize context
test/fixtures/controller.line/backgroundColor/scriptable.js
@@ -8,7 +8,7 @@ module.exports = { // option in dataset data: [4, 5, 10, null, -10, -5], backgroundColor: function(ctx) { - var index = (ctx.dataIndex === undefined ? ctx.datasetIndex : ctx.dataIndex); + var index = ctx.index; return index === 0 ? '#ff0000' : index === 1 ? '#00ff00' : '#ff00ff'; @@ -26,7 +26,7 @@ module.exports = { elements: { line: { backgroundColor: function(ctx) { - var index = (ctx.dataIndex === undefined ? ctx.datasetIndex : ctx.dataIndex); + var index = ctx.index; return index === 0 ? '#ff0000' : index === 1 ? '#00ff00' : '#ff00ff';
true
Other
chartjs
Chart.js
23bf7c0c89bd3e5ed4cbc2709a08eac63ad1c67d.json
Preserve scriptable context (#7981) * Preserve scriptable context * CC, utilize `index` in tests * Update example to utilize context
test/fixtures/controller.line/borderColor/scriptable.js
@@ -8,7 +8,7 @@ module.exports = { // option in dataset data: [4, 5, 10, null, -10, -5], borderColor: function(ctx) { - var index = (ctx.dataIndex === undefined ? ctx.datasetIndex : ctx.dataIndex); + var index = ctx.index; return index === 0 ? '#ff0000' : index === 1 ? '#00ff00' : '#0000ff'; @@ -26,7 +26,7 @@ module.exports = { elements: { line: { borderColor: function(ctx) { - var index = (ctx.dataIndex === undefined ? ctx.datasetIndex : ctx.dataIndex); + var index = ctx.index; return index === 0 ? '#ff0000' : index === 1 ? '#00ff00' : '#0000ff';
true
Other
chartjs
Chart.js
23bf7c0c89bd3e5ed4cbc2709a08eac63ad1c67d.json
Preserve scriptable context (#7981) * Preserve scriptable context * CC, utilize `index` in tests * Update example to utilize context
test/fixtures/controller.line/borderWidth/scriptable.js
@@ -9,7 +9,7 @@ module.exports = { data: [4, 5, 10, null, -10, -5], borderColor: '#0000ff', borderWidth: function(ctx) { - var index = (ctx.dataIndex === undefined ? ctx.datasetIndex : ctx.dataIndex); + var index = ctx.index; return index % 2 ? 10 : 20; }, pointBorderColor: '#00ff00' @@ -27,7 +27,7 @@ module.exports = { line: { borderColor: '#ff0000', borderWidth: function(ctx) { - var index = (ctx.dataIndex === undefined ? ctx.datasetIndex : ctx.dataIndex); + var index = ctx.index; return index % 2 ? 10 : 20; }, fill: false,
true
Other
chartjs
Chart.js
23bf7c0c89bd3e5ed4cbc2709a08eac63ad1c67d.json
Preserve scriptable context (#7981) * Preserve scriptable context * CC, utilize `index` in tests * Update example to utilize context
test/fixtures/controller.radar/backgroundColor/scriptable.js
@@ -8,7 +8,7 @@ module.exports = { // option in dataset data: [0, 5, 10, null, -10, -5], backgroundColor: function(ctx) { - var index = (ctx.dataIndex === undefined ? ctx.datasetIndex : ctx.dataIndex); + var index = ctx.index; return index === 0 ? '#ff0000' : index === 1 ? '#00ff00' : '#ff00ff'; @@ -26,7 +26,7 @@ module.exports = { elements: { line: { backgroundColor: function(ctx) { - var index = (ctx.dataIndex === undefined ? ctx.datasetIndex : ctx.dataIndex); + var index = ctx.index; return index === 0 ? '#ff0000' : index === 1 ? '#00ff00' : '#ff00ff';
true