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

Added pixelRatio option to override canvas upscaling. Resolves #876, test included. #877

Merged
merged 5 commits into from
Sep 20, 2017

Conversation

jeffvandyke
Copy link
Contributor

Let me know about any desired changes or adjustments. I hand tested the range-selector gallery example with pixelRatio: 3, and it seems to behave the same and properly force scaling; the implementation followed a definitive pattern of overriding utils.getContextPixelRatio()

Jeff VanDyke added 3 commits August 14, 2017 16:52
Falls back to old behavior if not specified.
Added to options reference,
Added to Dygraph.prototype.resizeElements_,
Added to rangeSelector.prototype.updateVisibility.
First fails without change, then passes after change.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 90.17% when pulling 77e133f on jeffvandyke:876-pixelRatio into f6e73ea on danvk:master.

@jeffvandyke
Copy link
Contributor Author

Just checking, any issues with merging this pull request?

Copy link
Owner

@danvk danvk left a comment

Choose a reason for hiding this comment

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

Left a few comments but otherwise looks good. Thanks for the change!

"pixelRatio": {
"default": "(devicePixelRatio / context.backingStoreRatio)",
"labels": ["Overall display"],
"type": "integer",
Copy link
Owner

Choose a reason for hiding this comment

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

Does this have to be an integer? Can it be a float?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, good idea, since devicePixelRatio can often be a non-whole number for different zoom levels and certain phones.

"default": "(devicePixelRatio / context.backingStoreRatio)",
"labels": ["Overall display"],
"type": "integer",
"description": "Overrides the pixel ratio scaling factor for the canvas's 3d context. Ordinarily, this is set to the devicePixelRatio / (context.backingStoreRatio || 1), so on mobile devices, where the devicePixelRatio can be somewhere around 3, performance can be improved by overriding this value to something less precise, like 1."
Copy link
Owner

Choose a reason for hiding this comment

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

2d context?

"default": "(devicePixelRatio / context.backingStoreRatio)",
"labels": ["Overall display"],
"type": "integer",
"description": "Overrides the pixel ratio scaling factor for the canvas's 3d context. Ordinarily, this is set to the devicePixelRatio / (context.backingStoreRatio || 1), so on mobile devices, where the devicePixelRatio can be somewhere around 3, performance can be improved by overriding this value to something less precise, like 1."
Copy link
Owner

Choose a reason for hiding this comment

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

add a caveat here, something along the lines of "performance can be improved at the expense of resolution"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good note.

src/dygraph.js Outdated
var canvasScale = utils.getContextPixelRatio(this.canvas_ctx_);
var pixelRatioOption = this.getNumericOption('pixelRatio')

var canvasScale = pixelRatioOption > 0
Copy link
Owner

Choose a reason for hiding this comment

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

Any reason not to do pixelRatioOption || utils.getContextPixelRatio(this.canvas_ctx_)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably trying to make my linter happier with 80 char lines, I switched it back here and in range-selector.js, it does read more naturally.

Fix typo in docs, documented a float type,
Simplified method of reading option.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 90.17% when pulling 975dc4e on jeffvandyke:876-pixelRatio into f6e73ea on danvk:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 90.17% when pulling 975dc4e on jeffvandyke:876-pixelRatio into f6e73ea on danvk:master.

@jeffvandyke
Copy link
Contributor Author

Hi, just wondering if you can merge in this pull request? I couldn't find any other changes asked for.

@danvk danvk merged commit 64f1c4d into danvk:master Sep 20, 2017
@danvk
Copy link
Owner

danvk commented Sep 20, 2017

Thanks!

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.

3 participants