File tree Expand file tree Collapse file tree 2 files changed +89
-1
lines changed Expand file tree Collapse file tree 2 files changed +89
-1
lines changed Original file line number Diff line number Diff line change @@ -437,9 +437,11 @@ export default class BarController extends DatasetController {
437
437
. filter ( meta => meta . controller . options . grouped ) ;
438
438
const stacked = iScale . options . stacked ;
439
439
const stacks = [ ] ;
440
+ const currentParsed = this . _cachedMeta . controller . getParsed ( dataIndex ) ;
441
+ const iScaleValue = currentParsed && currentParsed [ iScale . axis ] ;
440
442
441
443
const skipNull = ( meta ) => {
442
- const parsed = meta . controller . getParsed ( dataIndex ) ;
444
+ const parsed = meta . _parsed . find ( item => item [ iScale . axis ] === iScaleValue ) ;
443
445
const val = parsed && parsed [ meta . vScale . axis ] ;
444
446
445
447
if ( isNullOrUndef ( val ) || isNaN ( val ) ) {
Original file line number Diff line number Diff line change @@ -1676,6 +1676,92 @@ describe('Chart.controllers.bar', function() {
1676
1676
expect ( unevenChart ) . not . toThrow ( ) ;
1677
1677
} ) ;
1678
1678
1679
+ it ( 'should correctly count the number of stacks when skipNull and different order datasets' , function ( ) {
1680
+
1681
+ const chart = window . acquireChart ( {
1682
+ type : 'bar' ,
1683
+ data : {
1684
+ datasets : [
1685
+ {
1686
+ id : '1' ,
1687
+ label : 'USA' ,
1688
+ data : [
1689
+ {
1690
+ xScale : 'First' ,
1691
+ Country : 'USA' ,
1692
+ yScale : 524
1693
+ } ,
1694
+ {
1695
+ xScale : 'Second' ,
1696
+ Country : 'USA' ,
1697
+ yScale : 325
1698
+ }
1699
+ ] ,
1700
+
1701
+ yAxisID : 'yScale' ,
1702
+ xAxisID : 'xScale' ,
1703
+
1704
+ parsing : {
1705
+ yAxisKey : 'yScale' ,
1706
+ xAxisKey : 'xScale'
1707
+ }
1708
+ } ,
1709
+ {
1710
+ id : '2' ,
1711
+ label : 'BRA' ,
1712
+ data : [
1713
+ {
1714
+ xScale : 'Second' ,
1715
+ Country : 'BRA' ,
1716
+ yScale : 183
1717
+ } ,
1718
+ {
1719
+ xScale : 'First' ,
1720
+ Country : 'BRA' ,
1721
+ yScale : 177
1722
+ }
1723
+ ] ,
1724
+
1725
+ yAxisID : 'yScale' ,
1726
+ xAxisID : 'xScale' ,
1727
+
1728
+ parsing : {
1729
+ yAxisKey : 'yScale' ,
1730
+ xAxisKey : 'xScale'
1731
+ }
1732
+ } ,
1733
+ {
1734
+ id : '3' ,
1735
+ label : 'DEU' ,
1736
+ data : [
1737
+ {
1738
+ xScale : 'First' ,
1739
+ Country : 'DEU' ,
1740
+ yScale : 162
1741
+ }
1742
+ ] ,
1743
+
1744
+ yAxisID : 'yScale' ,
1745
+ xAxisID : 'xScale' ,
1746
+
1747
+ parsing : {
1748
+ yAxisKey : 'yScale' ,
1749
+ xAxisKey : 'xScale'
1750
+ }
1751
+ }
1752
+ ]
1753
+ } ,
1754
+ options : {
1755
+ skipNull : true
1756
+ }
1757
+ } ) ;
1758
+
1759
+ var meta = chart . getDatasetMeta ( 0 ) ;
1760
+ expect ( meta . controller . _getStackCount ( 0 ) ) . toBe ( 3 ) ;
1761
+ expect ( meta . controller . _getStackCount ( 1 ) ) . toBe ( 2 ) ;
1762
+
1763
+ } ) ;
1764
+
1679
1765
it ( 'should not override tooltip title and label callbacks' , async ( ) => {
1680
1766
const chart = window . acquireChart ( {
1681
1767
type : 'bar' ,
You can’t perform that action at this time.
0 commit comments