-
-
Save iamvee/80bb532d49103a171520bd0d6ddcd14a to your computer and use it in GitHub Desktop.
x_Svg
This file contains hidden or 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
var x = $$('.sparkline')[4] | |
.attributes[1].nodeValue.replace('M','').split('L') | |
.map(x => +x.split(',')[1]) | |
var foll = $$(".DataPoint-info")[4].childNodes | |
var info = {"df": +foll[1].innerHTML, "va": +foll[0].data} | |
var w = info['df'] / (x[27] - x[0]) | |
var initial = info['va'] - info['df'] | |
var res = [initial] | |
var diff = []; | |
for (let i in x) { | |
res.push(initial + w * (x[i]-x[0] )); | |
diff.push({'i':res[i] , 'j':res[i-1], 'dif':res[i] - res[i-1]}) | |
} | |
// ------------------------------ | |
console.log(diff) | |
var recs = $$('path.sparkline')[2].attributes[1].nodeValue.replace('M','').split('L') | |
.map(x => +x.split(',')[1]) | |
var coef = (+$$(".DataPoint-info")[2].childNodes[0].data.replace(',', '')) / recs.reduce((x, y) => x + y) | |
recs = recs.map(_x => +(_x*coef).toFixed()) |
This file contains hidden or 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
# args: delta, final | |
args = 100, 500 | |
x, y = zip(*map(eval, text.split("L")[1:])) | |
f = lambda arr: lambda _d, _f: lambda inp: int(((inp - arr[0]) / (arr[-1] - arr[0]) * _d) + _f - _d) | |
result = map(f(y)(*args), y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment