Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BarChart xConfig labelRotation issue #705

Open
xscotta opened this issue Aug 20, 2020 · 1 comment
Open

BarChart xConfig labelRotation issue #705

xscotta opened this issue Aug 20, 2020 · 1 comment

Comments

@xscotta
Copy link

xscotta commented Aug 20, 2020

Thanks in advance, please let me know if you need more data...

The version of d3plus from the comments at the top is " d3plus v2.0.0-alpha.25 "

I am using d3plus.Barchart...and changing the Xaxis label orientation by 90 degrees
.config ({ xConfig: { title: "" , labelRotation: 1 } })

This works in all cases except it gives an error when the number of labels is 2 or 3. So it works when the number of labels is 1, 4, 5, 6, 7 etc.

The error is at "d3plus.full.js:29525:72"
The error is " textData[(i + diff))] is undefined"
The line of code being executed in the function below is " var prevPosition =......."
The function being called is...
function calculateSpace(datum) {
var diff = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var i = datum.i,
position = datum.position;

      if (this._scale === "band") {
        return this._d3Scale.bandwidth();
      } else {
        var prevPosition = i - diff < 0 ? textData.length === 1 || !this._range ? rangeOuter[0] : (position - textData[i + diff].position) / 2 - position : position - (position - textData[i - diff].position) / 2;
        var prevSpace = Math.abs(position - prevPosition);
        var nextPosition = i + diff > textData.length - 1 ? textData.length === 1 || !this._range ? rangeOuter[1] : (position - textData[i - diff].position) / 2 - position : position - (position - textData[i + diff].position) / 2;
        var nextSpace = Math.abs(position - nextPosition);
        return min([prevSpace, nextSpace]) * 2;
      }
    }
@davelandry
Copy link
Member

davelandry commented Aug 25, 2020

@xscotta can you please post a full code snippit of your implementation showing this behavior? preferably as a jsfiddle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants