mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 04:09:08 +02:00
* fix issue #11717 Signed-off-by: Hu, Vince <Qingkun.Hu@fmr.com> * unit test for issue #11717 * fixing test lint style issue * update codes according review comments --------- Signed-off-by: Hu, Vince <Qingkun.Hu@fmr.com>
This commit is contained in:
parent
0ca1b6ef85
commit
147ee593ba
@ -437,9 +437,11 @@ export default class BarController extends DatasetController {
|
|||||||
.filter(meta => meta.controller.options.grouped);
|
.filter(meta => meta.controller.options.grouped);
|
||||||
const stacked = iScale.options.stacked;
|
const stacked = iScale.options.stacked;
|
||||||
const stacks = [];
|
const stacks = [];
|
||||||
|
const currentParsed = this._cachedMeta.controller.getParsed(dataIndex);
|
||||||
|
const iScaleValue = currentParsed && currentParsed[iScale.axis];
|
||||||
|
|
||||||
const skipNull = (meta) => {
|
const skipNull = (meta) => {
|
||||||
const parsed = meta.controller.getParsed(dataIndex);
|
const parsed = meta._parsed.find(item => item[iScale.axis] === iScaleValue);
|
||||||
const val = parsed && parsed[meta.vScale.axis];
|
const val = parsed && parsed[meta.vScale.axis];
|
||||||
|
|
||||||
if (isNullOrUndef(val) || isNaN(val)) {
|
if (isNullOrUndef(val) || isNaN(val)) {
|
||||||
|
@ -1676,6 +1676,92 @@ describe('Chart.controllers.bar', function() {
|
|||||||
expect(unevenChart).not.toThrow();
|
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() => {
|
it('should not override tooltip title and label callbacks', async() => {
|
||||||
const chart = window.acquireChart({
|
const chart = window.acquireChart({
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
|
Loading…
Reference in New Issue
Block a user