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

perf: remove unnecessary context.save() & context.restore() #141

Closed
wants to merge 297 commits into from

Conversation

WofWca
Copy link
Collaborator

@WofWca WofWca commented Oct 24, 2021

This reverts commit 3777c46.

TODO:

  • Merge Merge recent MRs #139
  • See the mentioned commit (3777c46), investigate, maybe file a bug in Chromium.
  • If it was a Chromium bug, consider whether we should refrain from merging this in order to support older versions of Chromium (I think probably not).

joewalnes and others added 30 commits February 23, 2013 09:35
Option for sharp grid lines, and a few minor things
…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
@WofWca WofWca changed the base branch from master to gh-pages April 13, 2022 07:34
@WofWca WofWca closed this Apr 13, 2022
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.

None yet