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

Warn if points are out of range #1050

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deribaucourt
Copy link

Some users may improperly define the range of their axes, leading to points being drawn outside of the chart area. In the worst cases, if all points are out of range, the chart will not be drawn at all.

Adding a warning can help users identify this issue and correct it.

Note that may spew a lot of warnings if their are a lot of points.


Such a warning helped me debug the usage of netdata. See netdata/netdata-cloud#1048

@mirabilos
Copy link
Collaborator

mirabilos commented Oct 22, 2024 via email

@deribaucourt
Copy link
Author

@mirabilos Done, thanks a lot for your review!

@deribaucourt deribaucourt force-pushed the master branch 3 times, most recently from 49f6836 to d56f470 Compare October 24, 2024 07:46

for (var j = 0; j < points.length; j++) {
var point = points[j];

// Range from 0-1 where 0 represents left and 1 represents right.
point.x = DygraphLayout.calcXNormal_(point.xval, this._xAxis, isLogscaleForX);
outOfXBounds += ((point.x<0)||(point.x>1));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (point.x < 0) || (point.x > 1), I had left out the spaces in the mail to convey the idea and not go over normal eMail line length, and the outer parenthesēs are redundant here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -269,6 +271,14 @@ DygraphLayout.prototype._evaluateLineCharts = function() {
}
}
point.y = DygraphLayout.calcYNormal_(axis, yval, logscale);
outOfYBounds += ((point.y<0)||(point.y>1));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

outOfYBounds += ((point.y<0)||(point.y>1));
}

if (outOfXBounds > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether this even makes sense for the x axis… or rather, when zooming in, some points are always going to be out of bounds, also for the y axis. Maybe the checks should be conditional on not having zoomed in? Unless they are already excluded then…

Perhaps we need to play around a bit with this.

Copy link
Author

@deribaucourt deribaucourt Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting question!
If I zoom in, the warning is only displayed for 2 points (those that allow drawing the line going out of the edge it appears). So it looks like all other points are excluded.

The rest of the time, x axis warnings are really interesting. In my use case for instance, I needed them to debug a graph not being shown because the x axis was improperly configured.

I think we would be good with simply ignoring 2 points from the x axis out of bounds counter. It's not going to generate false negatives except for graphs with just 2 points. While providing protection for zooming.

image

Some users may improperly define the range of their axes, leading to
points being drawn outside of the chart area. In the worst cases, if
all points are out of range, the chart will not be drawn at all.

Adding a warning can help users identify this issue and correct it.

2 x points are allowed in order to draw the edges of the chart when
zoomed in.
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

Successfully merging this pull request may close these issues.

2 participants