]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
When the category scale is used as the non main scale, return the correct data for... 3284/head
authorEvert Timberg <evert.timberg+github@gmail.com>
Sat, 10 Sep 2016 01:03:59 +0000 (21:03 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sat, 10 Sep 2016 01:03:59 +0000 (21:03 -0400)
src/scales/scale.category.js

index 7767ef58df78b6ace01a712c536a3e638d11a46a..6d9c33b646dc1e50e2600f8c428b070f03cbb0d6 100644 (file)
@@ -49,8 +49,16 @@ module.exports = function(Chart) {
                        me.ticks = (me.minIndex === 0 && me.maxIndex === labels.length - 1) ? labels : labels.slice(me.minIndex, me.maxIndex + 1);
                },
 
-               getLabelForIndex: function(index) {
-                       return this.ticks[index];
+               getLabelForIndex: function(index, datasetIndex) {
+                       var me = this;
+                       var data = me.chart.data;
+                       var isHorizontal = me.isHorizontal();
+
+                       if ((data.xLabels && isHorizontal) || (data.yLabels && !isHorizontal)) {
+                               return me.getRightValue(data.datasets[datasetIndex].data[index]);
+                       } else {
+                               return me.ticks[index];
+                       }
                },
 
                // Used to get data value locations.  Value can either be an index or a numerical value