forked from chartjs/Chart.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce unit test based on image comparison (chartjs#3988)
Attempt to make easier the creation of unit tests that check the drawing output. Until now, this was done by checking calls on a 'fake' context, which is hard to maintain (need to update pixel values by hands) and also not reliable when optimizing code (i.e. different calls sequence but same result). As of now, it's possible to define 'auto' tests based on JSON/PNG fixtures: chart is generated from the JSON file and compared to the associated PNG image. The image diff is done using `pixelmatch`. As an example (and in preparation of the `filler` plugin), add auto tests for the line element `fill` options.
- Loading branch information
1 parent
77d74b2
commit 3f948ad
Showing
30 changed files
with
835 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"config": { | ||
"type": "line", | ||
"data": { | ||
"labels": ["0", "1", "2", "3", "4", "5", "6", "7", "8"], | ||
"datasets": [{ | ||
"backgroundColor": "rgba(0, 0, 255, 0.25)", | ||
"data": [null, null, 2, 3, 4, -4, -2, 1, 0] | ||
}, { | ||
"backgroundColor": "rgba(0, 255, 0, 0.25)", | ||
"data": [6, 2, null, 4, 5, null, null, 2, 1] | ||
}, { | ||
"backgroundColor": "rgba(255, 0, 0, 0.25)", | ||
"data": [7, 3, 4, 5, 6, 1, 4, null, null] | ||
}, { | ||
"backgroundColor": "rgba(0, 0, 255, 0.25)", | ||
"data": [8, 7, 6, -6, -4, -6, 4, 5, 8] | ||
}] | ||
}, | ||
"options": { | ||
"responsive": false, | ||
"spanGaps": true, | ||
"legend": false, | ||
"title": false, | ||
"scales": { | ||
"xAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}], | ||
"yAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}] | ||
}, | ||
"elements": { | ||
"point": { | ||
"radius": 0 | ||
}, | ||
"line": { | ||
"borderColor": "transparent", | ||
"fill": "bottom", | ||
"tension": 0 | ||
} | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"config": { | ||
"type": "line", | ||
"data": { | ||
"labels": ["0", "1", "2", "3", "4", "5", "6", "7", "8"], | ||
"datasets": [{ | ||
"backgroundColor": "rgba(0, 0, 255, 0.25)", | ||
"data": [null, null, 2, 3, 4, -4, -2, 1, 0] | ||
}, { | ||
"backgroundColor": "rgba(0, 255, 0, 0.25)", | ||
"data": [6, 2, null, 4, 5, null, null, 2, 1] | ||
}, { | ||
"backgroundColor": "rgba(255, 0, 0, 0.25)", | ||
"data": [7, 3, 4, 5, 6, 1, 4, null, null] | ||
}, { | ||
"backgroundColor": "rgba(0, 0, 255, 0.25)", | ||
"data": [8, 7, 6, -6, -4, -6, 4, 5, 8] | ||
}] | ||
}, | ||
"options": { | ||
"responsive": false, | ||
"spanGaps": false, | ||
"legend": false, | ||
"title": false, | ||
"scales": { | ||
"xAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}], | ||
"yAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}] | ||
}, | ||
"elements": { | ||
"point": { | ||
"radius": 0 | ||
}, | ||
"line": { | ||
"borderColor": "transparent", | ||
"fill": "bottom", | ||
"tension": 0 | ||
} | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"config": { | ||
"type": "line", | ||
"data": { | ||
"labels": ["0", "1", "2", "3", "4", "5", "6", "7", "8"], | ||
"datasets": [{ | ||
"backgroundColor": "rgba(0, 0, 192, 0.25)", | ||
"data": [null, null, 2, 4, 2, 1, -1, 1, 2] | ||
}, { | ||
"backgroundColor": "rgba(0, 192, 0, 0.25)", | ||
"data": [4, 2, null, 3, 2.5, null, -2, 1.5, 3] | ||
}, { | ||
"backgroundColor": "rgba(192, 0, 0, 0.25)", | ||
"data": [3.5, 2, 1, 2.5, -2, 3, -1, null, null] | ||
}, { | ||
"backgroundColor": "rgba(128, 0, 128, 0.25)", | ||
"data": [5, 6, 5, -2, -4, -3, 4, 2, 4.5] | ||
}] | ||
}, | ||
"options": { | ||
"responsive": false, | ||
"spanGaps": true, | ||
"legend": false, | ||
"title": false, | ||
"scales": { | ||
"xAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}], | ||
"yAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}] | ||
}, | ||
"elements": { | ||
"point": { | ||
"radius": 0 | ||
}, | ||
"line": { | ||
"cubicInterpolationMode": "monotone", | ||
"borderColor": "transparent", | ||
"fill": "zero" | ||
} | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"config": { | ||
"type": "line", | ||
"data": { | ||
"labels": ["0", "1", "2", "3", "4", "5", "6", "7", "8"], | ||
"datasets": [{ | ||
"backgroundColor": "rgba(0, 0, 192, 0.25)", | ||
"data": [null, null, 2, 4, 2, 1, -1, 1, 2] | ||
}, { | ||
"backgroundColor": "rgba(0, 192, 0, 0.25)", | ||
"data": [4, 2, null, 3, 2.5, null, -2, 1.5, 3] | ||
}, { | ||
"backgroundColor": "rgba(192, 0, 0, 0.25)", | ||
"data": [3.5, 2, 1, 2.5, -2, 3, -1, null, null] | ||
}, { | ||
"backgroundColor": "rgba(128, 0, 128, 0.25)", | ||
"data": [5, 6, 5, -2, -4, -3, 4, 2, 4.5] | ||
}] | ||
}, | ||
"options": { | ||
"responsive": false, | ||
"spanGaps": false, | ||
"legend": false, | ||
"title": false, | ||
"scales": { | ||
"xAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}], | ||
"yAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}] | ||
}, | ||
"elements": { | ||
"point": { | ||
"radius": 0 | ||
}, | ||
"line": { | ||
"cubicInterpolationMode": "monotone", | ||
"borderColor": "transparent", | ||
"fill": "zero" | ||
} | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"config": { | ||
"type": "line", | ||
"data": { | ||
"labels": ["0", "1", "2", "3", "4", "5", "6", "7", "8"], | ||
"datasets": [{ | ||
"backgroundColor": "rgba(0, 0, 192, 0.25)", | ||
"data": [null, null, 2, 4, 2, 1, -1, 1, 2] | ||
}, { | ||
"backgroundColor": "rgba(0, 192, 0, 0.25)", | ||
"data": [4, 2, null, 3, 2.5, null, -2, 1.5, 3] | ||
}, { | ||
"backgroundColor": "rgba(192, 0, 0, 0.25)", | ||
"data": [3.5, 2, 1, 2.5, -2, 3, -1, null, null] | ||
}, { | ||
"backgroundColor": "rgba(128, 0, 128, 0.25)", | ||
"data": [5, 6, 5, -2, -4, -3, 4, 2, 4.5] | ||
}] | ||
}, | ||
"options": { | ||
"responsive": false, | ||
"spanGaps": true, | ||
"legend": false, | ||
"title": false, | ||
"scales": { | ||
"xAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}], | ||
"yAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}] | ||
}, | ||
"elements": { | ||
"point": { | ||
"radius": 0 | ||
}, | ||
"line": { | ||
"cubicInterpolationMode": "monotone", | ||
"borderColor": "transparent", | ||
"stepped": true, | ||
"fill": "zero" | ||
} | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"config": { | ||
"type": "line", | ||
"data": { | ||
"labels": ["0", "1", "2", "3", "4", "5", "6", "7", "8"], | ||
"datasets": [{ | ||
"backgroundColor": "rgba(0, 0, 192, 0.25)", | ||
"data": [null, null, 2, 4, 2, 1, -1, 1, 2] | ||
}, { | ||
"backgroundColor": "rgba(0, 192, 0, 0.25)", | ||
"data": [4, 2, null, 3, 2.5, null, -2, 1.5, 3] | ||
}, { | ||
"backgroundColor": "rgba(192, 0, 0, 0.25)", | ||
"data": [3.5, 2, 1, 2.5, -2, 3, -1, null, null] | ||
}, { | ||
"backgroundColor": "rgba(128, 0, 128, 0.25)", | ||
"data": [5, 6, 5, -2, -4, -3, 4, 2, 4.5] | ||
}] | ||
}, | ||
"options": { | ||
"responsive": false, | ||
"spanGaps": false, | ||
"legend": false, | ||
"title": false, | ||
"scales": { | ||
"xAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}], | ||
"yAxes": [{ | ||
"ticks": { | ||
"display": false | ||
} | ||
}] | ||
}, | ||
"elements": { | ||
"point": { | ||
"radius": 0 | ||
}, | ||
"line": { | ||
"cubicInterpolationMode": "monotone", | ||
"borderColor": "transparent", | ||
"stepped": true, | ||
"fill": "zero" | ||
} | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.