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
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/cubicInterpolationMode/scriptable.js
@@ -35,8 +35,8 @@ module.exports = { padding: 32 }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/cubicInterpolationMode/value.js
@@ -31,8 +31,8 @@ module.exports = { padding: 32 }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/fill/order-default.js
@@ -31,8 +31,8 @@ module.exports = { padding: 32 }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/fill/order.js
@@ -31,8 +31,8 @@ module.exports = { padding: 32 }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/fill/scriptable.js
@@ -33,8 +33,8 @@ module.exports = { padding: 32 }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/fill/value.js
@@ -29,8 +29,8 @@ module.exports = { padding: 32 }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/non-numeric-y.json
@@ -17,11 +17,11 @@ "legend": false, "title": false, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{ + "x": {"display": false}, + "y": { "type": "category", "display": false - }] + } } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/point-style.json
@@ -64,12 +64,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{ + "x": {"display": false}, + "y": { "display": false, "min": 0, "max": 4 - }] + } }, "elements": { "line": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointBackgroundColor/indexable.js
@@ -42,8 +42,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointBackgroundColor/scriptable.js
@@ -40,13 +40,11 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [ - { - display: false, - beginAtZero: true - } - ] + x: {display: false}, + y: { + display: false, + beginAtZero: true + } } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointBackgroundColor/value.js
@@ -28,8 +28,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointBorderColor/indexable.js
@@ -42,8 +42,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointBorderColor/scriptable.js
@@ -40,13 +40,11 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [ - { - display: false, - beginAtZero: true - } - ] + x: {display: false}, + y: { + display: false, + beginAtZero: true + } } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointBorderColor/value.js
@@ -28,8 +28,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointBorderWidth/indexable.js
@@ -34,8 +34,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointBorderWidth/scriptable.js
@@ -40,13 +40,11 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [ - { - display: false, - beginAtZero: true - } - ] + x: {display: false}, + y: { + display: false, + beginAtZero: true + } } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointBorderWidth/value.js
@@ -30,8 +30,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointStyle/indexable.js
@@ -46,8 +46,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointStyle/scriptable.js
@@ -44,13 +44,11 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [ - { - display: false, - beginAtZero: true - } - ] + x: {display: false}, + y: { + display: false, + beginAtZero: true + } } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/pointStyle/value.js
@@ -30,8 +30,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/radius/indexable.js
@@ -33,8 +33,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/radius/scriptable.js
@@ -39,13 +39,11 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [ - { - display: false, - beginAtZero: true - } - ] + x: {display: false}, + y: { + display: false, + beginAtZero: true + } } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/radius/value.js
@@ -29,8 +29,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/rotation/indexable.js
@@ -35,8 +35,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/rotation/scriptable.js
@@ -41,13 +41,11 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [ - { - display: false, - beginAtZero: true - } - ] + x: {display: false}, + y: { + display: false, + beginAtZero: true + } } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/rotation/value.js
@@ -31,8 +31,8 @@ module.exports = { } }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/stacking/order-default.js
@@ -31,8 +31,8 @@ module.exports = { padding: 32 }, scales: { - xAxes: [{stacked: true, display: false}], - yAxes: [{stacked: true, display: false}] + x: {stacked: true, display: false}, + y: {stacked: true, display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/controller.line/stacking/order-specified.js
@@ -33,8 +33,8 @@ module.exports = { padding: 32 }, scales: { - xAxes: [{stacked: true, display: false}], - yAxes: [{stacked: true, display: false}] + x: {stacked: true, display: false}, + y: {stacked: true, display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/core.scale/label-offset-vertical-axes.json
@@ -11,24 +11,24 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "ticks": { "display": false }, "gridLines":{ "display": false, "drawBorder": false } - }], - "yAxes": [{ + }, + "y": { "ticks": { "labelOffset": 25 }, "gridLines":{ "display": false, "drawBorder": false } - }] + } } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/core.scale/tick-drawing.json
@@ -9,7 +9,7 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "type": "category", "position": "top", "id": "x-axis-1", @@ -21,10 +21,10 @@ "drawBorder": false, "color": "rgba(0, 0, 0, 1)" } - }, { + }, + "x2": { "type": "category", "position": "bottom", - "id": "x-axis-2", "ticks": { "display": false }, @@ -33,36 +33,40 @@ "drawBorder": false, "color": "rgba(0, 0, 0, 1)" } - }], - "yAxes": [{ + }, + "y": { "position": "left", "id": "y-axis-1", "type": "linear", + "offset": false, "min": -100, "max": 100, "ticks": { "display": false }, "gridLines":{ + "offsetGridLines": false, "drawOnChartArea": false, "drawBorder": false, "color": "rgba(0, 0, 0, 1)" } - }, { + }, + "y2": { "type": "linear", - "id": "y-axis-2", "position": "right", + "offset": false, "min": 0, "max": 50, "ticks": { "display": false }, "gridLines":{ + "offsetGridLines": false, "drawOnChartArea": false, "drawBorder": false, "color": "rgba(0, 0, 0, 1)" } - }] + } } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/core.tooltip/opacity.js
@@ -38,8 +38,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} }, elements: { line: {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/default.js
@@ -12,8 +12,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/skip/all.js
@@ -15,8 +15,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/skip/first-span.js
@@ -16,8 +16,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/skip/first.js
@@ -15,8 +15,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/skip/last-span.js
@@ -16,8 +16,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/skip/last.js
@@ -15,8 +15,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/skip/middle-span.js
@@ -16,8 +16,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/skip/middle.js
@@ -15,8 +15,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/stepped/after.js
@@ -16,8 +16,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/stepped/before.js
@@ -16,8 +16,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/stepped/default.js
@@ -16,8 +16,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/stepped/middle.js
@@ -16,8 +16,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/tension/default.js
@@ -14,8 +14,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/tension/one.js
@@ -15,8 +15,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.line/tension/zero.js
@@ -15,8 +15,8 @@ module.exports = { legend: false, title: false, scales: { - xAxes: [{type: 'linear', display: false, min: 0, max: 20}], - yAxes: [{display: false, min: -15, max: 15}] + x: {type: 'linear', display: false, min: 0, max: 20}, + y: {display: false, min: -15, max: 15} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-circle.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-cross-rot.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-cross.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-dash.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-image.js
@@ -44,8 +44,8 @@ module.exports = { padding: 20 }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-line.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-rect-rot.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-rect-rounded.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-rect.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-star.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/point-style-triangle.json
@@ -53,8 +53,8 @@ "padding": 40 }, "scales": { - "xAxes": [{"display": false}], - "yAxes": [{"display": false}] + "x": {"display": false}, + "y": {"display": false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/element.point/rotation.js
@@ -42,8 +42,8 @@ module.exports = { padding: 20 }, scales: { - xAxes: [{display: false}], - yAxes: [{display: false}] + x: {display: false}, + y: {display: false} } } },
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-end-span.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-end.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-origin-span.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-origin-spline-span.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-origin-spline.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-origin-stepped-span.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-origin-stepped.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-origin.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-start-span.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-boundary-start.json
@@ -23,12 +23,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-dataset-border.json
@@ -31,12 +31,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-dataset-span.json
@@ -31,12 +31,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-dataset-spline-span.json
@@ -31,12 +31,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-dataset-spline.json
@@ -31,12 +31,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/plugin.filler/fill-line-dataset.json
@@ -31,12 +31,12 @@ "legend": false, "title": false, "scales": { - "xAxes": [{ + "x": { "display": false - }], - "yAxes": [{ + }, + "y": { "display": false - }] + } }, "elements": { "point": {
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/fixtures/scale.radialLinear/indexable-gridlines.json
@@ -10,6 +10,7 @@ "title": false, "scale": { "gridLines": { + "display": true, "color": [ "rgba(0, 0, 0, 0.5)", "rgba(255, 255, 255, 0.5)",
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/controller.bar.tests.js
@@ -41,21 +41,11 @@ describe('Chart.controllers.bar', function() { ], labels: [] }, - options: { - scales: { - xAxes: [{ - id: 'firstXScaleID' - }], - yAxes: [{ - id: 'firstYScaleID' - }] - } - } }); var meta = chart.getDatasetMeta(1); - expect(meta.xAxisID).toBe('firstXScaleID'); - expect(meta.yAxisID).toBe('firstYScaleID'); + expect(meta.xAxisID).toBe('x'); + expect(meta.yAxisID).toBe('y'); }); it('should correctly count the number of stacks ignoring datasets of other types and hidden datasets', function() { @@ -122,12 +112,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: true - }], - yAxes: [{ + }, + y: { stacked: true - }] + } } } }); @@ -155,12 +145,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: false - }], - yAxes: [{ + }, + y: { stacked: false - }] + } } } }); @@ -211,12 +201,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: true - }], - yAxes: [{ + }, + y: { stacked: true - }] + } } } }); @@ -244,12 +234,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: false - }], - yAxes: [{ + }, + y: { stacked: false - }] + } } } }); @@ -300,12 +290,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: true - }], - yAxes: [{ + }, + y: { stacked: true - }] + } } } }); @@ -333,12 +323,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: false - }], - yAxes: [{ + }, + y: { stacked: false - }] + } } } }); @@ -416,12 +406,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: true - }], - yAxes: [{ + }, + y: { stacked: true - }] + } } } }); @@ -452,12 +442,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: false - }], - yAxes: [{ + }, + y: { stacked: false - }] + } } } }); @@ -514,12 +504,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: true - }], - yAxes: [{ + }, + y: { stacked: true - }] + } } } }); @@ -550,12 +540,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: false - }], - yAxes: [{ + }, + y: { stacked: false - }] + } } } }); @@ -612,12 +602,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: true - }], - yAxes: [{ + }, + y: { stacked: true - }] + } } } }); @@ -648,12 +638,12 @@ describe('Chart.controllers.bar', function() { }, options: { scales: { - xAxes: [{ + x: { stacked: false - }], - yAxes: [{ + }, + y: { stacked: false - }] + } } } }); @@ -712,16 +702,14 @@ describe('Chart.controllers.bar', function() { } }, scales: { - xAxes: [{ - id: 'firstXScaleID', + x: { type: 'category', display: false - }], - yAxes: [{ - id: 'firstYScaleID', + }, + y: { type: 'linear', display: false - }] + } } } }); @@ -778,14 +766,14 @@ describe('Chart.controllers.bar', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { type: 'category', display: false - }], - yAxes: [{ + }, + y: { type: 'linear', display: false - }] + } } } }); @@ -819,15 +807,15 @@ describe('Chart.controllers.bar', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { type: 'category', display: false - }], - yAxes: [{ + }, + y: { type: 'linear', display: false, stacked: true - }] + } } } }); @@ -878,17 +866,17 @@ describe('Chart.controllers.bar', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { type: 'category', display: false - }], - yAxes: [{ + }, + y: { type: 'linear', display: false, stacked: true, min: 50, max: 100 - }] + } } } }); @@ -939,15 +927,15 @@ describe('Chart.controllers.bar', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { type: 'category', display: false, stacked: true - }], - yAxes: [{ + }, + y: { type: 'linear', display: false - }] + } } } }); @@ -998,15 +986,15 @@ describe('Chart.controllers.bar', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { type: 'category', display: false - }], - yAxes: [{ + }, + y: { type: 'linear', display: false, stacked: true - }] + } } } }); @@ -1059,15 +1047,15 @@ describe('Chart.controllers.bar', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { type: 'category', display: false - }], - yAxes: [{ + }, + y: { type: 'linear', display: false, stacked: true - }] + } } } }); @@ -1118,15 +1106,15 @@ describe('Chart.controllers.bar', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { type: 'category', display: false - }], - yAxes: [{ + }, + y: { type: 'linear', display: false, stacked: true, - }] + } } } }); @@ -1164,15 +1152,15 @@ describe('Chart.controllers.bar', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { type: 'category', display: false - }], - yAxes: [{ + }, + y: { type: 'linear', display: false, stacked: true - }] + } } } }); @@ -1212,16 +1200,16 @@ describe('Chart.controllers.bar', function() { } }, scales: { - xAxes: [{ + x: { type: 'category', display: false, stacked: true, - }], - yAxes: [{ + }, + y: { type: 'logarithmic', display: false, stacked: true - }] + } } } }); @@ -1277,16 +1265,16 @@ describe('Chart.controllers.bar', function() { } }, scales: { - xAxes: [{ + x: { type: 'category', display: false, stacked: true, - }], - yAxes: [{ + }, + y: { type: 'logarithmic', display: false, stacked: true - }] + } } } }); @@ -1511,10 +1499,10 @@ describe('Chart.controllers.bar', function() { data: this.data, options: { scales: { - xAxes: [{ + x: { min: 'March', max: 'May', - }] + } } } }; @@ -1526,13 +1514,13 @@ describe('Chart.controllers.bar', function() { data: this.data, options: { scales: { - xAxes: [{ + x: { min: 'March', max: 'May', - }], - yAxes: [{ + }, + y: { stacked: true - }] + } } } }; @@ -1585,10 +1573,10 @@ describe('Chart.controllers.bar', function() { data: this.data, options: { scales: { - yAxes: [{ + y: { min: 'March', max: 'May', - }] + } } } }; @@ -1600,13 +1588,13 @@ describe('Chart.controllers.bar', function() { data: this.data, options: { scales: { - xAxes: [{ + x: { stacked: true - }], - yAxes: [{ + }, + y: { min: 'March', max: 'May', - }] + } } } }; @@ -1636,13 +1624,13 @@ describe('Chart.controllers.bar', function() { } }, scales: { - xAxes: [{ + x: { id: 'x', type: 'category', - }], - yAxes: [{ + }, + y: { type: 'linear', - }] + } } } }); @@ -1724,5 +1712,4 @@ describe('Chart.controllers.bar', function() { expect(data[0]._model.base + minBarLength).toEqual(data[0]._model.x); expect(data[1]._model.base - minBarLength).toEqual(data[1]._model.x); }); - });
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/controller.bubble.tests.js
@@ -33,22 +33,12 @@ describe('Chart.controllers.bubble', function() { data: [] }] }, - options: { - scales: { - xAxes: [{ - id: 'firstXScaleID' - }], - yAxes: [{ - id: 'firstYScaleID' - }] - } - } }); var meta = chart.getDatasetMeta(0); - expect(meta.xAxisID).toBe('firstXScaleID'); - expect(meta.yAxisID).toBe('firstYScaleID'); + expect(meta.xAxisID).toBe('x'); + expect(meta.yAxisID).toBe('y'); }); it('should create point elements for each data item during initialization', function() { @@ -128,14 +118,14 @@ describe('Chart.controllers.bubble', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { type: 'category', display: false - }], - yAxes: [{ + }, + y: { type: 'linear', display: false - }] + } } } });
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/controller.line.tests.js
@@ -35,21 +35,11 @@ describe('Chart.controllers.line', function() { }], labels: [] }, - options: { - scales: { - xAxes: [{ - id: 'firstXScaleID' - }], - yAxes: [{ - id: 'firstYScaleID' - }] - } - } }); var meta = chart.getDatasetMeta(0); - expect(meta.xAxisID).toBe('firstXScaleID'); - expect(meta.yAxisID).toBe('firstYScaleID'); + expect(meta.xAxisID).toBe('x'); + expect(meta.yAxisID).toBe('y'); }); it('Should create line elements and point elements for each data item during initialization', function() { @@ -173,8 +163,8 @@ describe('Chart.controllers.line', function() { datasets: [{ data: [10, 15, 0, -4], label: 'dataset', - xAxisID: 'firstXScaleID', - yAxisID: 'firstYScaleID' + xAxisID: 'x', + yAxisID: 'y' }], labels: ['label1', 'label2', 'label3', 'label4'] }, @@ -189,14 +179,12 @@ describe('Chart.controllers.line', function() { } }, scales: { - xAxes: [{ - id: 'firstXScaleID', + x: { display: false - }], - yAxes: [{ - id: 'firstYScaleID', + }, + y: { display: false - }] + } } }, }); @@ -246,13 +234,13 @@ describe('Chart.controllers.line', function() { intersect: true }, scales: { - xAxes: [{ + x: { display: false, - }], - yAxes: [{ + }, + y: { display: false, beginAtZero: true - }] + } } } }); @@ -313,13 +301,13 @@ describe('Chart.controllers.line', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { display: false, - }], - yAxes: [{ + }, + y: { display: false, stacked: true - }] + } } } }); @@ -363,25 +351,26 @@ describe('Chart.controllers.line', function() { }, { data: [10, 10, -10, -10], label: 'dataset3', - yAxisID: 'secondAxis' + yAxisID: 'y2' }], labels: ['label1', 'label2', 'label3', 'label4'] }, options: { legend: false, title: false, scales: { - xAxes: [{ + x: { display: false, - }], - yAxes: [{ + }, + y: { display: false, stacked: true - }, { - id: 'secondAxis', + }, + y2: { type: 'linear', + position: 'right', display: false - }] + } } } }); @@ -453,13 +442,13 @@ describe('Chart.controllers.line', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { display: false, - }], - yAxes: [{ + }, + y: { display: false, stacked: true - }] + } } } }); @@ -507,13 +496,13 @@ describe('Chart.controllers.line', function() { legend: false, title: false, scales: { - xAxes: [{ + x: { display: false, - }], - yAxes: [{ + }, + y: { display: false, stacked: true - }] + } } } });
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/core.controller.tests.js
@@ -130,19 +130,19 @@ describe('Chart', function() { type: 'line', options: { scales: { - xAxes: [{ + x: { position: 'left', - }], - yAxes: [{ + }, + y: { position: 'bottom' - }] + } } } }); var scaleOptions = chart.options.scales; - expect(scaleOptions.xAxes[0].position).toBe('bottom'); - expect(scaleOptions.yAxes[0].position).toBe('left'); + expect(scaleOptions.x.position).toBe('bottom'); + expect(scaleOptions.y.position).toBe('left'); }); it('should throw an error if the chart type is incorrect', function() { @@ -158,12 +158,14 @@ describe('Chart', function() { }, options: { scales: { - xAxes: [{ + x: { + type: 'linear', position: 'left', - }], - yAxes: [{ + }, + y: { + type: 'category', position: 'bottom' - }] + } } } }); @@ -199,22 +201,18 @@ describe('Chart', function() { type: 'line', options: { scales: { - xAxes: [ - {id: 'foo0'}, - {id: 'foo1'} - ], - yAxes: [ - {id: 'bar0'}, - {id: 'bar1'} - ] + xFoo0: {}, + xFoo1: {}, + yBar0: {}, + yBar1: {}, } } }); - expect(chart.scales.foo0.type).toBe('category'); - expect(chart.scales.foo1.type).toBe('category'); - expect(chart.scales.bar0.type).toBe('linear'); - expect(chart.scales.bar1.type).toBe('linear'); + expect(chart.scales.xFoo0.type).toBe('category'); + expect(chart.scales.xFoo1.type).toBe('category'); + expect(chart.scales.yBar0.type).toBe('linear'); + expect(chart.scales.yBar1.type).toBe('linear'); }); it('should correctly apply defaults on central scale', function() { @@ -233,7 +231,7 @@ describe('Chart', function() { // let's check a few values from the user options and defaults expect(chart.scales.foo.type).toBe('logarithmic'); - expect(chart.scales.foo.options).toBe(chart.options.scale); + expect(chart.scales.foo.options).toEqual(chart.options.scales.foo); expect(chart.scales.foo.options).toEqual( jasmine.objectContaining({ _jasmineCheckA: 'a0', @@ -248,35 +246,33 @@ describe('Chart', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'foo', + x: { type: 'logarithmic', _jasmineCheckC: 'c2', _jasmineCheckD: 'd2' - }], - yAxes: [{ - id: 'bar', + }, + y: { type: 'time', _jasmineCheckC: 'c2', _jasmineCheckE: 'e2' - }] + } } } }); - expect(chart.scales.foo.type).toBe('logarithmic'); - expect(chart.scales.foo.options).toBe(chart.options.scales.xAxes[0]); - expect(chart.scales.foo.options).toEqual( + expect(chart.scales.x.type).toBe('logarithmic'); + expect(chart.scales.x.options).toBe(chart.options.scales.x); + expect(chart.scales.x.options).toEqual( jasmine.objectContaining({ _jasmineCheckA: 'a0', _jasmineCheckB: 'b1', _jasmineCheckC: 'c2', _jasmineCheckD: 'd2' })); - expect(chart.scales.bar.type).toBe('time'); - expect(chart.scales.bar.options).toBe(chart.options.scales.yAxes[0]); - expect(chart.scales.bar.options).toEqual( + expect(chart.scales.y.type).toBe('time'); + expect(chart.scales.y.options).toBe(chart.options.scales.y); + expect(chart.scales.y.options).toEqual( jasmine.objectContaining({ _jasmineCheckA: 'a0', _jasmineCheckB: 'b0', @@ -291,23 +287,21 @@ describe('Chart', function() { options: { _jasmineCheck: 42, scales: { - xAxes: [{ - id: 'foo', + x: { type: 'linear', _jasmineCheck: 42, - }], - yAxes: [{ - id: 'bar', + }, + y: { type: 'category', _jasmineCheck: 42, - }] + } } } }); expect(chart.options._jasmineCheck).toBeDefined(); - expect(chart.scales.foo.options._jasmineCheck).toBeDefined(); - expect(chart.scales.bar.options._jasmineCheck).toBeDefined(); + expect(chart.scales.x.options._jasmineCheck).toBeDefined(); + expect(chart.scales.y.options._jasmineCheck).toBeDefined(); expect(Chart.defaults.line._jasmineCheck).not.toBeDefined(); expect(Chart.defaults.global._jasmineCheck).not.toBeDefined(); @@ -989,15 +983,15 @@ describe('Chart', function() { chart.options = { responsive: false, scales: { - yAxes: [{ + y: { min: 0, max: 10 - }] + } } }; chart.update(); - var yScale = chart.scales['y-axis-0']; + var yScale = chart.scales.y; expect(yScale.options.min).toBe(0); expect(yScale.options.max).toBe(10); }); @@ -1016,11 +1010,11 @@ describe('Chart', function() { } }); - chart.options.scales.yAxes[0].min = 0; - chart.options.scales.yAxes[0].max = 10; + chart.options.scales.y.min = 0; + chart.options.scales.y.max = 10; chart.update(); - var yScale = chart.scales['y-axis-0']; + var yScale = chart.scales.y; expect(yScale.options.min).toBe(0); expect(yScale.options.max).toBe(10); }); @@ -1040,37 +1034,20 @@ describe('Chart', function() { }); var newScalesConfig = { - yAxes: [{ + y: { min: 0, max: 10 - }] + } }; chart.options.scales = newScalesConfig; chart.update(); - var yScale = chart.scales['y-axis-0']; + var yScale = chart.scales.y; expect(yScale.options.min).toBe(0); expect(yScale.options.max).toBe(10); }); - it ('should assign unique scale IDs', function() { - var chart = acquireChart({ - type: 'line', - options: { - scales: { - xAxes: [{id: 'x-axis-0'}, {}, {}], - yAxes: [{id: 'y-axis-1'}, {}, {}] - } - } - }); - - expect(Object.keys(chart.scales).sort()).toEqual([ - 'x-axis-0', 'x-axis-1', 'x-axis-2', - 'y-axis-1', 'y-axis-2', 'y-axis-3' - ]); - }); - it ('should remove discarded scale', function() { var chart = acquireChart({ type: 'line', @@ -1083,28 +1060,27 @@ describe('Chart', function() { options: { responsive: true, scales: { - yAxes: [{ - id: 'yAxis0', + y: { min: 0, max: 10 - }] + } } } }); var newScalesConfig = { - yAxes: [{ + y: { min: 0, max: 10 - }] + } }; chart.options.scales = newScalesConfig; chart.update(); var yScale = chart.scales.yAxis0; expect(yScale).toBeUndefined(); - var newyScale = chart.scales['y-axis-0']; + var newyScale = chart.scales.y; expect(newyScale.options.min).toBe(0); expect(newyScale.options.max).toBe(10); }); @@ -1181,15 +1157,16 @@ describe('Chart', function() { options: { responsive: true, scales: { - xAxes: [{ + x: { type: 'category' - }], - yAxes: [{ + }, + y: { + type: 'linear', scaleLabel: { display: true, labelString: 'Value' } - }] + } } } };
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/core.datasetController.tests.js
@@ -233,16 +233,22 @@ describe('Chart.DatasetController', function() { }, options: { scales: { - xAxes: [{ - id: 'firstXScaleID' - }, { - id: 'secondXScaleID' - }], - yAxes: [{ - id: 'firstYScaleID' - }, { - id: 'secondYScaleID' - }] + firstXScaleID: { + type: 'category', + position: 'bottom' + }, + secondXScaleID: { + type: 'category', + position: 'bottom' + }, + firstYScaleID: { + type: 'linear', + position: 'left' + }, + secondYScaleID: { + type: 'linear', + position: 'left' + }, } } });
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/core.layouts.tests.js
@@ -21,18 +21,6 @@ describe('Chart.layouts', function() { {data: [10, 5, 0, 25, 78, -10]} ], labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5', 'tick6'] - }, - options: { - scales: { - xAxes: [{ - id: 'xScale', - type: 'category' - }], - yAxes: [{ - id: 'yScale', - type: 'linear' - }] - } } }, { canvas: { @@ -47,18 +35,18 @@ describe('Chart.layouts', function() { expect(chart.chartArea.top).toBeCloseToPixel(32); // Is xScale at the right spot - expect(chart.scales.xScale.bottom).toBeCloseToPixel(150); - expect(chart.scales.xScale.left).toBeCloseToPixel(34); - expect(chart.scales.xScale.right).toBeCloseToPixel(247); - expect(chart.scales.xScale.top).toBeCloseToPixel(120); - expect(chart.scales.xScale.labelRotation).toBeCloseTo(0); + expect(chart.scales.x.bottom).toBeCloseToPixel(150); + expect(chart.scales.x.left).toBeCloseToPixel(34); + expect(chart.scales.x.right).toBeCloseToPixel(247); + expect(chart.scales.x.top).toBeCloseToPixel(120); + expect(chart.scales.x.labelRotation).toBeCloseTo(0); // Is yScale at the right spot - expect(chart.scales.yScale.bottom).toBeCloseToPixel(120); - expect(chart.scales.yScale.left).toBeCloseToPixel(0); - expect(chart.scales.yScale.right).toBeCloseToPixel(34); - expect(chart.scales.yScale.top).toBeCloseToPixel(32); - expect(chart.scales.yScale.labelRotation).toBeCloseTo(0); + expect(chart.scales.y.bottom).toBeCloseToPixel(120); + expect(chart.scales.y.left).toBeCloseToPixel(0); + expect(chart.scales.y.right).toBeCloseToPixel(34); + expect(chart.scales.y.top).toBeCloseToPixel(32); + expect(chart.scales.y.labelRotation).toBeCloseTo(0); }); it('should fit scales that are in the top and right positions', function() { @@ -72,16 +60,14 @@ describe('Chart.layouts', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale', + x: { type: 'category', position: 'top' - }], - yAxes: [{ - id: 'yScale', + }, + y: { type: 'linear', position: 'right' - }] + } } } }, { @@ -97,18 +83,18 @@ describe('Chart.layouts', function() { expect(chart.chartArea.top).toBeCloseToPixel(62); // Is xScale at the right spot - expect(chart.scales.xScale.bottom).toBeCloseToPixel(62); - expect(chart.scales.xScale.left).toBeCloseToPixel(3); - expect(chart.scales.xScale.right).toBeCloseToPixel(216); - expect(chart.scales.xScale.top).toBeCloseToPixel(32); - expect(chart.scales.xScale.labelRotation).toBeCloseTo(0); + expect(chart.scales.x.bottom).toBeCloseToPixel(62); + expect(chart.scales.x.left).toBeCloseToPixel(3); + expect(chart.scales.x.right).toBeCloseToPixel(216); + expect(chart.scales.x.top).toBeCloseToPixel(32); + expect(chart.scales.x.labelRotation).toBeCloseTo(0); // Is yScale at the right spot - expect(chart.scales.yScale.bottom).toBeCloseToPixel(142); - expect(chart.scales.yScale.left).toBeCloseToPixel(216); - expect(chart.scales.yScale.right).toBeCloseToPixel(250); - expect(chart.scales.yScale.top).toBeCloseToPixel(62); - expect(chart.scales.yScale.labelRotation).toBeCloseTo(0); + expect(chart.scales.y.bottom).toBeCloseToPixel(142); + expect(chart.scales.y.left).toBeCloseToPixel(216); + expect(chart.scales.y.right).toBeCloseToPixel(250); + expect(chart.scales.y.top).toBeCloseToPixel(62); + expect(chart.scales.y.labelRotation).toBeCloseTo(0); }); it('should fit scales with long labels correctly', function() { @@ -125,19 +111,17 @@ describe('Chart.layouts', function() { display: false }, scales: { - xAxes: [{ - id: 'xScale', + x: { type: 'category', ticks: { maxRotation: 0, autoSkip: false } - }], - yAxes: [{ - id: 'yScale', + }, + y: { type: 'linear', position: 'right' - }] + } } } }, { @@ -153,30 +137,30 @@ describe('Chart.layouts', function() { expect(chart.chartArea.top).toBeCloseToPixel(7); // Is xScale at the right spot - expect(chart.scales.xScale.bottom).toBeCloseToPixel(150); - expect(chart.scales.xScale.left).toBeCloseToPixel(60); - expect(chart.scales.xScale.right).toBeCloseToPixel(452); - expect(chart.scales.xScale.top).toBeCloseToPixel(120); - expect(chart.scales.xScale.labelRotation).toBeCloseTo(0); - - expect(chart.scales.xScale.height).toBeCloseToPixel(30); - expect(chart.scales.xScale.paddingLeft).toBeCloseToPixel(60); - expect(chart.scales.xScale.paddingTop).toBeCloseToPixel(0); - expect(chart.scales.xScale.paddingRight).toBeCloseToPixel(60); - expect(chart.scales.xScale.paddingBottom).toBeCloseToPixel(0); + expect(chart.scales.x.bottom).toBeCloseToPixel(150); + expect(chart.scales.x.left).toBeCloseToPixel(60); + expect(chart.scales.x.right).toBeCloseToPixel(452); + expect(chart.scales.x.top).toBeCloseToPixel(120); + expect(chart.scales.x.labelRotation).toBeCloseTo(0); + + expect(chart.scales.x.height).toBeCloseToPixel(30); + expect(chart.scales.x.paddingLeft).toBeCloseToPixel(60); + expect(chart.scales.x.paddingTop).toBeCloseToPixel(0); + expect(chart.scales.x.paddingRight).toBeCloseToPixel(60); + expect(chart.scales.x.paddingBottom).toBeCloseToPixel(0); // Is yScale at the right spot - expect(chart.scales.yScale.bottom).toBeCloseToPixel(120); - expect(chart.scales.yScale.left).toBeCloseToPixel(452); - expect(chart.scales.yScale.right).toBeCloseToPixel(486); - expect(chart.scales.yScale.top).toBeCloseToPixel(7); - expect(chart.scales.yScale.labelRotation).toBeCloseTo(0); - - expect(chart.scales.yScale.width).toBeCloseToPixel(34); - expect(chart.scales.yScale.paddingLeft).toBeCloseToPixel(0); - expect(chart.scales.yScale.paddingTop).toBeCloseToPixel(7); - expect(chart.scales.yScale.paddingRight).toBeCloseToPixel(0); - expect(chart.scales.yScale.paddingBottom).toBeCloseToPixel(7); + expect(chart.scales.y.bottom).toBeCloseToPixel(120); + expect(chart.scales.y.left).toBeCloseToPixel(452); + expect(chart.scales.y.right).toBeCloseToPixel(486); + expect(chart.scales.y.top).toBeCloseToPixel(7); + expect(chart.scales.y.labelRotation).toBeCloseTo(0); + + expect(chart.scales.y.width).toBeCloseToPixel(34); + expect(chart.scales.y.paddingLeft).toBeCloseToPixel(0); + expect(chart.scales.y.paddingTop).toBeCloseToPixel(7); + expect(chart.scales.y.paddingRight).toBeCloseToPixel(0); + expect(chart.scales.y.paddingBottom).toBeCloseToPixel(7); }); it('should fit scales that overlap the chart area', function() { @@ -197,40 +181,39 @@ describe('Chart.layouts', function() { expect(chart.chartArea.right).toBeCloseToPixel(512); expect(chart.chartArea.top).toBeCloseToPixel(32); - expect(chart.scale.bottom).toBeCloseToPixel(512); - expect(chart.scale.left).toBeCloseToPixel(0); - expect(chart.scale.right).toBeCloseToPixel(512); - expect(chart.scale.top).toBeCloseToPixel(32); - expect(chart.scale.width).toBeCloseToPixel(512); - expect(chart.scale.height).toBeCloseToPixel(480); + var scale = chart.scales.r; + expect(scale.bottom).toBeCloseToPixel(512); + expect(scale.left).toBeCloseToPixel(0); + expect(scale.right).toBeCloseToPixel(512); + expect(scale.top).toBeCloseToPixel(32); + expect(scale.width).toBeCloseToPixel(512); + expect(scale.height).toBeCloseToPixel(480); }); it('should fit multiple axes in the same position', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale1', + yAxisID: 'y', data: [10, 5, 0, 25, 78, -10] }, { - yAxisID: 'yScale2', + yAxisID: 'y2', data: [-19, -20, 0, -99, -50, 0] }], labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5', 'tick6'] }, options: { scales: { - xAxes: [{ - id: 'xScale', + x: { type: 'category' - }], - yAxes: [{ - id: 'yScale1', + }, + y: { type: 'linear' - }, { - id: 'yScale2', + }, + y2: { type: 'linear' - }] + } } } }, { @@ -246,54 +229,54 @@ describe('Chart.layouts', function() { expect(chart.chartArea.top).toBeCloseToPixel(32); // Is xScale at the right spot - expect(chart.scales.xScale.bottom).toBeCloseToPixel(150); - expect(chart.scales.xScale.left).toBeCloseToPixel(73); - expect(chart.scales.xScale.right).toBeCloseToPixel(247); - expect(chart.scales.xScale.top).toBeCloseToPixel(118); - expect(chart.scales.xScale.labelRotation).toBeCloseTo(40, -1); + expect(chart.scales.x.bottom).toBeCloseToPixel(150); + expect(chart.scales.x.left).toBeCloseToPixel(73); + expect(chart.scales.x.right).toBeCloseToPixel(247); + expect(chart.scales.x.top).toBeCloseToPixel(118); + expect(chart.scales.x.labelRotation).toBeCloseTo(40, -1); // Are yScales at the right spot - expect(chart.scales.yScale1.bottom).toBeCloseToPixel(118); - expect(chart.scales.yScale1.left).toBeCloseToPixel(41); - expect(chart.scales.yScale1.right).toBeCloseToPixel(73); - expect(chart.scales.yScale1.top).toBeCloseToPixel(32); - expect(chart.scales.yScale1.labelRotation).toBeCloseTo(0); - - expect(chart.scales.yScale2.bottom).toBeCloseToPixel(118); - expect(chart.scales.yScale2.left).toBeCloseToPixel(0); - expect(chart.scales.yScale2.right).toBeCloseToPixel(41); - expect(chart.scales.yScale2.top).toBeCloseToPixel(32); - expect(chart.scales.yScale2.labelRotation).toBeCloseTo(0); + expect(chart.scales.y.bottom).toBeCloseToPixel(118); + expect(chart.scales.y.left).toBeCloseToPixel(41); + expect(chart.scales.y.right).toBeCloseToPixel(73); + expect(chart.scales.y.top).toBeCloseToPixel(32); + expect(chart.scales.y.labelRotation).toBeCloseTo(0); + + expect(chart.scales.y2.bottom).toBeCloseToPixel(118); + expect(chart.scales.y2.left).toBeCloseToPixel(0); + expect(chart.scales.y2.right).toBeCloseToPixel(41); + expect(chart.scales.y2.top).toBeCloseToPixel(32); + expect(chart.scales.y2.labelRotation).toBeCloseTo(0); }); it ('should fit a full width box correctly', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - xAxisID: 'xScale1', + xAxisID: 'x', data: [10, 5, 0, 25, 78, -10] }, { - xAxisID: 'xScale2', + xAxisID: 'x2', data: [-19, -20, 0, -99, -50, 0] }], labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5', 'tick6'] }, options: { scales: { - xAxes: [{ - id: 'xScale1', - type: 'category' - }, { - id: 'xScale2', + x: { + type: 'category', + offset: false + }, + x2: { type: 'category', position: 'top', - fullWidth: true - }], - yAxes: [{ - id: 'yScale', + fullWidth: true, + offset: false + }, + y: { type: 'linear' - }] + } } } }); @@ -304,21 +287,21 @@ describe('Chart.layouts', function() { expect(chart.chartArea.top).toBeCloseToPixel(62); // Are xScales at the right spot - expect(chart.scales.xScale1.bottom).toBeCloseToPixel(512); - expect(chart.scales.xScale1.left).toBeCloseToPixel(40); - expect(chart.scales.xScale1.right).toBeCloseToPixel(496); - expect(chart.scales.xScale1.top).toBeCloseToPixel(484); + expect(chart.scales.x.bottom).toBeCloseToPixel(512); + expect(chart.scales.x.left).toBeCloseToPixel(40); + expect(chart.scales.x.right).toBeCloseToPixel(496); + expect(chart.scales.x.top).toBeCloseToPixel(484); - expect(chart.scales.xScale2.bottom).toBeCloseToPixel(62); - expect(chart.scales.xScale2.left).toBeCloseToPixel(0); - expect(chart.scales.xScale2.right).toBeCloseToPixel(512); - expect(chart.scales.xScale2.top).toBeCloseToPixel(32); + expect(chart.scales.x2.bottom).toBeCloseToPixel(62); + expect(chart.scales.x2.left).toBeCloseToPixel(0); + expect(chart.scales.x2.right).toBeCloseToPixel(512); + expect(chart.scales.x2.top).toBeCloseToPixel(32); // Is yScale at the right spot - expect(chart.scales.yScale.bottom).toBeCloseToPixel(484); - expect(chart.scales.yScale.left).toBeCloseToPixel(0); - expect(chart.scales.yScale.right).toBeCloseToPixel(40); - expect(chart.scales.yScale.top).toBeCloseToPixel(62); + expect(chart.scales.y.bottom).toBeCloseToPixel(484); + expect(chart.scales.y.left).toBeCloseToPixel(0); + expect(chart.scales.y.right).toBeCloseToPixel(40); + expect(chart.scales.y.top).toBeCloseToPixel(62); }); describe('padding settings', function() { @@ -335,16 +318,14 @@ describe('Chart.layouts', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale', + x: { type: 'category', display: false - }], - yAxes: [{ - id: 'yScale', + }, + y: { type: 'linear', display: false - }] + } }, legend: { display: false @@ -382,16 +363,14 @@ describe('Chart.layouts', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale', + x: { type: 'category', display: false - }], - yAxes: [{ - id: 'yScale', + }, + y: { type: 'linear', display: false - }] + } }, legend: { display: false @@ -434,16 +413,14 @@ describe('Chart.layouts', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale', + x: { type: 'category', display: false - }], - yAxes: [{ - id: 'yScale', + }, + y: { type: 'linear', display: false - }] + } }, legend: { display: false @@ -498,8 +475,8 @@ describe('Chart.layouts', function() { } }); - var xAxis = chart.scales['x-axis-0']; - var yAxis = chart.scales['y-axis-0']; + var xAxis = chart.scales.x; + var yAxis = chart.scales.y; var legend = chart.legend; var title = chart.titleBlock; @@ -520,60 +497,63 @@ describe('Chart.layouts', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', + position: 'bottom', display: true, weight: 1 - }, { - id: 'xScale1', + }, + x1: { type: 'category', + position: 'bottom', display: true, weight: 2 - }, { - id: 'xScale2', + }, + x2: { type: 'category', + position: 'bottom', display: true - }, { - id: 'xScale3', + }, + x3: { type: 'category', display: true, position: 'top', weight: 1 - }, { - id: 'xScale4', + }, + x4: { type: 'category', display: true, position: 'top', weight: 2 - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear', display: true, weight: 1 - }, { - id: 'yScale1', + }, + y1: { type: 'linear', + position: 'left', display: true, weight: 2 - }, { - id: 'yScale2', + }, + y2: { type: 'linear', + position: 'left', display: true - }, { - id: 'yScale3', + }, + y3: { type: 'linear', display: true, position: 'right', weight: 1 - }, { - id: 'yScale4', + }, + y4: { type: 'linear', display: true, position: 'right', weight: 2 - }] + } } } }, { @@ -583,17 +563,17 @@ describe('Chart.layouts', function() { } }); - var xScale0 = chart.scales.xScale0; - var xScale1 = chart.scales.xScale1; - var xScale2 = chart.scales.xScale2; - var xScale3 = chart.scales.xScale3; - var xScale4 = chart.scales.xScale4; + var xScale0 = chart.scales.x; + var xScale1 = chart.scales.x1; + var xScale2 = chart.scales.x2; + var xScale3 = chart.scales.x3; + var xScale4 = chart.scales.x4; - var yScale0 = chart.scales.yScale0; - var yScale1 = chart.scales.yScale1; - var yScale2 = chart.scales.yScale2; - var yScale3 = chart.scales.yScale3; - var yScale4 = chart.scales.yScale4; + var yScale0 = chart.scales.y; + var yScale1 = chart.scales.y1; + var yScale2 = chart.scales.y2; + var yScale3 = chart.scales.y3; + var yScale4 = chart.scales.y4; expect(xScale0.weight).toBe(1); expect(xScale1.weight).toBe(2); @@ -650,7 +630,7 @@ describe('Chart.layouts', function() { width: 256 } }); - var yAxis = chart.scales['y-axis-0']; + var yAxis = chart.scales.y; // issue #4441: y-axis labels partially hidden. // minimum horizontal space required to fit labels
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/core.scale.tests.js
@@ -28,18 +28,18 @@ describe('Core.scale', function() { data: data, options: { scales: { - xAxes: [{ + x: { ticks: { autoSkip: true } - }] + } } } }); } function lastTick(chart) { - var xAxis = chart.scales['x-axis-0']; + var xAxis = chart.scales.x; var ticks = xAxis.getTicks(); return ticks[ticks.length - 1]; } @@ -133,8 +133,7 @@ describe('Core.scale', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { gridLines: { offsetGridLines: test.offsetGridLines, drawTicks: false @@ -143,18 +142,18 @@ describe('Core.scale', function() { display: false }, offset: test.offset - }], - yAxes: [{ + }, + y: { display: false - }] + } }, legend: { display: false } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; xScale.ctx = window.createMockContext(); chart.draw(); @@ -178,12 +177,11 @@ describe('Core.scale', function() { }, options: { scales: { - xAxes: [{ + x: { display: false - }], - yAxes: [{ + }, + y: { type: 'category', - id: 'yScale0', gridLines: { offsetGridLines: test.offsetGridLines, drawTicks: false @@ -192,15 +190,15 @@ describe('Core.scale', function() { display: false }, offset: test.offset - }] + } }, legend: { display: false } } }); - var yScale = chart.scales.yScale0; + var yScale = chart.scales.y; yScale.ctx = window.createMockContext(); chart.draw(); @@ -226,12 +224,9 @@ describe('Core.scale', function() { }, options: { scales: { - xAxes: [{ - id: 'foo' - }], - yAxes: [{ + y: { display: false - }] + } }, legend: { display: false @@ -244,7 +239,7 @@ describe('Core.scale', function() { } }); - var scale = chart.scales.foo; + var scale = chart.scales.x; expect(scale.left).toBeGreaterThan(100); expect(scale.right).toBeGreaterThan(190); }); @@ -268,19 +263,17 @@ describe('Core.scale', function() { }, options: { scales: { - xAxes: [{ - id: 'foo', + x: { display: 'auto' - }], - yAxes: [{ + }, + y: { type: 'category', - id: 'yScale0' - }] + } } } }); - var scale = chart.scales.foo; + var scale = chart.scales.x; scale.ctx = window.createMockContext(); chart.draw(); @@ -301,15 +294,14 @@ describe('Core.scale', function() { }, options: { scales: { - xAxes: [{ - id: 'foo', + x: { display: 'auto' - }] + } } } }); - var scale = chart.scales.foo; + var scale = chart.scales.x; scale.ctx = window.createMockContext(); chart.draw(); @@ -336,15 +328,14 @@ describe('Core.scale', function() { }, options: { scales: { - yAxes: [{ - id: 'foo', + y: { display: 'auto' - }] + } } } }); - var scale = chart.scales.foo; + var scale = chart.scales.y; scale.ctx = window.createMockContext(); chart.draw(); @@ -365,15 +356,14 @@ describe('Core.scale', function() { }, options: { scales: { - yAxes: [{ - id: 'foo', + y: { display: 'auto' - }] + } } } }); - var scale = chart.scales.foo; + var scale = chart.scales.y; scale.ctx = window.createMockContext(); chart.draw(); @@ -390,14 +380,13 @@ describe('Core.scale', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'category', labels: labels, afterBuildTicks: function(scale) { scale.ticks = scale.ticks.slice(1); } - }] + } } } }); @@ -412,12 +401,11 @@ describe('Core.scale', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'category', labels: labels, afterBuildTicks: function() { } - }] + } } } }); @@ -432,14 +420,13 @@ describe('Core.scale', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'category', labels: labels, afterBuildTicks: function(scale) { scale.ticks = []; } - }] + } } } }); @@ -455,10 +442,9 @@ describe('Core.scale', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'linear', - }] + } } } }); @@ -480,16 +466,15 @@ describe('Core.scale', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'customScale', gridLines: { z: 10 }, ticks: { z: 20 } - }] + } } } }); @@ -504,16 +489,15 @@ describe('Core.scale', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'linear', ticks: { z: 10 }, gridLines: { z: 10 } - }] + } } } }); @@ -528,13 +512,12 @@ describe('Core.scale', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'linear', ticks: { z: 10 } - }] + } } } }); @@ -545,13 +528,12 @@ describe('Core.scale', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'linear', gridLines: { z: 11 } - }] + } } } }); @@ -562,16 +544,15 @@ describe('Core.scale', function() { type: 'line', options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'linear', ticks: { z: 10 }, gridLines: { z: 11 } - }] + } } } }); @@ -595,16 +576,16 @@ describe('Core.scale', function() { }, options: { scales: { - xAxes: [{ + x: { id: 'x', type: 'linear', min: -20, max: 20 - }], - yAxes: [{ + }, + y: { id: 'y', type: 'linear' - }] + } } } });
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/core.ticks.tests.js
@@ -25,29 +25,29 @@ describe('Test tick generators', function() { display: false, }, scales: { - xAxes: [{ + x: { type: 'linear', position: 'bottom', ticks: { callback: function(value) { return value.toString(); } } - }], - yAxes: [{ + }, + y: { type: 'linear', ticks: { callback: function(value) { return value.toString(); } } - }] + } } } }); - var xLabels = getLabels(chart.scales['x-axis-0']); - var yLabels = getLabels(chart.scales['y-axis-0']); + var xLabels = getLabels(chart.scales.x); + var yLabels = getLabels(chart.scales.y); expect(xLabels).toEqual(['0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1']); expect(yLabels).toEqual(['1', '0.9', '0.8', '0.7', '0.6', '0.5', '0.4', '0.3', '0.2', '0.1', '0']); @@ -66,7 +66,7 @@ describe('Test tick generators', function() { display: false, }, scales: { - xAxes: [{ + x: { type: 'logarithmic', position: 'bottom', min: 0.1, @@ -76,8 +76,8 @@ describe('Test tick generators', function() { return value.toString(); } } - }], - yAxes: [{ + }, + y: { type: 'logarithmic', min: 0.1, max: 1, @@ -86,13 +86,13 @@ describe('Test tick generators', function() { return value.toString(); } } - }] + } } } }); - var xLabels = getLabels(chart.scales['x-axis-0']); - var yLabels = getLabels(chart.scales['y-axis-0']); + var xLabels = getLabels(chart.scales.x); + var yLabels = getLabels(chart.scales.y); expect(xLabels).toEqual(['0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1']); expect(yLabels).toEqual(['1', '0.9', '0.8', '0.7', '0.6', '0.5', '0.4', '0.3', '0.2', '0.1']);
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/scale.category.tests.js
@@ -147,11 +147,10 @@ describe('Category scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'category', labels: labels - }] + } } } }); @@ -165,28 +164,26 @@ describe('Category scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [10, 5, 0, 25, 78] }], labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5'] }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); - var scale = chart.scales.xScale0; + var scale = chart.scales.x; expect(scale.getLabelForValue(1)).toBe('tick2'); }); @@ -196,28 +193,26 @@ describe('Category scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [10, 5, 0, 25, 78] }], labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick_last'] }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; expect(xScale.getPixelForValue(0)).toBeCloseToPixel(23 + 6); // plus lineHeight expect(xScale.getValueForPixel(23)).toBe(0); @@ -239,28 +234,26 @@ describe('Category scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [10, 5, 0, 25, 78] }], labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick_last'] }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; expect(xScale.getPixelForValue('tick1')).toBeCloseToPixel(23 + 6); // plus lineHeight }); @@ -269,30 +262,28 @@ describe('Category scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [10, 5, 0, 25, 78] }], labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick_last'] }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', position: 'bottom', min: 'tick2', max: 'tick4' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; expect(xScale.getPixelForValue(1)).toBeCloseToPixel(23 + 6); // plus lineHeight expect(xScale.getPixelForValue(3)).toBeCloseToPixel(496); @@ -308,30 +299,28 @@ describe('Category scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: ['3', '5', '1', '4', '2'] }], labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5'], yLabels: ['1', '2', '3', '4', '5'] }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', position: 'bottom', - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'category', position: 'left' - }] + } } } }); - var yScale = chart.scales.yScale0; + var yScale = chart.scales.y; expect(yScale.getPixelForValue(0)).toBeCloseToPixel(32); expect(yScale.getValueForPixel(257)).toBe(2); @@ -353,32 +342,30 @@ describe('Category scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: ['3', '5', '1', '4', '2'] }], labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5'], yLabels: ['1', '2', '3', '4', '5'] }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', position: 'bottom', - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'category', position: 'left', min: '2', max: '4' - }] + } } } }); - var yScale = chart.scales.yScale0; + var yScale = chart.scales.y; expect(yScale.getPixelForValue(1)).toBeCloseToPixel(32); expect(yScale.getPixelForValue(3)).toBeCloseToPixel(482); @@ -395,8 +382,8 @@ describe('Category scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [ {x: 0, y: 10}, {x: 1, y: 5}, @@ -409,20 +396,18 @@ describe('Category scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; expect(xScale.getPixelForValue(0)).toBeCloseToPixel(29); expect(xScale.getPixelForValue(3)).toBeCloseToPixel(506); expect(xScale.getPixelForValue(4)).toBeCloseToPixel(664); @@ -433,8 +418,8 @@ describe('Category scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [ {x: 0, y: 2}, {x: 1, y: 4}, @@ -448,21 +433,19 @@ describe('Category scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'category', position: 'left' - }] + } } } }); - var yScale = chart.scales.yScale0; + var yScale = chart.scales.y; expect(yScale.getPixelForValue(0)).toBeCloseToPixel(32); expect(yScale.getPixelForValue(4)).toBeCloseToPixel(481); }); @@ -472,8 +455,8 @@ describe('Category scale tests', function() { type: 'bar', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [ {x: 0, y: 10}, {x: 1, y: 5}, @@ -486,20 +469,18 @@ describe('Category scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'category', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; expect(xScale.getPixelForValue(0)).toBeCloseToPixel(89); expect(xScale.getPixelForValue(3)).toBeCloseToPixel(449); expect(xScale.getPixelForValue(4)).toBeCloseToPixel(569); @@ -510,8 +491,8 @@ describe('Category scale tests', function() { type: 'horizontalBar', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [ {x: 10, y: 0}, {x: 5, y: 1}, @@ -524,20 +505,18 @@ describe('Category scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'linear', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'category' - }] + } } } }); - var yScale = chart.scales.yScale0; + var yScale = chart.scales.y; expect(yScale.getPixelForValue(0)).toBeCloseToPixel(88); expect(yScale.getPixelForValue(3)).toBeCloseToPixel(426); expect(yScale.getPixelForValue(4)).toBeCloseToPixel(538);
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/scale.linear.tests.js
@@ -53,194 +53,191 @@ describe('Linear Scale', function() { type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 5, 0, -5, 78, -100] }, { - yAxisID: 'yScale1', + yAxisID: 'y2', data: [-1000, 1000], }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [150] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear' - }, { - id: 'yScale1', - type: 'linear' - }] + }, + y2: { + type: 'linear', + position: 'right', + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(-100); - expect(chart.scales.yScale0.max).toBe(150); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(-100); + expect(chart.scales.y.max).toBe(150); }); it('Should correctly determine the max & min of string data values', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: ['10', '5', '0', '-5', '78', '-100'] }, { - yAxisID: 'yScale1', + yAxisID: 'y2', data: ['-1000', '1000'], }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: ['150'] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear' - }, { - id: 'yScale1', - type: 'linear' - }] + }, + y2: { + type: 'linear', + position: 'right' + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(-100); - expect(chart.scales.yScale0.max).toBe(150); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(-100); + expect(chart.scales.y.max).toBe(150); }); it('Should correctly determine the max & min when no values provided and suggested minimum and maximum are set', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', suggestedMin: -10, suggestedMax: 15 - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(-10); - expect(chart.scales.yScale0.max).toBe(15); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(-10); + expect(chart.scales.y.max).toBe(15); }); it('Should correctly determine the max & min data values ignoring hidden datasets', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: ['10', '5', '0', '-5', '78', '-100'] }, { - yAxisID: 'yScale1', + yAxisID: 'y2', data: ['-1000', '1000'], }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: ['150'], hidden: true }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear' - }, { - id: 'yScale1', + }, + y2: { + position: 'right', type: 'linear' - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(-100); - expect(chart.scales.yScale0.max).toBe(80); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(-100); + expect(chart.scales.y.max).toBe(80); }); it('Should correctly determine the max & min data values ignoring data that is NaN', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [null, 90, NaN, undefined, 45, 30, Infinity, -Infinity] }], labels: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear' - }] + } } } }); - expect(chart.scales.yScale0.min).toBe(30); - expect(chart.scales.yScale0.max).toBe(90); + expect(chart.scales.y.min).toBe(30); + expect(chart.scales.y.max).toBe(90); // Scale is now stacked - chart.scales.yScale0.options.stacked = true; + chart.scales.y.options.stacked = true; chart.update(); - expect(chart.scales.yScale0.min).toBe(0); - expect(chart.scales.yScale0.max).toBe(90); + expect(chart.scales.y.min).toBe(0); + expect(chart.scales.y.max).toBe(90); }); it('Should correctly determine the max & min data values for small numbers', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [-1e-8, 3e-8, -4e-8, 6e-8] }], labels: ['a', 'b', 'c', 'd'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear' - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min * 1e8).toBeCloseTo(-4); - expect(chart.scales.yScale0.max * 1e8).toBeCloseTo(6); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min * 1e8).toBeCloseTo(-4); + expect(chart.scales.y.max * 1e8).toBeCloseTo(6); }); it('Should correctly determine the max & min for scatter data', function() { var chart = window.acquireChart({ type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [{ x: 10, y: 100 @@ -258,33 +255,31 @@ describe('Linear Scale', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'linear', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); chart.update(); - expect(chart.scales.xScale0.min).toBe(-20); - expect(chart.scales.xScale0.max).toBe(100); - expect(chart.scales.yScale0.min).toBe(0); - expect(chart.scales.yScale0.max).toBe(100); + expect(chart.scales.x.min).toBe(-20); + expect(chart.scales.x.max).toBe(100); + expect(chart.scales.y.min).toBe(0); + expect(chart.scales.y.max).toBe(100); }); it('Should correctly get the label for the given index', function() { var chart = window.acquireChart({ type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [{ x: 10, y: 100 @@ -302,109 +297,107 @@ describe('Linear Scale', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'linear', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); chart.update(); - expect(chart.scales.yScale0.getLabelForValue(7)).toBe(7); + expect(chart.scales.y.getLabelForValue(7)).toBe(7); }); it('Should correctly determine the min and max data values when stacked mode is turned on', function() { var chart = window.acquireChart({ type: 'line', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 5, 0, -5, 78, -100], type: 'bar' }, { - yAxisID: 'yScale1', + yAxisID: 'y2', data: [-1000, 1000], }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [150, 0, 0, -100, -10, 9], type: 'bar' }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 10, 10, 10, 10, 10], type: 'line' }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', stacked: true - }, { - id: 'yScale1', + }, + y2: { + position: 'right', type: 'linear' - }] + } } } }); chart.update(); - expect(chart.scales.yScale0.min).toBe(-150); - expect(chart.scales.yScale0.max).toBe(200); + expect(chart.scales.y.min).toBe(-150); + expect(chart.scales.y.max).toBe(200); }); it('Should correctly determine the min and max data values when stacked mode is turned on and there are hidden datasets', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 5, 0, -5, 78, -100], }, { - yAxisID: 'yScale1', + yAxisID: 'y2', data: [-1000, 1000], }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [150, 0, 0, -100, -10, 9], }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 20, 30, 40, 50, 60], hidden: true }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', stacked: true - }, { - id: 'yScale1', + }, + y2: { + position: 'right', type: 'linear' - }] + } } } }); chart.update(); - expect(chart.scales.yScale0.min).toBe(-150); - expect(chart.scales.yScale0.max).toBe(200); + expect(chart.scales.y.min).toBe(-150); + expect(chart.scales.y.max).toBe(200); }); it('Should correctly determine the min and max data values when stacked mode is turned on there are multiple types of datasets', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', type: 'bar', data: [10, 5, 0, -5, 78, -100] }, { @@ -418,18 +411,17 @@ describe('Linear Scale', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', stacked: true - }] + } } } }); - chart.scales.yScale0.determineDataLimits(); - expect(chart.scales.yScale0.min).toBe(-105); - expect(chart.scales.yScale0.max).toBe(160); + chart.scales.y.determineDataLimits(); + expect(chart.scales.y.min).toBe(-105); + expect(chart.scales.y.max).toBe(160); }); it('Should ensure that the scale has a max and min that are not equal', function() { @@ -441,17 +433,16 @@ describe('Linear Scale', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear' - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(0); - expect(chart.scales.yScale0.max).toBe(1); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(0); + expect(chart.scales.y.max).toBe(1); }); it('Should ensure that the scale has a max and min that are not equal when beginAtZero is set', function() { @@ -463,73 +454,70 @@ describe('Linear Scale', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', beginAtZero: true - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(0); - expect(chart.scales.yScale0.max).toBe(1); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(0); + expect(chart.scales.y.max).toBe(1); }); it('Should use the suggestedMin and suggestedMax options', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [1, 1, 1, 2, 1, 0] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', suggestedMax: 10, suggestedMin: -10 - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(-10); - expect(chart.scales.yScale0.max).toBe(10); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(-10); + expect(chart.scales.y.max).toBe(10); }); it('Should use the min and max options', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [1, 1, 1, 2, 1, 0] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', max: 1010, min: -1010 - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(-1010); - expect(chart.scales.yScale0.max).toBe(1010); - var labels = getLabels(chart.scales.yScale0); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(-1010); + expect(chart.scales.y.max).toBe(1010); + var labels = getLabels(chart.scales.y); expect(labels[0]).toBe('1010'); expect(labels[labels.length - 1]).toBe('-1010'); }); @@ -539,59 +527,57 @@ describe('Linear Scale', function() { type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 3, 6, 8, 3, 1] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', min: 1, max: 11, ticks: { stepSize: 2 } - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(1); - expect(chart.scales.yScale0.max).toBe(11); - expect(getLabels(chart.scales.yScale0)).toEqual(['11', '10', '8', '6', '4', '2', '1']); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(1); + expect(chart.scales.y.max).toBe(11); + expect(getLabels(chart.scales.y)).toEqual(['11', '10', '8', '6', '4', '2', '1']); }); it('Should create decimal steps if stepSize is a decimal number', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 3, 6, 8, 3, 1] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', ticks: { stepSize: 2.5 } - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(0); - expect(chart.scales.yScale0.max).toBe(10); - expect(getLabels(chart.scales.yScale0)).toEqual(['10', '7.5', '5', '2.5', '0']); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(0); + expect(chart.scales.y.max).toBe(10); + expect(getLabels(chart.scales.y)).toEqual(['10', '7.5', '5', '2.5', '0']); }); describe('precision', function() { @@ -600,57 +586,55 @@ describe('Linear Scale', function() { type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [0, 1, 2, 1, 0, 1] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', ticks: { precision: 0 } - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(0); - expect(chart.scales.yScale0.max).toBe(2); - expect(getLabels(chart.scales.yScale0)).toEqual(['2', '1', '0']); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(0); + expect(chart.scales.y.max).toBe(2); + expect(getLabels(chart.scales.y)).toEqual(['2', '1', '0']); }); it('Should round the step size to the given number of decimal places', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [0, 0.001, 0.002, 0.003, 0, 0.001] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', ticks: { precision: 2 } - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(0); - expect(chart.scales.yScale0.max).toBe(0.01); - expect(getLabels(chart.scales.yScale0)).toEqual(['0.01', '0']); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(0); + expect(chart.scales.y.max).toBe(0.01); + expect(getLabels(chart.scales.y)).toEqual(['0.01', '0']); }); }); @@ -660,83 +644,80 @@ describe('Linear Scale', function() { type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [20, 30, 40, 50] }], labels: ['a', 'b', 'c', 'd'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(getLabels(chart.scales.yScale0)).toEqual(['50', '45', '40', '35', '30', '25', '20']); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(getLabels(chart.scales.y)).toEqual(['50', '45', '40', '35', '30', '25', '20']); - chart.scales.yScale0.options.beginAtZero = true; + chart.scales.y.options.beginAtZero = true; chart.update(); - expect(getLabels(chart.scales.yScale0)).toEqual(['50', '45', '40', '35', '30', '25', '20', '15', '10', '5', '0']); + expect(getLabels(chart.scales.y)).toEqual(['50', '45', '40', '35', '30', '25', '20', '15', '10', '5', '0']); chart.data.datasets[0].data = [-20, -30, -40, -50]; chart.update(); - expect(getLabels(chart.scales.yScale0)).toEqual(['0', '-5', '-10', '-15', '-20', '-25', '-30', '-35', '-40', '-45', '-50']); + expect(getLabels(chart.scales.y)).toEqual(['0', '-5', '-10', '-15', '-20', '-25', '-30', '-35', '-40', '-45', '-50']); - chart.scales.yScale0.options.beginAtZero = false; + chart.scales.y.options.beginAtZero = false; chart.update(); - expect(getLabels(chart.scales.yScale0)).toEqual(['-20', '-25', '-30', '-35', '-40', '-45', '-50']); + expect(getLabels(chart.scales.y)).toEqual(['-20', '-25', '-30', '-35', '-40', '-45', '-50']); }); it('Should generate tick marks in the correct order in reversed mode', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 5, 0, 25, 78] }], labels: ['a', 'b', 'c', 'd'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', reverse: true - }] + } } } }); - expect(getLabels(chart.scales.yScale0)).toEqual(['0', '10', '20', '30', '40', '50', '60', '70', '80']); - expect(chart.scales.yScale0.start).toBe(80); - expect(chart.scales.yScale0.end).toBe(0); + expect(getLabels(chart.scales.y)).toEqual(['0', '10', '20', '30', '40', '50', '60', '70', '80']); + expect(chart.scales.y.start).toBe(80); + expect(chart.scales.y.end).toBe(0); }); it('should use the correct number of decimal places in the default format function', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [0.06, 0.005, 0, 0.025, 0.0078] }], labels: ['a', 'b', 'c', 'd'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', - }] + } } } }); - expect(getLabels(chart.scales.yScale0)).toEqual(['0.06', '0.05', '0.04', '0.03', '0.02', '0.01', '0']); + expect(getLabels(chart.scales.y)).toEqual(['0.06', '0.05', '0.04', '0.03', '0.02', '0.01', '0']); }); it('Should correctly limit the maximum number of ticks', function() { @@ -750,69 +731,66 @@ describe('Linear Scale', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale' - }] + y: {} } } }); - expect(getLabels(chart.scales.yScale)).toEqual(['2.5', '2.0', '1.5', '1.0', '0.5']); + expect(getLabels(chart.scales.y)).toEqual(['2.5', '2.0', '1.5', '1.0', '0.5']); - chart.options.scales.yAxes[0].ticks.maxTicksLimit = 11; + chart.options.scales.y.ticks.maxTicksLimit = 11; chart.update(); - expect(getLabels(chart.scales.yScale)).toEqual(['2.5', '2.0', '1.5', '1.0', '0.5']); + expect(getLabels(chart.scales.y)).toEqual(['2.5', '2.0', '1.5', '1.0', '0.5']); - chart.options.scales.yAxes[0].ticks.maxTicksLimit = 21; + chart.options.scales.y.ticks.maxTicksLimit = 21; chart.update(); - expect(getLabels(chart.scales.yScale)).toEqual([ + expect(getLabels(chart.scales.y)).toEqual([ '2.5', '2.4', '2.3', '2.2', '2.1', '2.0', '1.9', '1.8', '1.7', '1.6', '1.5', '1.4', '1.3', '1.2', '1.1', '1.0', '0.9', '0.8', '0.7', '0.6', '0.5' ]); - chart.options.scales.yAxes[0].ticks.maxTicksLimit = 11; - chart.options.scales.yAxes[0].ticks.stepSize = 0.01; + chart.options.scales.y.ticks.maxTicksLimit = 11; + chart.options.scales.y.ticks.stepSize = 0.01; chart.update(); - expect(getLabels(chart.scales.yScale)).toEqual(['2.5', '2.0', '1.5', '1.0', '0.5']); + expect(getLabels(chart.scales.y)).toEqual(['2.5', '2.0', '1.5', '1.0', '0.5']); - chart.options.scales.yAxes[0].min = 0.3; - chart.options.scales.yAxes[0].max = 2.8; + chart.options.scales.y.min = 0.3; + chart.options.scales.y.max = 2.8; chart.update(); - expect(getLabels(chart.scales.yScale)).toEqual(['2.8', '2.5', '2.0', '1.5', '1.0', '0.5', '0.3']); + expect(getLabels(chart.scales.y)).toEqual(['2.8', '2.5', '2.0', '1.5', '1.0', '0.5', '0.3']); }); it('Should build labels using the user supplied callback', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 5, 0, 25, 78] }], labels: ['a', 'b', 'c', 'd'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', ticks: { callback: function(value, index) { return index.toString(); } } - }] + } } } }); // Just the index - expect(getLabels(chart.scales.yScale0)).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8']); + expect(getLabels(chart.scales.y)).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8']); }); it('Should get the correct pixel value for a point', function() { @@ -821,27 +799,25 @@ describe('Linear Scale', function() { data: { labels: [-1, 1], datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [-1, 1] }], }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'linear', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; expect(xScale.getPixelForValue(1)).toBeCloseToPixel(501); // right - paddingRight expect(xScale.getPixelForValue(-1)).toBeCloseToPixel(31 + 6); // left + paddingLeft + lineSpace expect(xScale.getPixelForValue(0)).toBeCloseToPixel(266 + 6 / 2); // halfway*/ @@ -850,7 +826,7 @@ describe('Linear Scale', function() { expect(xScale.getValueForPixel(31)).toBeCloseTo(-1, 1e-2); expect(xScale.getValueForPixel(266)).toBeCloseTo(0, 1e-2); - var yScale = chart.scales.yScale0; + var yScale = chart.scales.y; expect(yScale.getPixelForValue(1)).toBeCloseToPixel(32); // right - paddingRight expect(yScale.getPixelForValue(-1)).toBeCloseToPixel(484); // left + paddingLeft expect(yScale.getPixelForValue(0)).toBeCloseToPixel(258); // halfway*/ @@ -865,8 +841,8 @@ describe('Linear Scale', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [{ x: 10, y: 100 @@ -884,21 +860,19 @@ describe('Linear Scale', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'linear', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear' - }] + } } } }); - var xScale = chart.scales.xScale0; - var yScale = chart.scales.yScale0; + var xScale = chart.scales.x; + var yScale = chart.scales.y; expect(xScale.paddingTop).toBeCloseToPixel(0); expect(xScale.paddingBottom).toBeCloseToPixel(0); expect(xScale.paddingLeft).toBeCloseToPixel(12); @@ -938,8 +912,8 @@ describe('Linear Scale', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', - yAxisID: 'yScale0', + xAxisID: 'x', + yAxisID: 'y', data: [{ x: 10, y: 100 @@ -957,13 +931,11 @@ describe('Linear Scale', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'linear', position: 'bottom' - }], - yAxes: [{ - id: 'yScale0', + }, + y: { type: 'linear', gridLines: { drawTicks: false, @@ -977,12 +949,12 @@ describe('Linear Scale', function() { display: false, padding: 0 } - }] + } } } }); - var yScale = chart.scales.yScale0; + var yScale = chart.scales.y; expect(yScale.width).toBeCloseToPixel(0); }); @@ -1009,12 +981,12 @@ describe('Linear Scale', function() { data: barData, options: { scales: { - xAxes: [{ + x: { stacked: true - }], - yAxes: [{ + }, + y: { stacked: true - }] + } } } }); @@ -1025,8 +997,8 @@ describe('Linear Scale', function() { chart.update(); }); - expect(chart.scales['x-axis-0'].min).toEqual(0); - expect(chart.scales['x-axis-0'].max).toEqual(1); + expect(chart.scales.x.min).toEqual(0); + expect(chart.scales.x.max).toEqual(1); }); it('max and min value should be valid when min is set and all datasets are hidden', function() { @@ -1045,15 +1017,15 @@ describe('Linear Scale', function() { data: barData, options: { scales: { - xAxes: [{ + x: { min: 20 - }] + } } } }); - expect(chart.scales['x-axis-0'].min).toEqual(20); - expect(chart.scales['x-axis-0'].max).toEqual(21); + expect(chart.scales.x.min).toEqual(20); + expect(chart.scales.x.max).toEqual(21); }); it('min settings should be used if set to zero', function() { @@ -1071,15 +1043,15 @@ describe('Linear Scale', function() { data: barData, options: { scales: { - xAxes: [{ + x: { min: 0, max: 3000 - }] + } } } }); - expect(chart.scales['x-axis-0'].min).toEqual(0); + expect(chart.scales.x.min).toEqual(0); }); it('max settings should be used if set to zero', function() { @@ -1097,15 +1069,15 @@ describe('Linear Scale', function() { data: barData, options: { scales: { - xAxes: [{ + x: { min: -3000, max: 0 - }] + } } } }); - expect(chart.scales['x-axis-0'].max).toEqual(0); + expect(chart.scales.x.max).toEqual(0); }); it('Should generate max and min that are not equal when data contains values that are very close to each other', function() { @@ -1121,16 +1093,15 @@ describe('Linear Scale', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'linear', - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.max).toBeGreaterThan(chart.scales.yScale0.min); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.max).toBeGreaterThan(chart.scales.y.min); }); it('Should get correct pixel values when horizontal', function() { @@ -1143,10 +1114,9 @@ describe('Linear Scale', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'linear', - }] + } } } }); @@ -1184,10 +1154,9 @@ describe('Linear Scale', function() { }, options: { scales: { - yAxes: [{ - id: 'y', + y: { type: 'linear', - }] + } } } });
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/scale.logarithmic.tests.js
@@ -54,212 +54,218 @@ describe('Logarithmic Scale tests', function() { type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [42, 1000, 64, 100], }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: [10, 5, 5000, 78, 450] }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: [150] }, { - yAxisID: 'yScale2', + yAxisID: 'y2', data: [20, 0, 150, 1800, 3040] }, { - yAxisID: 'yScale3', + yAxisID: 'y3', data: [67, 0.0004, 0, 820, 0.001] }], labels: ['a', 'b', 'c', 'd', 'e'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { + id: 'y', type: 'logarithmic' - }, { - id: 'yScale1', - type: 'logarithmic' - }, { - id: 'yScale2', - type: 'logarithmic' - }, { - id: 'yScale3', + }, + y1: { + type: 'logarithmic', + position: 'right' + }, + y2: { + type: 'logarithmic', + position: 'right' + }, + y3: { + position: 'right', type: 'logarithmic' - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(10); - expect(chart.scales.yScale0.max).toBe(1000); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(10); + expect(chart.scales.y.max).toBe(1000); - expect(chart.scales.yScale1).not.toEqual(undefined); // must construct - expect(chart.scales.yScale1.min).toBe(1); - expect(chart.scales.yScale1.max).toBe(5000); + expect(chart.scales.y1).not.toEqual(undefined); // must construct + expect(chart.scales.y1.min).toBe(1); + expect(chart.scales.y1.max).toBe(5000); - expect(chart.scales.yScale2).not.toEqual(undefined); // must construct - expect(chart.scales.yScale2.min).toBe(0); - expect(chart.scales.yScale2.max).toBe(4000); + expect(chart.scales.y2).not.toEqual(undefined); // must construct + expect(chart.scales.y2.min).toBe(0); + expect(chart.scales.y2.max).toBe(4000); - expect(chart.scales.yScale3).not.toEqual(undefined); // must construct - expect(chart.scales.yScale3.min).toBe(0); - expect(chart.scales.yScale3.max).toBe(900); + expect(chart.scales.y3).not.toEqual(undefined); // must construct + expect(chart.scales.y3.min).toBe(0); + expect(chart.scales.y3.max).toBe(900); }); it('should correctly determine the max & min of string data values', function() { var chart = window.acquireChart({ type: 'line', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: ['42', '1000', '64', '100'], }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: ['10', '5', '5000', '78', '450'] }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: ['150'] }, { - yAxisID: 'yScale2', + yAxisID: 'y2', data: ['20', '0', '150', '1800', '3040'] }, { - yAxisID: 'yScale3', + yAxisID: 'y3', data: ['67', '0.0004', '0', '820', '0.001'] }], labels: ['a', 'b', 'c', 'd', 'e'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'logarithmic' - }, { - id: 'yScale1', + }, + y1: { + position: 'right', type: 'logarithmic' - }, { - id: 'yScale2', + }, + y2: { + position: 'right', type: 'logarithmic' - }, { - id: 'yScale3', + }, + y3: { + position: 'right', type: 'logarithmic' - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(10); - expect(chart.scales.yScale0.max).toBe(1000); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(10); + expect(chart.scales.y.max).toBe(1000); - expect(chart.scales.yScale1).not.toEqual(undefined); // must construct - expect(chart.scales.yScale1.min).toBe(1); - expect(chart.scales.yScale1.max).toBe(5000); + expect(chart.scales.y1).not.toEqual(undefined); // must construct + expect(chart.scales.y1.min).toBe(1); + expect(chart.scales.y1.max).toBe(5000); - expect(chart.scales.yScale2).not.toEqual(undefined); // must construct - expect(chart.scales.yScale2.min).toBe(0); - expect(chart.scales.yScale2.max).toBe(4000); + expect(chart.scales.y2).not.toEqual(undefined); // must construct + expect(chart.scales.y2.min).toBe(0); + expect(chart.scales.y2.max).toBe(4000); - expect(chart.scales.yScale3).not.toEqual(undefined); // must construct - expect(chart.scales.yScale3.min).toBe(0); - expect(chart.scales.yScale3.max).toBe(900); + expect(chart.scales.y3).not.toEqual(undefined); // must construct + expect(chart.scales.y3.min).toBe(0); + expect(chart.scales.y3.max).toBe(900); }); it('should correctly determine the max & min data values when there are hidden datasets', function() { var chart = window.acquireChart({ type: 'line', data: { datasets: [{ - yAxisID: 'yScale1', + yAxisID: 'y1', data: [10, 5, 5000, 78, 450] }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [42, 1000, 64, 100], }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: [50000], hidden: true }, { - yAxisID: 'yScale2', + yAxisID: 'y2', data: [20, 0, 7400, 14, 291] }, { - yAxisID: 'yScale2', + yAxisID: 'y2', data: [6, 0.0007, 9, 890, 60000], hidden: true }], labels: ['a', 'b', 'c', 'd', 'e'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'logarithmic' - }, { - id: 'yScale1', + }, + y1: { + position: 'right', type: 'logarithmic' - }, { - id: 'yScale2', + }, + y2: { + position: 'right', type: 'logarithmic' - }] + } } } }); - expect(chart.scales.yScale1).not.toEqual(undefined); // must construct - expect(chart.scales.yScale1.min).toBe(1); - expect(chart.scales.yScale1.max).toBe(5000); + expect(chart.scales.y1).not.toEqual(undefined); // must construct + expect(chart.scales.y1.min).toBe(1); + expect(chart.scales.y1.max).toBe(5000); - expect(chart.scales.yScale2).not.toEqual(undefined); // must construct - expect(chart.scales.yScale2.min).toBe(0); - expect(chart.scales.yScale2.max).toBe(8000); + expect(chart.scales.y2).not.toEqual(undefined); // must construct + expect(chart.scales.y2.min).toBe(0); + expect(chart.scales.y2.max).toBe(8000); }); it('should correctly determine the max & min data values when there is NaN data', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [undefined, 10, null, 5, 5000, NaN, 78, 450] }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [undefined, 28, null, 1000, 500, NaN, 50, 42, Infinity, -Infinity] }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: [undefined, 30, null, 9400, 0, NaN, 54, 836] }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: [undefined, 0, null, 800, 9, NaN, 894, 21] }], labels: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'logarithmic' - }, { - id: 'yScale1', + }, + y1: { + position: 'right', type: 'logarithmic' - }] + } } } }); - expect(chart.scales.yScale0).not.toEqual(undefined); // must construct - expect(chart.scales.yScale0.min).toBe(1); - expect(chart.scales.yScale0.max).toBe(5000); + expect(chart.scales.y).not.toEqual(undefined); // must construct + expect(chart.scales.y.min).toBe(1); + expect(chart.scales.y.max).toBe(5000); // Turn on stacked mode since it uses it's own - chart.options.scales.yAxes[0].stacked = true; + chart.options.scales.y.stacked = true; chart.update(); - expect(chart.scales.yScale0.min).toBe(10); - expect(chart.scales.yScale0.max).toBe(6000); + expect(chart.scales.y.min).toBe(10); + expect(chart.scales.y.max).toBe(6000); - expect(chart.scales.yScale1).not.toEqual(undefined); // must construct - expect(chart.scales.yScale1.min).toBe(0); - expect(chart.scales.yScale1.max).toBe(10000); + expect(chart.scales.y1).not.toEqual(undefined); // must construct + expect(chart.scales.y1.min).toBe(0); + expect(chart.scales.y1.max).toBe(10000); }); it('should correctly determine the max & min for scatter data', function() { @@ -277,24 +283,22 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale', + x: { type: 'logarithmic', position: 'bottom' - }], - yAxes: [{ - id: 'yScale', + }, + y: { type: 'logarithmic' - }] + } } } }); - expect(chart.scales.xScale.min).toBe(1); - expect(chart.scales.xScale.max).toBe(100); + expect(chart.scales.x.min).toBe(1); + expect(chart.scales.x.max).toBe(100); - expect(chart.scales.yScale.min).toBe(1); - expect(chart.scales.yScale.max).toBe(200); + expect(chart.scales.y.min).toBe(1); + expect(chart.scales.y.max).toBe(200); }); it('should correctly determine the max & min for scatter data when 0 values are present', function() { @@ -312,24 +316,22 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale', + x: { type: 'logarithmic', position: 'bottom' - }], - yAxes: [{ - id: 'yScale', + }, + y: { type: 'logarithmic' - }] + } } } }); - expect(chart.scales.xScale.min).toBe(0); - expect(chart.scales.xScale.max).toBe(300); + expect(chart.scales.x.min).toBe(0); + expect(chart.scales.x.max).toBe(300); - expect(chart.scales.yScale.min).toBe(0); - expect(chart.scales.yScale.max).toBe(1000); + expect(chart.scales.y.min).toBe(0); + expect(chart.scales.y.max).toBe(1000); }); it('should correctly determine the min and max data values when stacked mode is turned on', function() { @@ -338,58 +340,58 @@ describe('Logarithmic Scale tests', function() { data: { datasets: [{ type: 'bar', - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 5, 1, 5, 78, 100] }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: [0, 1000], }, { type: 'bar', - yAxisID: 'yScale0', + yAxisID: 'y', data: [150, 10, 10, 100, 10, 9] }, { type: 'line', - yAxisID: 'yScale0', + yAxisID: 'y', data: [100, 100, 100, 100, 100, 100] }], labels: ['a', 'b', 'c', 'd', 'e', 'f'] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'logarithmic', stacked: true - }, { - id: 'yScale1', + }, + y1: { + position: 'right', type: 'logarithmic' - }] + } } } }); - expect(chart.scales.yScale0.min).toBe(10); - expect(chart.scales.yScale0.max).toBe(200); + expect(chart.scales.y.min).toBe(10); + expect(chart.scales.y.max).toBe(200); }); it('should correctly determine the min and max data values when stacked mode is turned on ignoring hidden datasets', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 5, 1, 5, 78, 100], type: 'bar' }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: [0, 1000], type: 'bar' }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [150, 10, 10, 100, 10, 9], type: 'bar' }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [10000, 10000, 10000, 10000, 10000, 10000], hidden: true, type: 'bar' @@ -398,20 +400,20 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'logarithmic', stacked: true - }, { - id: 'yScale1', + }, + y1: { + position: 'right', type: 'logarithmic' - }] + } } } }); - expect(chart.scales.yScale0.min).toBe(10); - expect(chart.scales.yScale0.max).toBe(200); + expect(chart.scales.y.min).toBe(10); + expect(chart.scales.y.max).toBe(200); }); it('should ensure that the scale has a max and min that are not equal', function() { @@ -425,22 +427,21 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic' - }] + } } } }); - expect(chart.scales.yScale.min).toBe(1); - expect(chart.scales.yScale.max).toBe(10); + expect(chart.scales.y.min).toBe(1); + expect(chart.scales.y.max).toBe(10); chart.data.datasets[0].data = [0.15, 0.15]; chart.update(); - expect(chart.scales.yScale.min).toBe(0.01); - expect(chart.scales.yScale.max).toBe(1); + expect(chart.scales.y.min).toBe(0.01); + expect(chart.scales.y.max).toBe(1); }); it('should use the min and max options', function() { @@ -454,8 +455,7 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic', min: 10, max: 1010, @@ -464,12 +464,12 @@ describe('Logarithmic Scale tests', function() { return value; } } - }] + } } } }); - var yScale = chart.scales.yScale; + var yScale = chart.scales.y; var tickCount = yScale.ticks.length; expect(yScale.min).toBe(10); expect(yScale.max).toBe(1010); @@ -488,8 +488,7 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic', min: -10, max: -1010, @@ -498,14 +497,14 @@ describe('Logarithmic Scale tests', function() { return value; } } - }] + } } } }); - var yScale = chart.scales.yScale; - expect(yScale.min).toBe(0); - expect(yScale.max).toBe(2); + var y = chart.scales.y; + expect(y.min).toBe(0); + expect(y.max).toBe(2); }); it('should ignore invalid min and max options', function() { @@ -519,8 +518,7 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic', min: 'zero', max: null, @@ -529,14 +527,14 @@ describe('Logarithmic Scale tests', function() { return value; } } - }] + } } } }); - var yScale = chart.scales.yScale; - expect(yScale.min).toBe(0); - expect(yScale.max).toBe(2); + var y = chart.scales.y; + expect(y.min).toBe(0); + expect(y.max).toBe(2); }); it('should generate tick marks', function() { @@ -550,21 +548,20 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic', ticks: { callback: function(value) { return value; } } - }] + } } } }); // Counts down because the lines are drawn top to bottom - var scale = chart.scales.yScale; + var scale = chart.scales.y; expect(getLabels(scale)).toEqual([80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); expect(scale.start).toEqual(1); expect(scale.end).toEqual(80); @@ -581,20 +578,19 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic', ticks: { callback: function(value) { return value; } } - }] + } } } }); - var scale = chart.scales.yScale; + var scale = chart.scales.y; // Counts down because the lines are drawn top to bottom expect(getLabels(scale)).toEqual([30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0.9, 0.8, 0]); expect(scale.start).toEqual(0); @@ -613,21 +609,20 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic', reverse: true, ticks: { callback: function(value) { return value; } } - }] + } } } }); - var scale = chart.scales.yScale; + var scale = chart.scales.y; expect(getLabels(scale)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80]); expect(scale.start).toEqual(80); expect(scale.end).toEqual(1); @@ -644,21 +639,20 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic', reverse: true, ticks: { callback: function(value) { return value; } } - }] + } } } }); - var scale = chart.scales.yScale; + var scale = chart.scales.y; expect(getLabels(scale)).toEqual([0, 9, 10, 20, 30]); expect(scale.start).toEqual(30); expect(scale.end).toEqual(0); @@ -675,15 +669,14 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic' - }] + } } } }); - expect(getLabels(chart.scales.yScale)).toEqual(['8e+1', '', '', '5e+1', '', '', '2e+1', '1e+1', '', '', '', '', '5e+0', '', '', '2e+0', '1e+0', '0']); + expect(getLabels(chart.scales.y)).toEqual(['8e+1', '', '', '5e+1', '', '', '2e+1', '1e+1', '', '', '', '', '5e+0', '', '', '2e+0', '1e+0', '0']); }); it('should build labels using the user supplied callback', function() { @@ -697,53 +690,52 @@ describe('Logarithmic Scale tests', function() { }, options: { scales: { - yAxes: [{ - id: 'yScale', + y: { type: 'logarithmic', ticks: { callback: function(value, index) { return index.toString(); } } - }] + } } } }); // Just the index - expect(getLabels(chart.scales.yScale)).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16']); + expect(getLabels(chart.scales.y)).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16']); }); it('should correctly get the correct label for a data item', function() { var chart = window.acquireChart({ type: 'bar', data: { datasets: [{ - yAxisID: 'yScale0', + yAxisID: 'y', data: [10, 5, 5000, 78, 450] }, { - yAxisID: 'yScale1', + yAxisID: 'y1', data: [1, 1000, 10, 100], }, { - yAxisID: 'yScale0', + yAxisID: 'y', data: [150] }], labels: [] }, options: { scales: { - yAxes: [{ - id: 'yScale0', + y: { type: 'logarithmic' - }, { - id: 'yScale1', + }, + y1: { + position: 'right', type: 'logarithmic' - }] + } } } }); - expect(chart.scales.yScale0.getLabelForValue(150)).toBe(150); + expect(chart.scales.y.getLabelForValue(150)).toBe(150); }); describe('when', function() { @@ -780,9 +772,9 @@ describe('Logarithmic Scale tests', function() { { axis: 'y', scale: { - yAxes: [{ + y: { min: 0 - }] + } }, firstTick: 0, describe: 'all stacks are defined and min: 0' @@ -791,9 +783,9 @@ describe('Logarithmic Scale tests', function() { axis: 'y', data: dataWithEmptyStacks, scale: { - yAxes: [{ + y: { min: 0 - }] + } }, firstTick: 0, describe: 'not stacks are defined and min: 0' @@ -812,9 +804,9 @@ describe('Logarithmic Scale tests', function() { { axis: 'x', scale: { - xAxes: [{ + x: { min: 0 - }] + } }, firstTick: 0, describe: 'all stacks are defined and min: 0' @@ -823,9 +815,9 @@ describe('Logarithmic Scale tests', function() { axis: 'x', data: dataWithEmptyStacks, scale: { - xAxes: [{ + x: { min: 0 - }] + } }, firstTick: 0, describe: 'not all stacks are defined and min: 0' @@ -844,11 +836,11 @@ describe('Logarithmic Scale tests', function() { chartStart = 'bottom'; chartEnd = 'top'; } - scaleConfig[setup.axis + 'Axes'] = [{ + scaleConfig[setup.axis] = { type: 'logarithmic' - }]; + }; Chart.helpers.extend(scaleConfig, setup.scale); - scaleConfig[setup.axis + 'Axes'][0].type = 'logarithmic'; + scaleConfig[setup.axis].type = 'logarithmic'; var description = 'dataset has stack option and ' + setup.describe + ' and axis is "' + setup.axis + '";'; @@ -865,7 +857,7 @@ describe('Logarithmic Scale tests', function() { } }); - var axisID = setup.axis + '-axis-0'; + var axisID = setup.axis; var scale = chart.scales[axisID]; var firstTick = setup.firstTick; var lastTick = 80; // last tick (should be first available tick after: 2 * 39) @@ -979,35 +971,37 @@ describe('Logarithmic Scale tests', function() { var expectation = 'min = ' + setup.firstTick + ', max = ' + setup.lastTick; describe(setup.describe + ' and axis is "' + axis.id + '"; expect: ' + expectation + ';', function() { beforeEach(function() { - var xScaleConfig = { + var xConfig = { type: 'logarithmic', + position: 'bottom' }; - var yScaleConfig = { + var yConfig = { type: 'logarithmic', + position: 'left' }; var data = setup.data || { datasets: [{ data: setup.dataset }], }; - Chart.helpers.extend(xScaleConfig, setup.scale); - Chart.helpers.extend(yScaleConfig, setup.scale); + Chart.helpers.extend(xConfig, setup.scale); + Chart.helpers.extend(yConfig, setup.scale); Chart.helpers.extend(data, setup.data || {}); this.chart = window.acquireChart({ type: 'line', data: data, options: { scales: { - xAxes: [xScaleConfig], - yAxes: [yScaleConfig] + x: xConfig, + y: yConfig } } }); }); it('should get the correct pixel value for a point', function() { var chart = this.chart; - var axisID = axis.id + '-axis-0'; + var axisID = axis.id; var scale = chart.scales[axisID]; var firstTick = setup.firstTick; var lastTick = setup.lastTick; @@ -1106,35 +1100,37 @@ describe('Logarithmic Scale tests', function() { var expectation = 'min = 0, max = ' + setup.lastTick + ', first tick = ' + setup.firstTick; describe(setup.describe + ' and axis is "' + axis.id + '"; expect: ' + expectation + ';', function() { beforeEach(function() { - var xScaleConfig = { + var xConfig = { type: 'logarithmic', + position: 'bottom' }; - var yScaleConfig = { + var yConfig = { type: 'logarithmic', + position: 'left' }; var data = setup.data || { datasets: [{ data: setup.dataset }], }; - Chart.helpers.extend(xScaleConfig, setup.scale); - Chart.helpers.extend(yScaleConfig, setup.scale); + Chart.helpers.extend(xConfig, setup.scale); + Chart.helpers.extend(yConfig, setup.scale); Chart.helpers.extend(data, setup.data || {}); this.chart = window.acquireChart({ type: 'line', data: data, options: { scales: { - xAxes: [xScaleConfig], - yAxes: [yScaleConfig] + x: xConfig, + y: yConfig } } }); }); it('should get the correct pixel value for a point', function() { var chart = this.chart; - var axisID = axis.id + '-axis-0'; + var axisID = axis.id; var scale = chart.scales[axisID]; var firstTick = setup.firstTick; var lastTick = setup.lastTick;
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/scale.radialLinear.tests.js
@@ -87,8 +87,8 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.min).toBe(-100); - expect(chart.scale.max).toBe(150); + expect(chart.scales.r.min).toBe(-100); + expect(chart.scales.r.max).toBe(150); }); it('Should correctly determine the max & min of string data values', function() { @@ -107,8 +107,8 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.min).toBe(-100); - expect(chart.scale.max).toBe(150); + expect(chart.scales.r.min).toBe(-100); + expect(chart.scales.r.max).toBe(150); }); it('Should correctly determine the max & min data values when there are hidden datasets', function() { @@ -130,8 +130,8 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.min).toBe(-100); - expect(chart.scale.max).toBe(150); + expect(chart.scales.r.min).toBe(-100); + expect(chart.scales.r.max).toBe(150); }); it('Should correctly determine the max & min data values when there is NaN data', function() { @@ -148,8 +148,8 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.min).toBe(50); - expect(chart.scale.max).toBe(70); + expect(chart.scales.r.min).toBe(50); + expect(chart.scales.r.max).toBe(70); }); it('Should ensure that the scale has a max and min that are not equal', function() { @@ -160,13 +160,13 @@ describe('Test the radial linear scale', function() { labels: [] }, options: { - scale: { - id: 'myScale' + scales: { + rScale: {} } } }); - var scale = chart.scales.myScale; + var scale = chart.scales.rScale; expect(scale.min).toBe(-1); expect(scale.max).toBe(1); @@ -189,8 +189,8 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.min).toBe(-10); - expect(chart.scale.max).toBe(10); + expect(chart.scales.r.min).toBe(-10); + expect(chart.scales.r.max).toBe(10); }); it('Should use the min and max options', function() { @@ -210,9 +210,9 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.min).toBe(-1010); - expect(chart.scale.max).toBe(1010); - expect(getLabels(chart.scale)).toEqual(['-1010', '-1000', '-500', '0', '500', '1000', '1010']); + expect(chart.scales.r.min).toBe(-1010); + expect(chart.scales.r.max).toBe(1010); + expect(getLabels(chart.scales.r)).toEqual(['-1010', '-1000', '-500', '0', '500', '1000', '1010']); }); it('should forcibly include 0 in the range if the beginAtZero option is used', function() { @@ -231,22 +231,22 @@ describe('Test the radial linear scale', function() { } }); - expect(getLabels(chart.scale)).toEqual(['20', '25', '30', '35', '40', '45', '50']); + expect(getLabels(chart.scales.r)).toEqual(['20', '25', '30', '35', '40', '45', '50']); - chart.scale.options.beginAtZero = true; + chart.scales.r.options.beginAtZero = true; chart.update(); - expect(getLabels(chart.scale)).toEqual(['0', '5', '10', '15', '20', '25', '30', '35', '40', '45', '50']); + expect(getLabels(chart.scales.r)).toEqual(['0', '5', '10', '15', '20', '25', '30', '35', '40', '45', '50']); chart.data.datasets[0].data = [-20, -30, -40, -50]; chart.update(); - expect(getLabels(chart.scale)).toEqual(['-50', '-45', '-40', '-35', '-30', '-25', '-20', '-15', '-10', '-5', '0']); + expect(getLabels(chart.scales.r)).toEqual(['-50', '-45', '-40', '-35', '-30', '-25', '-20', '-15', '-10', '-5', '0']); - chart.scale.options.beginAtZero = false; + chart.scales.r.options.beginAtZero = false; chart.update(); - expect(getLabels(chart.scale)).toEqual(['-50', '-45', '-40', '-35', '-30', '-25', '-20']); + expect(getLabels(chart.scales.r)).toEqual(['-50', '-45', '-40', '-35', '-30', '-25', '-20']); }); it('Should generate tick marks in the correct order in reversed mode', function() { @@ -265,9 +265,9 @@ describe('Test the radial linear scale', function() { } }); - expect(getLabels(chart.scale)).toEqual(['80', '70', '60', '50', '40', '30', '20', '10', '0']); - expect(chart.scale.start).toBe(80); - expect(chart.scale.end).toBe(0); + expect(getLabels(chart.scales.r)).toEqual(['80', '70', '60', '50', '40', '30', '20', '10', '0']); + expect(chart.scales.r.start).toBe(80); + expect(chart.scales.r.end).toBe(0); }); it('Should correctly limit the maximum number of ticks', function() { @@ -288,23 +288,23 @@ describe('Test the radial linear scale', function() { } }); - expect(getLabels(chart.scale)).toEqual(['0.5', '1.0', '1.5', '2.0', '2.5']); + expect(getLabels(chart.scales.r)).toEqual(['0.5', '1.0', '1.5', '2.0', '2.5']); - chart.options.scale.ticks.maxTicksLimit = 11; + chart.options.scales.r.ticks.maxTicksLimit = 11; chart.update(); - expect(getLabels(chart.scale)).toEqual(['0.5', '1.0', '1.5', '2.0', '2.5']); + expect(getLabels(chart.scales.r)).toEqual(['0.5', '1.0', '1.5', '2.0', '2.5']); - chart.options.scale.ticks.stepSize = 0.01; + chart.options.scales.r.ticks.stepSize = 0.01; chart.update(); - expect(getLabels(chart.scale)).toEqual(['0.5', '1.0', '1.5', '2.0', '2.5']); + expect(getLabels(chart.scales.r)).toEqual(['0.5', '1.0', '1.5', '2.0', '2.5']); - chart.options.scale.min = 0.3; - chart.options.scale.max = 2.8; + chart.options.scales.r.min = 0.3; + chart.options.scales.r.max = 2.8; chart.update(); - expect(getLabels(chart.scale)).toEqual(['0.3', '0.5', '1.0', '1.5', '2.0', '2.5', '2.8']); + expect(getLabels(chart.scales.r)).toEqual(['0.3', '0.5', '1.0', '1.5', '2.0', '2.5', '2.8']); }); it('Should build labels using the user supplied callback', function() { @@ -327,8 +327,8 @@ describe('Test the radial linear scale', function() { } }); - expect(getLabels(chart.scale)).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8']); - expect(chart.scale.pointLabels).toEqual(['label1', 'label2', 'label3', 'label4', 'label5']); + expect(getLabels(chart.scales.r)).toEqual(['0', '1', '2', '3', '4', '5', '6', '7', '8']); + expect(chart.scales.r.pointLabels).toEqual(['label1', 'label2', 'label3', 'label4', 'label5']); }); it('Should build point labels using the user supplied callback', function() { @@ -351,7 +351,7 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.pointLabels).toEqual(['0', '1', '2', '3', '4']); + expect(chart.scales.r.pointLabels).toEqual(['0', '1', '2', '3', '4']); }); it('Should build point labels from falsy values', function() { @@ -365,7 +365,7 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.pointLabels).toEqual([0, '', '', '', '', '']); + expect(chart.scales.r.pointLabels).toEqual([0, '', '', '', '', '']); }); it('should correctly set the center point', function() { @@ -388,9 +388,9 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.drawingArea).toBe(227); - expect(chart.scale.xCenter).toBe(256); - expect(chart.scale.yCenter).toBe(284); + expect(chart.scales.r.drawingArea).toBe(227); + expect(chart.scales.r.xCenter).toBe(256); + expect(chart.scales.r.yCenter).toBe(284); }); it('should correctly get the label for a given data index', function() { @@ -412,7 +412,7 @@ describe('Test the radial linear scale', function() { } } }); - expect(chart.scale.getLabelForValue(5)).toBe(5); + expect(chart.scales.r.getLabelForValue(5)).toBe(5); }); it('should get the correct distance from the center point', function() { @@ -435,18 +435,18 @@ describe('Test the radial linear scale', function() { } }); - expect(chart.scale.getDistanceFromCenterForValue(chart.scale.min)).toBe(0); - expect(chart.scale.getDistanceFromCenterForValue(chart.scale.max)).toBe(227); + expect(chart.scales.r.getDistanceFromCenterForValue(chart.scales.r.min)).toBe(0); + expect(chart.scales.r.getDistanceFromCenterForValue(chart.scales.r.max)).toBe(227); - var position = chart.scale.getPointPositionForValue(1, 5); + var position = chart.scales.r.getPointPositionForValue(1, 5); expect(position.x).toBeCloseToPixel(270); expect(position.y).toBeCloseToPixel(278); - chart.scale.options.reverse = true; + chart.scales.r.options.reverse = true; chart.update(); - expect(chart.scale.getDistanceFromCenterForValue(chart.scale.min)).toBe(227); - expect(chart.scale.getDistanceFromCenterForValue(chart.scale.max)).toBe(0); + expect(chart.scales.r.getDistanceFromCenterForValue(chart.scales.r.min)).toBe(227); + expect(chart.scales.r.getDistanceFromCenterForValue(chart.scales.r.max)).toBe(0); }); it('should correctly get angles for all points', function() { @@ -477,14 +477,14 @@ describe('Test the radial linear scale', function() { var slice = 72; // (360 / 5) for (var i = 0; i < 5; i++) { - expect(radToNearestDegree(chart.scale.getIndexAngle(i))).toBe(15 + (slice * i)); + expect(radToNearestDegree(chart.scales.r.getIndexAngle(i))).toBe(15 + (slice * i)); } chart.options.startAngle = 0; chart.update(); for (var x = 0; x < 5; x++) { - expect(radToNearestDegree(chart.scale.getIndexAngle(x))).toBe((slice * x)); + expect(radToNearestDegree(chart.scales.r.getIndexAngle(x))).toBe((slice * x)); } }); @@ -511,7 +511,7 @@ describe('Test the radial linear scale', function() { } }); - var scale = chart.scale; + var scale = chart.scales.r; [{ startAngle: 30,
true
Other
chartjs
Chart.js
ce74eb76a1ad29c0ccaeb8cf3e606d82e38f2ac7.json
Convert axis options from arrays to objects (#6773) * Convert axis options from arrays to objects * Updated all chart type defaults * Throw errors when axis type or position are not specified * Avoid raising unnecessary errors when merging options into the default configs * Fix additional tests * Ensure scale defaults are set if type is not explicitly defined * Another step * Include `scale` as `firstIDs.r` * update docs * Update for buildOrUpdateScales * Update migration guide * Add test back
test/specs/scale.time.tests.js
@@ -13,13 +13,13 @@ describe('Time scale tests', function() { data: data, options: { scales: { - xAxes: [options] + x: options } } }, {canvas: {width: width, height: height}}); - return chart.scales.xScale0; + return chart.scales.x; } function getLabels(scale) { @@ -145,7 +145,7 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: [{ x: newDateFromRef(0), y: 1 @@ -172,16 +172,15 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', position: 'bottom' - }], + }, } } }, {canvas: {width: 800, height: 200}}); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; var ticks = getLabels(xScale); // `bounds === 'data'`: first and last ticks removed since outside the data range @@ -193,7 +192,7 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'tScale0', + xAxisID: 'x', data: [{ t: newDateFromRef(0), y: 1 @@ -220,16 +219,15 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'tScale0', + x: { type: 'time', position: 'bottom' - }], + }, } } }, {canvas: {width: 800, height: 200}}); - var tScale = chart.scales.tScale0; + var tScale = chart.scales.x; var ticks = getLabels(tScale); // `bounds === 'data'`: first and last ticks removed since outside the data range @@ -243,14 +241,13 @@ describe('Time scale tests', function() { data: { labels: ['foo', 'bar'], datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: [0, 1] }], }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', position: 'bottom', time: { @@ -265,13 +262,13 @@ describe('Time scale tests', function() { ticks: { source: 'labels' } - }], + }, } } }); // Counts down because the lines are drawn top to bottom - var labels = getLabels(chart.scales.xScale0); + var labels = getLabels(chart.scales.x); // Counts down because the lines are drawn top to bottom expect(labels[0]).toBe('Jan 2'); @@ -322,25 +319,24 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: data }], }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', ticks: { source: 'data', autoSkip: true } - }], + }, } } }); - var scale = chart.scales.xScale0; + var scale = chart.scales.x; expect(scale._unit).toEqual('month'); }); @@ -517,7 +513,7 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: [] }], labels: [ @@ -532,16 +528,15 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', - position: 'bottom', - }], + position: 'bottom' + }, } } }); - this.scale = this.chart.scales.xScale0; + this.scale = this.chart.scales.x; }); it('should be bounded by the nearest week beginnings', function() { @@ -585,17 +580,16 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', bounds: 'ticks', position: 'bottom' - }], + }, } } }, {canvas: {width: 800, height: 200}}); - this.scale = this.chart.scales.xScale0; + this.scale = this.chart.scales.x; }); it('should be bounded by nearest step\'s year start and end', function() { @@ -641,27 +635,26 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: [null, 10, 3] }], labels: ['2015-01-01T20:00:00', '2015-01-02T21:00:00', '2015-01-03T22:00:00', '2015-01-05T23:00:00', '2015-01-07T03:00', '2015-01-08T10:00', '2015-01-10T12:00'], // days }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', position: 'bottom', ticks: { source: 'labels', autoSkip: false } - }], + } } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; var controller = chart.getDatasetMeta(0).controller; expect(xScale.getLabelForValue(controller._getParsed(0)[xScale.id])).toBeTruthy(); expect(xScale.getLabelForValue(controller._getParsed(0)[xScale.id])).toBe('Jan 1, 2015, 8:00:00 pm'); @@ -674,15 +667,14 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: [0, 0] }], labels: ['2015-01-01T20:00:00', '2015-01-01T20:01:00'] }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', time: { displayFormats: { @@ -694,11 +686,11 @@ describe('Time scale tests', function() { return '<' + value + '>'; } } - }] + } } } }); - this.scale = this.chart.scales.xScale0; + this.scale = this.chart.scales.x; }); it('should get the correct labels for ticks', function() { @@ -711,7 +703,7 @@ describe('Time scale tests', function() { it('should update ticks.callback correctly', function() { var chart = this.chart; - chart.options.scales.xAxes[0].ticks.callback = function(value) { + chart.options.scales.x.ticks.callback = function(value) { return '{' + value + '}'; }; chart.update(); @@ -729,15 +721,14 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: [0, 0] }], labels: ['2015-01-01T20:00:00', '2015-01-01T20:01:00'] }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', ticks: { callback: function(value) { @@ -755,11 +746,11 @@ describe('Time scale tests', function() { } } } - }] + } } } }); - this.scale = this.chart.scales.xScale0; + this.scale = this.chart.scales.x; }); it('should get the correct labels for major and minor ticks', function() { @@ -773,7 +764,7 @@ describe('Time scale tests', function() { it('should only use ticks.minor callback if ticks.major.enabled is false', function() { var chart = this.chart; - chart.options.scales.xAxes[0].ticks.major.enabled = false; + chart.options.scales.x.ticks.major.enabled = false; chart.update(); var labels = getLabels(this.scale); @@ -784,7 +775,7 @@ describe('Time scale tests', function() { it('should use ticks.callback if ticks.major.callback is omitted', function() { var chart = this.chart; - chart.options.scales.xAxes[0].ticks.major.callback = undefined; + chart.options.scales.x.ticks.major.callback = undefined; chart.update(); var labels = getLabels(this.scale); @@ -795,7 +786,7 @@ describe('Time scale tests', function() { it('should use ticks.callback if ticks.minor.callback is omitted', function() { var chart = this.chart; - chart.options.scales.xAxes[0].ticks.minor.callback = undefined; + chart.options.scales.x.ticks.minor.callback = undefined; chart.update(); var labels = getLabels(this.scale); @@ -811,22 +802,21 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: [{t: '2015-01-01T20:00:00', y: 10}, {t: '2015-01-02T21:00:00', y: 3}] }], }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', position: 'bottom' - }], + }, } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; var controller = chart.getDatasetMeta(0).controller; var value = controller._getParsed(0)[xScale.id]; expect(xScale.getLabelForValue(value)).toBeTruthy(); @@ -838,7 +828,7 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: [ {t: +new Date('2018-01-08 05:14:23.234'), y: 10}, {t: +new Date('2018-01-09 06:17:43.426'), y: 3} @@ -847,16 +837,15 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', position: 'bottom' - }], + }, } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; var controller = chart.getDatasetMeta(0).controller; var label = xScale.getLabelForValue(controller._getParsed(0)[xScale.id]); expect(label).toEqual('Jan 8, 2018, 5:14:23 am'); @@ -868,22 +857,21 @@ describe('Time scale tests', function() { data: { labels: ['2016-05-27'], datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: [5] }] }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { display: true, type: 'time' - }] + } } } }); - var xScale = chart.scales.xScale0; + var xScale = chart.scales.x; var pixel = xScale.getPixelForValue(moment('2016-05-27').valueOf()); expect(xScale.getValueForPixel(pixel)).toEqual(moment(chart.data.labels[0]).valueOf()); @@ -899,13 +887,13 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ + x: { type: 'time', ticks: { min: moment().subtract(1, 'months'), max: moment(), } - }], + }, }, responsive: true, }, @@ -914,8 +902,8 @@ describe('Time scale tests', function() { style: 'display: none', }, }); - expect(chart.scales['y-axis-0'].width).toEqual(0); - expect(chart.scales['y-axis-0'].maxWidth).toEqual(0); + expect(chart.scales.y.width).toEqual(0); + expect(chart.scales.y.maxWidth).toEqual(0); expect(chart.width).toEqual(0); }); @@ -930,16 +918,15 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', time: { parser: 'YYYY' }, ticks: { source: 'labels' } - }] + } } } }); @@ -956,7 +943,7 @@ describe('Time scale tests', function() { it ('should not add ticks for min and max if they extend the labels range', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; options.max = '2051'; @@ -970,7 +957,7 @@ describe('Time scale tests', function() { it ('should not duplicate ticks if min and max are the labels limits', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2017'; options.max = '2042'; @@ -995,7 +982,7 @@ describe('Time scale tests', function() { it ('should correctly handle empty `data.labels` using `time.unit`', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.time.unit = 'year'; chart.data.labels = []; @@ -1024,16 +1011,15 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', time: { parser: 'YYYY' }, ticks: { source: 'data' } - }] + } } } }); @@ -1050,7 +1036,7 @@ describe('Time scale tests', function() { it ('should not add ticks for min and max if they extend the labels range', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; options.max = '2051'; @@ -1064,7 +1050,7 @@ describe('Time scale tests', function() { it ('should not duplicate ticks if min and max are the labels limits', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2017'; options.max = '2043'; @@ -1090,7 +1076,7 @@ describe('Time scale tests', function() { it ('should correctly handle empty `data.labels` and hidden datasets using `time.unit`', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.time.unit = 'year'; chart.data.labels = []; @@ -1116,8 +1102,7 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', time: { parser: 'YYYY' @@ -1126,10 +1111,10 @@ describe('Time scale tests', function() { ticks: { source: 'labels' } - }], - yAxes: [{ + }, + y: { display: false - }] + } } } }); @@ -1149,7 +1134,7 @@ describe('Time scale tests', function() { it ('should add a step before if scale.min is before the first data', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; chart.update(); @@ -1163,7 +1148,7 @@ describe('Time scale tests', function() { it ('should add a step after if scale.max is after the last data', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.max = '2050'; chart.update(); @@ -1177,7 +1162,7 @@ describe('Time scale tests', function() { it ('should add steps before and after if scale.min/max are outside the data range', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; options.max = '2050'; @@ -1200,8 +1185,7 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', time: { parser: 'YYYY' @@ -1210,10 +1194,10 @@ describe('Time scale tests', function() { ticks: { source: 'labels' } - }], - yAxes: [{ + }, + y: { display: false - }] + } } } }); @@ -1233,7 +1217,7 @@ describe('Time scale tests', function() { it ('should take in account scale min and max if outside the ticks range', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; options.max = '2050'; @@ -1262,18 +1246,17 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', bounds: 'data', time: { parser: 'MM/DD HH:mm', unit: 'day' } - }], - yAxes: [{ + }, + y: { display: false - }] + } } } }); @@ -1299,18 +1282,17 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', bounds: 'ticks', time: { parser: 'MM/DD HH:mm', unit: 'day' } - }], - yAxes: [{ + }, + y: { display: false - }] + } } } }); @@ -1341,8 +1323,7 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', bounds: bounds, time: { @@ -1352,10 +1333,10 @@ describe('Time scale tests', function() { ticks: { source: source } - }], - yAxes: [{ + }, + y: { display: false - }] + } } } }); @@ -1364,7 +1345,7 @@ describe('Time scale tests', function() { it ('should expand scale to the min/max range', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; var min = '02/19 07:00'; var max = '02/24 08:00'; var minMillis = +moment(min, 'MM/DD HH:mm'); @@ -1386,7 +1367,7 @@ describe('Time scale tests', function() { it ('should shrink scale to the min/max range', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; var min = '02/21 07:00'; var max = '02/22 20:00'; var minMillis = +moment(min, 'MM/DD HH:mm'); @@ -1422,8 +1403,7 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', time: { parser: 'YYYY' @@ -1432,7 +1412,7 @@ describe('Time scale tests', function() { source: source }, distribution: distribution - }] + } } } }); @@ -1448,7 +1428,7 @@ describe('Time scale tests', function() { it ('should add offset from the edges if offset is true', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.offset = true; chart.update(); @@ -1464,7 +1444,7 @@ describe('Time scale tests', function() { it ('should not add offset if min and max extend the labels range', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; options.max = '2051'; @@ -1489,7 +1469,7 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ + x: { id: 'x', type: 'time', time: { @@ -1499,7 +1479,7 @@ describe('Time scale tests', function() { source: source }, distribution: distribution - }] + } } } }); @@ -1508,7 +1488,7 @@ describe('Time scale tests', function() { it ('should add offset if min and max extend the labels range and offset is true', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; options.max = '2051'; @@ -1536,8 +1516,7 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', reverse: true, time: { @@ -1546,10 +1525,10 @@ describe('Time scale tests', function() { ticks: { source: 'labels', } - }], - yAxes: [{ + }, + y: { display: false - }] + } } } }); @@ -1576,7 +1555,7 @@ describe('Time scale tests', function() { it ('should reverse the bars and add offsets if offset is true', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.offset = true; chart.update(); @@ -1592,7 +1571,7 @@ describe('Time scale tests', function() { it ('should reverse the values for pixels if offset is true', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.offset = true; chart.update(); @@ -1624,8 +1603,7 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', time: { parser: 'YYYY' @@ -1635,10 +1613,10 @@ describe('Time scale tests', function() { ticks: { source: 'labels' } - }], - yAxes: [{ + }, + y: { display: false - }] + } } } }); @@ -1659,7 +1637,7 @@ describe('Time scale tests', function() { it ('should reverse the labels and should add a step before if scale.min is before the first data', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; chart.update(); @@ -1674,7 +1652,7 @@ describe('Time scale tests', function() { it ('should reverse the labels and should add a step after if scale.max is after the last data', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.max = '2050'; chart.update(); @@ -1689,7 +1667,7 @@ describe('Time scale tests', function() { it ('should reverse the labels and should add steps before and after if scale.min/max are outside the data range', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; options.max = '2050'; @@ -1712,8 +1690,7 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', time: { parser: 'YYYY' @@ -1723,10 +1700,10 @@ describe('Time scale tests', function() { ticks: { source: 'labels' } - }], - yAxes: [{ + }, + y: { display: false - }] + } } } }); @@ -1747,7 +1724,7 @@ describe('Time scale tests', function() { it ('should reverse the labels and should take in account scale min and max if outside the ticks range', function() { var chart = this.chart; var scale = chart.scales.x; - var options = chart.options.scales.xAxes[0]; + var options = chart.options.scales.x; options.min = '2012'; options.max = '2050'; @@ -1783,28 +1760,26 @@ describe('Time scale tests', function() { }, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', labels: ['2015', '2016', '2017'], time: timeOpts }, - { - id: 'x2', + x2: { type: 'time', + position: 'bottom', time: timeOpts - }], - yAxes: [{ - id: 'y', + }, + y: { type: 'time', time: timeOpts }, - { - id: 'y2', + y2: { + position: 'left', type: 'time', labels: ['2005', '2006', '2007'], time: timeOpts - }] + } } } }); @@ -1828,14 +1803,13 @@ describe('Time scale tests', function() { type: 'line', data: { datasets: [{ - xAxisID: 'xScale0', + xAxisID: 'x', data: data }], }, options: { scales: { - xAxes: [{ - id: 'xScale0', + x: { type: 'time', ticks: { major: { @@ -1844,12 +1818,12 @@ describe('Time scale tests', function() { source: 'data', autoSkip: true } - }], + }, } } }); - var scale = chart.scales.xScale0; + var scale = chart.scales.x; var labels = scale.ticks.map(function(t) { return t.label; @@ -1870,10 +1844,9 @@ describe('Time scale tests', function() { data: {}, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time' - }] + } } } }); @@ -1893,7 +1866,7 @@ describe('Time scale tests', function() { }; expect(chart.scales.x.options.time.displayFormats).toEqual(expected); - expect(chart.options.scales.xAxes[0].time.displayFormats).toEqual(expected); + expect(chart.options.scales.x.time.displayFormats).toEqual(expected); }); it('should merge user formats with adapter presets', function() { @@ -1902,8 +1875,7 @@ describe('Time scale tests', function() { data: {}, options: { scales: { - xAxes: [{ - id: 'x', + x: { type: 'time', time: { displayFormats: { @@ -1912,7 +1884,7 @@ describe('Time scale tests', function() { month: 'bla' } } - }] + } } } }); @@ -1932,7 +1904,7 @@ describe('Time scale tests', function() { }; expect(chart.scales.x.options.time.displayFormats).toEqual(expected); - expect(chart.options.scales.xAxes[0].time.displayFormats).toEqual(expected); + expect(chart.options.scales.x.time.displayFormats).toEqual(expected); }); }); });
true
Other
chartjs
Chart.js
34b93751db94dc775ce00458db5a3cb1dfc5a84a.json
Change updateElement to updateElements (#6722)
docs/getting-started/v3-migration.md
@@ -101,6 +101,7 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released * `Chart.Animation.animationObject` was renamed to `Chart.Animation` * `Chart.Animation.chartInstance` was renamed to `Chart.Animation.chart` * `DatasetController.createMetaData` and `DatasetController.createMetaDataset` were replaced with `DatasetController.createElement` +* `DatasetController.updateElement` was renamed to `DatasetController.updateElements` * `TimeScale.getLabelCapacity` was renamed to `TimeScale._getLabelCapacity` * `TimeScale.tickFormatFunction` was renamed to `TimeScale._tickFormatFunction` * `TimeScale.getPixelForOffset` was renamed to `TimeScale._getPixelForOffset`
true
Other
chartjs
Chart.js
34b93751db94dc775ce00458db5a3cb1dfc5a84a.json
Change updateElement to updateElements (#6722)
src/controllers/controller.bar.js
@@ -271,58 +271,49 @@ module.exports = DatasetController.extend({ }, update: function(reset) { - var me = this; - var rects = me._cachedMeta.data; - var i, ilen; - - me._ruler = me.getRuler(); + const me = this; + const rects = me._cachedMeta.data; - for (i = 0, ilen = rects.length; i < ilen; ++i) { - me.updateElement(rects[i], i, reset); - } + me.updateElements(rects, 0, rects.length, reset); }, - updateElement: function(rectangle, index, reset) { - var me = this; - var options = me._resolveDataElementOptions(index); + updateElements: function(rectangles, start, count, reset) { + const me = this; + const vscale = me._cachedMeta.vScale; + const base = vscale.getBasePixel(); + const horizontal = vscale.isHorizontal(); + const ruler = me.getRuler(); + let i; + + for (i = 0; i < start + count; i++) { + const rectangle = rectangles[i]; + const options = me._resolveDataElementOptions(i); + const vpixels = me.calculateBarValuePixels(i, options); + const ipixels = me.calculateBarIndexPixels(i, ruler, options); + + rectangle._model = { + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderSkipped: options.borderSkipped, + borderWidth: options.borderWidth + }; + + const model = rectangle._model; + + // all borders are drawn for floating bar + if (me._getParsed(i)._custom) { + model.borderSkipped = null; + } - rectangle._model = { - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderSkipped: options.borderSkipped, - borderWidth: options.borderWidth - }; + model.horizontal = horizontal; + model.base = reset ? base : vpixels.base; + model.x = horizontal ? reset ? base : vpixels.head : ipixels.center; + model.y = horizontal ? ipixels.center : reset ? base : vpixels.head; + model.height = horizontal ? ipixels.size : undefined; + model.width = horizontal ? undefined : ipixels.size; - // all borders are drawn for floating bar - if (me._getParsed(index)._custom) { - rectangle._model.borderSkipped = null; + rectangle.pivot(me.chart._animationsDisabled); } - - me._updateElementGeometry(rectangle, index, reset, options); - - rectangle.pivot(me.chart._animationsDisabled); - }, - - /** - * @private - */ - _updateElementGeometry: function(rectangle, index, reset, options) { - const me = this; - const meta = me._cachedMeta; - const model = rectangle._model; - const vScale = meta.vScale; - const base = vScale.getBasePixel(); - const horizontal = vScale.isHorizontal(); - const ruler = me._ruler || me.getRuler(); - const vpixels = me.calculateBarValuePixels(index, options); - const ipixels = me.calculateBarIndexPixels(index, ruler, options); - - model.horizontal = horizontal; - model.base = reset ? base : vpixels.base; - model.x = horizontal ? reset ? base : vpixels.head : ipixels.center; - model.y = horizontal ? ipixels.center : reset ? base : vpixels.head; - model.height = horizontal ? ipixels.size : undefined; - model.width = horizontal ? undefined : ipixels.size; }, /**
true
Other
chartjs
Chart.js
34b93751db94dc775ce00458db5a3cb1dfc5a84a.json
Change updateElement to updateElements (#6722)
src/controllers/controller.bubble.js
@@ -116,39 +116,42 @@ module.exports = DatasetController.extend({ const points = me._cachedMeta.data; // Update Points - helpers.each(points, function(point, index) { - me.updateElement(point, index, reset); - }); + me.updateElements(points, 0, points.length, reset); }, /** * @protected */ - updateElement: function(point, index, reset) { + updateElements: function(points, start, count, reset) { const me = this; const meta = me._cachedMeta; const xScale = meta.xScale; const yScale = meta.yScale; - const options = me._resolveDataElementOptions(index); - const parsed = !reset && me._getParsed(index); - const x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(parsed[xScale.id]); - const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed[yScale.id]); - - point._options = options; - point._model = { - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderWidth: options.borderWidth, - hitRadius: options.hitRadius, - pointStyle: options.pointStyle, - rotation: options.rotation, - radius: reset ? 0 : options.radius, - skip: isNaN(x) || isNaN(y), - x: x, - y: y, - }; - - point.pivot(me.chart._animationsDisabled); + let i; + + for (i = start; i < start + count; i++) { + const point = points[i]; + const options = me._resolveDataElementOptions(i); + const parsed = !reset && me._getParsed(i); + const x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(parsed[xScale.id]); + const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed[yScale.id]); + + point._options = options; + point._model = { + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderWidth: options.borderWidth, + hitRadius: options.hitRadius, + pointStyle: options.pointStyle, + rotation: options.rotation, + radius: reset ? 0 : options.radius, + skip: isNaN(x) || isNaN(y), + x: x, + y: y, + }; + + point.pivot(me.chart._animationsDisabled); + } }, /**
true
Other
chartjs
Chart.js
34b93751db94dc775ce00458db5a3cb1dfc5a84a.json
Change updateElement to updateElements (#6722)
src/controllers/controller.doughnut.js
@@ -217,29 +217,30 @@ module.exports = DatasetController.extend({ me.outerRadius = chart.outerRadius - chart.radiusLength * me._getRingWeightOffset(me.index); me.innerRadius = Math.max(me.outerRadius - chart.radiusLength * chartWeight, 0); - for (i = 0, ilen = arcs.length; i < ilen; ++i) { - me.updateElement(arcs[i], i, reset); - } + me.updateElements(arcs, 0, arcs.length, reset); }, - updateElement: function(arc, index, reset) { - var me = this; - var chart = me.chart; - var chartArea = chart.chartArea; - var opts = chart.options; - var animationOpts = opts.animation; - var centerX = (chartArea.left + chartArea.right) / 2; - var centerY = (chartArea.top + chartArea.bottom) / 2; - var startAngle = opts.rotation; // non reset case handled later - var endAngle = opts.rotation; // non reset case handled later - var circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(arc._parsed * opts.circumference / DOUBLE_PI); - var innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius; - var outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius; - var options = arc._options || {}; - - helpers.extend(arc, { - // Desired view properties - _model: { + + updateElements: function(arcs, start, count, reset) { + const me = this; + const chart = me.chart; + const chartArea = chart.chartArea; + const opts = chart.options; + const animationOpts = opts.animation; + const centerX = (chartArea.left + chartArea.right) / 2; + const centerY = (chartArea.top + chartArea.bottom) / 2; + const startAngle = opts.rotation; // non reset case handled later + const endAngle = opts.rotation; // non reset case handled later + const innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius; + const outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius; + var i; + + for (i = 0; i < start + count; ++i) { + const arc = arcs[i]; + const circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(arc._parsed * opts.circumference / DOUBLE_PI); + const options = arc._options || {}; + const model = { + // Desired view properties backgroundColor: options.backgroundColor, borderColor: options.borderColor, borderWidth: options.borderWidth, @@ -251,23 +252,23 @@ module.exports = DatasetController.extend({ circumference: circumference, outerRadius: outerRadius, innerRadius: innerRadius - } - }); + }; - var model = arc._model; + arc._model = model; - // Set correct angles if not resetting - if (!reset || !animationOpts.animateRotate) { - if (index === 0) { - model.startAngle = opts.rotation; - } else { - model.startAngle = me._cachedMeta.data[index - 1]._model.endAngle; + // Set correct angles if not resetting + if (!reset || !animationOpts.animateRotate) { + if (i === 0) { + model.startAngle = opts.rotation; + } else { + model.startAngle = me._cachedMeta.data[i - 1]._model.endAngle; + } + + model.endAngle = model.startAngle + model.circumference; } - model.endAngle = model.startAngle + model.circumference; + arc.pivot(chart._animationsDisabled); } - - arc.pivot(chart._animationsDisabled); }, calculateTotal: function() {
true
Other
chartjs
Chart.js
34b93751db94dc775ce00458db5a3cb1dfc5a84a.json
Change updateElement to updateElements (#6722)
src/controllers/controller.line.js
@@ -68,14 +68,14 @@ module.exports = DatasetController.extend({ }, update: function(reset) { - var me = this; - var meta = me._cachedMeta; - var line = meta.dataset; - var points = meta.data || []; - var options = me.chart.options; - var config = me._config; - var showLine = me._showLine = valueOrDefault(config.showLine, options.showLines); - var i, ilen; + const me = this; + const meta = me._cachedMeta; + const line = meta.dataset; + const points = meta.data || []; + const options = me.chart.options; + const config = me._config; + const showLine = me._showLine = valueOrDefault(config.showLine, options.showLines); + let i, ilen; // Update Line if (showLine) { @@ -88,9 +88,7 @@ module.exports = DatasetController.extend({ } // Update Points - for (i = 0, ilen = points.length; i < ilen; ++i) { - me.updateElement(points[i], i, reset); - } + me.updateElements(points, 0, points.length, reset); if (showLine && line._model.tension !== 0) { me.updateBezierControlPoints(); @@ -102,35 +100,40 @@ module.exports = DatasetController.extend({ } }, - updateElement: function(point, index, reset) { + updateElements: function(points, start, count, reset) { const me = this; const meta = me._cachedMeta; const xScale = meta.xScale; const yScale = meta.yScale; const stacked = meta._stacked; - const parsed = me._getParsed(index); - const options = me._resolveDataElementOptions(index); - const x = xScale.getPixelForValue(parsed[xScale.id]); - const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(stacked ? me._applyStack(yScale, parsed) : parsed[yScale.id]); - - // Utility - point._options = options; - - // Desired view properties - point._model = { - x: x, - y: y, - skip: isNaN(x) || isNaN(y), - // Appearance - radius: options.radius, - pointStyle: options.pointStyle, - rotation: options.rotation, - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderWidth: options.borderWidth, - // Tooltip - hitRadius: options.hitRadius - }; + var i; + + for (i = start; i < start + count; ++i) { + const point = points[i]; + const parsed = me._getParsed(i); + const options = me._resolveDataElementOptions(i); + const x = xScale.getPixelForValue(parsed[xScale.id]); + const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(stacked ? me._applyStack(yScale, parsed) : parsed[yScale.id]); + + // Utility + point._options = options; + + // Desired view properties + point._model = { + x: x, + y: y, + skip: isNaN(x) || isNaN(y), + // Appearance + radius: options.radius, + pointStyle: options.pointStyle, + rotation: options.rotation, + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderWidth: options.borderWidth, + // Tooltip + hitRadius: options.hitRadius + }; + } }, /** @@ -234,7 +237,6 @@ module.exports = DatasetController.extend({ var ilen = points.length; if (me._showLine) { - meta.dataset.draw(); }
true
Other
chartjs
Chart.js
34b93751db94dc775ce00458db5a3cb1dfc5a84a.json
Change updateElement to updateElements (#6722)
src/controllers/controller.polarArea.js
@@ -154,10 +154,7 @@ module.exports = DatasetController.extend({ start += angle; } - for (i = 0, ilen = arcs.length; i < ilen; ++i) { - arcs[i]._options = me._resolveDataElementOptions(i); - me.updateElement(arcs[i], i, reset); - } + me.updateElements(arcs, 0, arcs.length, reset); }, /** @@ -178,29 +175,29 @@ module.exports = DatasetController.extend({ me.innerRadius = me.outerRadius - chart.radiusLength; }, - updateElement: function(arc, index, reset) { - var me = this; - var chart = me.chart; - var dataset = me.getDataset(); - var opts = chart.options; - var animationOpts = opts.animation; - var scale = chart.scale; - - var centerX = scale.xCenter; - var centerY = scale.yCenter; - - // var negHalfPI = -0.5 * Math.PI; - var datasetStartAngle = opts.startAngle; - var distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]); - var startAngle = me._starts[index]; - var endAngle = startAngle + (arc.hidden ? 0 : me._angles[index]); - - var resetRadius = animationOpts.animateScale ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]); - var options = arc._options || {}; - - helpers.extend(arc, { - // Desired view properties - _model: { + updateElements: function(arcs, start, count, reset) { + const me = this; + const chart = me.chart; + const dataset = me.getDataset(); + const opts = chart.options; + const animationOpts = opts.animation; + const scale = chart.scale; + const centerX = scale.xCenter; + const centerY = scale.yCenter; + var i; + + for (i = 0; i < start + count; i++) { + const arc = arcs[i]; + // var negHalfPI = -0.5 * Math.PI; + const datasetStartAngle = opts.startAngle; + const distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[i]); + const startAngle = me._starts[i]; + const endAngle = startAngle + (arc.hidden ? 0 : me._angles[i]); + + const resetRadius = animationOpts.animateScale ? 0 : scale.getDistanceFromCenterForValue(dataset.data[i]); + const options = arc._options = me._resolveDataElementOptions(i); + + arc._model = { backgroundColor: options.backgroundColor, borderColor: options.borderColor, borderWidth: options.borderWidth, @@ -211,10 +208,10 @@ module.exports = DatasetController.extend({ outerRadius: reset ? resetRadius : distance, startAngle: reset && animationOpts.animateRotate ? datasetStartAngle : startAngle, endAngle: reset && animationOpts.animateRotate ? datasetStartAngle : endAngle - } - }); + }; - arc.pivot(chart._animationsDisabled); + arc.pivot(chart._animationsDisabled); + } }, countVisibleElements: function() {
true
Other
chartjs
Chart.js
34b93751db94dc775ce00458db5a3cb1dfc5a84a.json
Change updateElement to updateElements (#6722)
src/controllers/controller.radar.js
@@ -108,9 +108,7 @@ module.exports = DatasetController.extend({ line.pivot(animationsDisabled); // Update Points - for (i = 0, ilen = points.length; i < ilen; ++i) { - me.updateElement(points[i], i, reset); - } + me.updateElements(points, 0, points.length, reset); // Update bezier control points me.updateBezierControlPoints(); @@ -121,34 +119,39 @@ module.exports = DatasetController.extend({ } }, - updateElement: function(point, index, reset) { - var me = this; - var dataset = me.getDataset(); - var scale = me.chart.scale; - var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]); - var options = me._resolveDataElementOptions(index); - var x = reset ? scale.xCenter : pointPosition.x; - var y = reset ? scale.yCenter : pointPosition.y; - - // Utility - point._options = options; - - // Desired view properties - point._model = { - x: x, // value not used in dataset scale, but we want a consistent API between scales - y: y, - skip: isNaN(x) || isNaN(y), - // Appearance - radius: options.radius, - pointStyle: options.pointStyle, - rotation: options.rotation, - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderWidth: options.borderWidth, - - // Tooltip - hitRadius: options.hitRadius - }; + updateElements: function(points, start, count, reset) { + const me = this; + const dataset = me.getDataset(); + const scale = me.chart.scale; + var i; + + for (i = start; i < start + count; i++) { + const point = points[i]; + const pointPosition = scale.getPointPositionForValue(i, dataset.data[i]); + const options = me._resolveDataElementOptions(i); + const x = reset ? scale.xCenter : pointPosition.x; + const y = reset ? scale.yCenter : pointPosition.y; + + // Utility + point._options = options; + + // Desired view properties + point._model = { + x: x, // value not used in dataset scale, but we want a consistent API between scales + y: y, + skip: isNaN(x) || isNaN(y), + // Appearance + radius: options.radius, + pointStyle: options.pointStyle, + rotation: options.rotation, + backgroundColor: options.backgroundColor, + borderColor: options.borderColor, + borderWidth: options.borderWidth, + + // Tooltip + hitRadius: options.hitRadius + }; + } }, /**
true
Other
chartjs
Chart.js
34b93751db94dc775ce00458db5a3cb1dfc5a84a.json
Change updateElement to updateElements (#6722)
src/core/core.datasetController.js
@@ -48,7 +48,6 @@ function listenArrayEvents(array, listener) { }); } - function scaleClip(scale, allowedOverflow) { var opts = scale && scale.options || {}; var reverse = opts.reverse; @@ -972,15 +971,15 @@ helpers.extend(DatasetController.prototype, { insertElements: function(start, count) { const me = this; const elements = []; + const data = me._cachedMeta.data; let i; + for (i = start; i < start + count; ++i) { elements.push(me.createElement(me.dataElementType)); } - me._cachedMeta.data.splice(start, 0, ...elements); + data.splice(start, 0, ...elements); me._parse(start, count); - for (i = 0; i < count; ++i) { - me.updateElement(elements[i], start + i, true); - } + me.updateElements(data, start, count); }, /**
true
Other
chartjs
Chart.js
f5b2b8db64c22347a61a4df1e48a16a48e374ebb.json
Reduce object creation during parsing (#6758) * Reduce object creation during parsing * Rename method to createElement * Make code more efficient? * Update migration guide
docs/getting-started/v3-migration.md
@@ -65,18 +65,19 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released * `helpers.removeEvent` * `helpers.roundedRect` * `helpers.scaleMerge` -* `Scale.getRightValue` -* `Scale.mergeTicksOptions` -* `Scale.ticksAsNumbers` * `Chart.Controller` * `Chart.chart.chart` * `Chart.types` -* `Line.calculatePointY` +* `DatasetController.addElementAndReset` * `Element.getArea` * `Element.height` * `Element.inLabelRange` -* Made `scale.handleDirectionalChanges` private -* Made `scale.tickValues` private +* `Line.calculatePointY` +* `Scale.getRightValue` +* `Scale.mergeTicksOptions` +* `Scale.ticksAsNumbers` +* `Scale.handleDirectionalChanges` is now private +* `Scale.tickValues` is now private #### Removal of private APIs @@ -95,6 +96,7 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released * `helpers.log10` was renamed to `helpers.math.log10` * `Chart.Animation.animationObject` was renamed to `Chart.Animation` * `Chart.Animation.chartInstance` was renamed to `Chart.Animation.chart` +* `DatasetController.createMetaData` and `DatasetController.createMetaDataset` were replaced with `DatasetController.createElement` * `TimeScale.getLabelCapacity` was renamed to `TimeScale._getLabelCapacity` * `TimeScale.tickFormatFunction` was renamed to `TimeScale._tickFormatFunction` * `TimeScale.getPixelForOffset` was renamed to `TimeScale._getPixelForOffset`
true
Other
chartjs
Chart.js
f5b2b8db64c22347a61a4df1e48a16a48e374ebb.json
Reduce object creation during parsing (#6758) * Reduce object creation during parsing * Rename method to createElement * Make code more efficient? * Update migration guide
src/controllers/controller.doughnut.js
@@ -143,7 +143,7 @@ module.exports = DatasetController.extend({ var metaData = this.getMeta().data; var i, ilen; for (i = start, ilen = start + count; i < ilen; ++i) { - metaData[i]._val = +data[i]; + metaData[i]._parsed = +data[i]; } }, @@ -232,7 +232,7 @@ module.exports = DatasetController.extend({ var centerY = (chartArea.top + chartArea.bottom) / 2; var startAngle = opts.rotation; // non reset case handled later var endAngle = opts.rotation; // non reset case handled later - var circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(arc._val * opts.circumference / DOUBLE_PI); + var circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(arc._parsed * opts.circumference / DOUBLE_PI); var innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius; var outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius; var options = arc._options || {}; @@ -276,7 +276,7 @@ module.exports = DatasetController.extend({ var value; helpers.each(metaData, function(arc) { - value = arc ? arc._val : NaN; + value = arc ? arc._parsed : NaN; if (!isNaN(value) && !arc.hidden) { total += Math.abs(value); }
true
Other
chartjs
Chart.js
f5b2b8db64c22347a61a4df1e48a16a48e374ebb.json
Reduce object creation during parsing (#6758) * Reduce object creation during parsing * Rename method to createElement * Make code more efficient? * Update migration guide
src/core/core.datasetController.js
@@ -327,20 +327,9 @@ helpers.extend(DatasetController.prototype, { } }, - createMetaDataset: function() { - var me = this; - var type = me.datasetElementType; - return type && new type({ - _ctx: me.chart.ctx - }); - }, - - createMetaData: function() { - var me = this; - var type = me.dataElementType; + createElement: function(type) { return type && new type({ - _ctx: me.chart.ctx, - _parsed: {} + _ctx: this.chart.ctx }); }, @@ -411,16 +400,10 @@ helpers.extend(DatasetController.prototype, { data = me._data; for (i = 0, ilen = data.length; i < ilen; ++i) { - metaData[i] = metaData[i] || me.createMetaData(); + metaData[i] = metaData[i] || me.createElement(me.dataElementType); } - meta.dataset = meta.dataset || me.createMetaDataset(); - }, - - addElementAndReset: function(index) { - var element = this.createMetaData(); - this._cachedMeta.data.splice(index, 0, element); - this.updateElement(element, index, true); + meta.dataset = meta.dataset || me.createElement(me.datasetElementType); }, buildOrUpdateElements: function() { @@ -973,10 +956,17 @@ helpers.extend(DatasetController.prototype, { * @private */ insertElements: function(start, count) { - for (var i = 0; i < count; ++i) { - this.addElementAndReset(start + i); + const me = this; + const elements = []; + var i; + for (i = start; i < start + count; ++i) { + elements.push(me.createElement(me.dataElementType)); + } + me._cachedMeta.data.splice(start, 0, ...elements); + me._parse(start, count); + for (i = 0; i < count; ++i) { + me.updateElement(elements[i], start + i, true); } - this._parse(start, count); }, /**
true
Other
chartjs
Chart.js
4b4b4b79e1e24d2f8e253abbe365a34021a29b79.json
Convert all scales to use ES6 classes
src/scales/scale.category.js
@@ -1,29 +1,28 @@ 'use strict'; -var Scale = require('../core/core.scale'); +const Scale = require('../core/core.scale'); -var defaultConfig = { +const defaultConfig = { position: 'bottom' }; -module.exports = Scale.extend({ - - _parse: function(raw, index) { +class CategroyScale extends Scale { + _parse(raw, index) { var labels = this._getLabels(); var first = labels.indexOf(raw); var last = labels.lastIndexOf(raw); return first === -1 || first !== last ? index : first; - }, + } - determineDataLimits: function() { + determineDataLimits() { var me = this; var max = me._getLabels().length - 1; me.min = Math.max(me._userMin || 0, 0); me.max = Math.min(me._userMax || max, max); - }, + } - buildTicks: function() { + buildTicks() { var me = this; var labels = me._getLabels(); var min = me.min; @@ -34,19 +33,19 @@ module.exports = Scale.extend({ return labels.map(function(l) { return {value: l}; }); - }, + } - getLabelForValue: function(value) { + getLabelForValue(value) { var me = this; var labels = me._getLabels(); if (value >= 0 && value < labels.length) { return labels[value]; } return value; - }, + } - _configure: function() { + _configure() { var me = this; var offset = me.options.offset; var ticks = me.ticks; @@ -64,36 +63,37 @@ module.exports = Scale.extend({ me._startValue = me.min - (offset ? 0.5 : 0); me._valueRange = Math.max(ticks.length - (offset ? 0 : 1), 1); - }, + } // Used to get data value locations. Value can either be an index or a numerical value - getPixelForValue: function(value) { + getPixelForValue(value) { var me = this; if (typeof value !== 'number') { value = me._parse(value); } return me.getPixelForDecimal((value - me._startValue) / me._valueRange); - }, + } - getPixelForTick: function(index) { + getPixelForTick(index) { var ticks = this.ticks; return index < 0 || index > ticks.length - 1 ? null : this.getPixelForValue(index + this.min); - }, + } - getValueForPixel: function(pixel) { + getValueForPixel(pixel) { var me = this; var value = Math.round(me._startValue + me.getDecimalForPixel(pixel) * me._valueRange); return Math.min(Math.max(value, 0), me.ticks.length - 1); - }, + } - getBasePixel: function() { + getBasePixel() { return this.bottom; } -}); +} +module.exports = CategroyScale; // INTERNAL: static default options, registered in src/index.js module.exports._defaults = defaultConfig;
true
Other
chartjs
Chart.js
4b4b4b79e1e24d2f8e253abbe365a34021a29b79.json
Convert all scales to use ES6 classes
src/scales/scale.linear.js
@@ -1,18 +1,18 @@ 'use strict'; -var helpers = require('../helpers/index'); -var LinearScaleBase = require('./scale.linearbase'); -var Ticks = require('../core/core.ticks'); +const helpers = require('../helpers/index'); +const LinearScaleBase = require('./scale.linearbase'); +const Ticks = require('../core/core.ticks'); -var defaultConfig = { +const defaultConfig = { position: 'left', ticks: { callback: Ticks.formatters.linear } }; -module.exports = LinearScaleBase.extend({ - determineDataLimits: function() { +class LinearScale extends LinearScaleBase { + determineDataLimits() { var me = this; var DEFAULT_MIN = 0; var DEFAULT_MAX = 1; @@ -30,10 +30,10 @@ module.exports = LinearScaleBase.extend({ // Common base implementation to handle min, max, beginAtZero me.handleTickRangeOptions(); - }, + } // Returns the maximum number of ticks based on the scale dimension - _computeTickLimit: function() { + _computeTickLimit() { var me = this; var tickFont; @@ -42,35 +42,36 @@ module.exports = LinearScaleBase.extend({ } tickFont = helpers.options._parseFont(me.options.ticks); return Math.ceil(me.height / tickFont.lineHeight); - }, + } /** * Called after the ticks are built * @private */ - _handleDirectionalChanges: function(ticks) { + _handleDirectionalChanges(ticks) { // If we are in a vertical orientation the top value is the highest so reverse the array return this.isHorizontal() ? ticks : ticks.reverse(); - }, + } // Utils - getPixelForValue: function(value) { + getPixelForValue(value) { var me = this; return me.getPixelForDecimal((value - me._startValue) / me._valueRange); - }, + } - getValueForPixel: function(pixel) { + getValueForPixel(pixel) { return this._startValue + this.getDecimalForPixel(pixel) * this._valueRange; - }, + } - getPixelForTick: function(index) { + getPixelForTick(index) { var ticks = this._tickValues; if (index < 0 || index > ticks.length - 1) { return null; } return this.getPixelForValue(ticks[index]); } -}); +} +module.exports = LinearScale; // INTERNAL: static default options, registered in src/index.js module.exports._defaults = defaultConfig;
true