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
perf: remove unnecessary context.save()
& context.restore()
#141
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option for sharp grid lines, and a few minor things
Extended changelog for v1.11.
…lds. `chart.options.horizontalLines` is an array of values of form: { color:'#ffffff', lineWidth: 1, value: 0 } That example results in a 1px white line, indicating the y-axis. This is useful if your chart has both positive and negative values, and absolute values are important. Before this patch, only relative values could easily be observed. The set of lines may be dynamically updated at runtime. The example in customisation.html demonstrates this.
Client code can now provide custom code to calculate the min/max y-values. This provides more flexibility than a dozen confusing settings. The demo in customisation.html has been extended to show this new behaviour in operation. The custom y-range function in this demo balances the range around y==0, and ensures there's always a minimum range visible to avoid situations where near-zero noise values from a sensor are stretched to the full visual range, exaggerating its significance when in fact it can likely be ignored.
Before this patch, the chart could convey misinformation under some circumstances. For example, if you set maxValue to 5, and then plotted the values 1,10,1, you would view these points as 1,5,1. By saturating the y-pixel-value to always be on the chart, the viewer may be shown misinformation. This patch simply removes the saturation. If the min/max values are tighter than the data, you see cropping of the series.
Callers can now specify a subset of the grid options object. Before this patch callers had to specify all or none of the grid options in the SmoothieChart constructor function. Also the default strokeStyle for grid lines was given two different default values, depending upon how you constructed SmoothieChart. This new approach means that the default values are all specified in the same, single, place. typeof(val) === 'undefined' is used for values which may legitimately be zero. This code would be quite a bit less verbose if using something like Underscore.js's `extend` function [1]. A similar approach that doesn't depend upon any libraries would be good. [1] http://underscorejs.org/#extend
The example in customisation.html shows a way of rounding the upper/lower limits to numbers rounded in a human-friendly fashion.
Support for horizontal lines and a min/max range callback function
Exports declared. package.json added.
package.json: - Using consistent version numbers - Pointing at source repo after cherry-picking from @dominictarr's fork. - Removed duplicate 'main' definition - Extended keywords
Rearranged some aspects of the render function for clarity.
Improved performance when dropping multiple points by only calling splice once (an O(N) operation itself), rather than N times.
…es was always being removed, not necessarily the provided one. Closes joewalnes#24. Thanks to @davidgaleano for providing the fix!
This is more consistent with the rest of the options, but breaks a relatively new, obscure and optional API.
Documented the three different types of available options in the code using /** */ style comments.
…er they're chart options, or series options.
Reduce the amount of checks
This changes behavior a bit - when `render(` is passed a canvas different from `this.canvas`
and when the user calls `render` manually with a custom `time` argument
…der time It would depend on `scrollBackwards` and `fillStyle` being `undefined` or not. Depending on this, it would either continue the line up to the edge of the canvas or leave it at `lastX`. This makes it so that it is always left at `lastX`.
…tore()`" This reverts commit f7b488e. For some reason in Chromium 95.0.4638.54 (and maybe others) that change caused `render()` CPU time to grow over time. For me on the `examples/example1.html` page it would grow from 0.5ms to 50ms over 5 minutes
This reverts commit 3777c46.
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reverts commit 3777c46.
TODO: