Skip to content

Commit

Permalink
unit test for issue chartjs#11717
Browse files Browse the repository at this point in the history
  • Loading branch information
huqingkun committed Jul 31, 2024
1 parent 549ce91 commit 170f4ce
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions test/specs/controller.bar.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,92 @@ describe('Chart.controllers.bar', function() {
expect(unevenChart).not.toThrow();
});

it('should correctly count the number of stacks when skipNull and different order datasets', function() {

const chart = window.acquireChart({
type: "bar",
data: {
datasets: [
{
id: "1",
label: "USA",
data: [
{
xScale: "First",
Country: "USA",
yScale: 524
},
{
xScale: "Second",
Country: "USA",
yScale: 325
}
],

yAxisID: "yScale",
xAxisID: "xScale",

parsing: {
yAxisKey: "yScale",
xAxisKey: "xScale"
}
},
{
id: "2",
label: "BRA",
data: [
{
xScale: "Second",
Country: "BRA",
yScale: 183
},
{
xScale: "First",
Country: "BRA",
yScale: 177
}
],

yAxisID: "yScale",
xAxisID: "xScale",

parsing: {
yAxisKey: "yScale",
xAxisKey: "xScale"
}
},
{
id: "3",
label: "DEU",
data: [
{
xScale: "First",
Country: "DEU",
yScale: 162
}
],

yAxisID: "yScale",
xAxisID: "xScale",

parsing: {
yAxisKey: "yScale",
xAxisKey: "xScale"
}
}
]
},
options: {
skipNull: true
}
})

var meta = chart.getDatasetMeta(0);
expect(meta.controller._getStackCount(0)).toBe(3);
expect(meta.controller._getStackCount(1)).toBe(2);

});

it('should not override tooltip title and label callbacks', async() => {
const chart = window.acquireChart({
type: 'bar',
Expand Down

0 comments on commit 170f4ce

Please sign in to comment.