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

orf is not a function #1891

Closed
davis opened this issue Jan 12, 2016 · 6 comments
Closed

orf is not a function #1891

davis opened this issue Jan 12, 2016 · 6 comments
Milestone

Comments

@davis
Copy link
Contributor

davis commented Jan 12, 2016

            if (this._model.yAlign === 'center') {
                lf = function(x) { return x <= midX; };
                rf = function(x) { return x > midX; };
                olf = function(x) { return x + size.width > _this._chart.width; };
                orf = function(x) { return x - size.width < 0; };
                yf = function(y) { return y <= midY ? 'top' : 'bottom'; };
            } else {                                                               // [1]
                lf = function(x) { return x <= (size.width / 2); };
                rf = function(x) { return x >= (_this._chart.width - (size.width / 2)); };
            }

            if (lf(this._model.x)) {
                this._model.xAlign = 'left';

                // Is tooltip too wide and goes over the right side of the chart.?
                if (olf(this._model.x)) {
                    this._model.xAlign = 'center';
                    this._model.yAlign = yf(this._model.y);
                }
            } else if (rf(this._model.x)) {                                // [2]
                this._model.xAlign = 'right';

                // Is tooltip too wide and goes outside left edge of canvas?
                if (orf(this._model.x)) {
                    this._model.xAlign = 'center';
                    this._model.yAlign = yf(this._model.y);
                }
            }

somewhere in this block of logic, i'm hitting the first else block [1] because yAlign is "bottom", so orf never gets set,
then i hit the else if block [2] because lf(this._model.x) is false, and rf(this._model.x) is true and orf is undefined

I haven't done too much digging around, but perhaps you guys may know a bit more about this?

should olf, orf, and yf be getting set even if yAlign is not "center"?

I'll get around to posting a fiddle

@etimberg
Copy link
Member

@davis I think this is related to #1884

I was just gonna take a look at it to see what the issue was

@davis
Copy link
Contributor Author

davis commented Jan 12, 2016

@etimberg I changed the code from

if (this._model.yAlign === 'center') {
  lf = function(x) { return x <= midX; };
  rf = function(x) { return x > midX; };
  olf = function(x) { return x + size.width > _this._chart.width; };
  orf = function(x) { return x - size.width < 0; };
  yf = function(y) { return y <= midY ? 'top' : 'bottom'; };
} else {
  lf = function(x) { return x <= (size.width / 2); };
  rf = function(x) { return x >= (_this._chart.width - (size.width / 2)); };
}

to

if (this._model.yAlign === 'center') {
  lf = function(x) { return x <= midX; };
  rf = function(x) { return x > midX; };
} else {
  lf = function(x) { return x <= (size.width / 2); };
  rf = function(x) { return x >= (_this._chart.width - (size.width / 2)); };
}

olf = function(x) { return x + size.width > _this._chart.width; };
orf = function(x) { return x - size.width < 0; };
yf = function(y) { return y <= midY ? 'top' : 'bottom'; };

and that seemed to fix the bug

@etimberg
Copy link
Member

@davis checked out your fix and it works well. It also fixes #1884

if you can, please open a PR and I will merge it.

@davis
Copy link
Contributor Author

davis commented Jan 12, 2016

oh, sure!

@etimberg
Copy link
Member

Closing as #1892 was merged

@tanuja840
Copy link

i need help
i want to add tooltips in my line graph

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

No branches or pull requests

3 participants