Skip to content

Commit

Permalink
Split three-stated variable into 2 variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Dec 19, 2018
1 parent 574949d commit eb749c1
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/scales/scale.category.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,13 @@ module.exports = function() {
// This is the case in some tests, and probably only in tests
var ds = chart.getDatasetMeta && chart.getDatasetMeta(datasetIndex).controller;

// Three states here
// null: There is no getValueScaleId in dataset (= not a bar chart)
// true: Scale same as this
// false: Value scale is not this scale
var isValue = ds && ds.getValueScaleId
? ds.getValueScaleId() === me.id
: null;

// FIXME For non-bar charts we assume vertical axis is value scale
// Do we have a getValuesScaleId function? (eg. bar chart)
var hasValueScale = ds && ds.getValueScaleId;
var isValueScale = hasValueScale && ds.getValueScaleId() === me.id;

// FIXME For non-bar charts we assume vertical axis is a value scale
// and thus should return getRightValue
if (isValue || (isValue === null && !isHorizontal)) {
if (isValueScale || (!hasValueScale && !isHorizontal)) {
return me.getRightValue(data.datasets[datasetIndex].data[index]);
}
return me.ticks[index - me.minIndex];
Expand Down

0 comments on commit eb749c1

Please sign in to comment.