Created
February 5, 2018 05:22
-
-
Save oakley808/bacb360bc22b891248980be9846e3c66 to your computer and use it in GitHub Desktop.
Draw a line for the average value on MyFitnessPal charts. (Paste into browser console.)
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
chartNum = Highcharts.charts.length - 1 // grab the last (current) chart | |
data = Highcharts.charts[chartNum].series[0].yData.filter(d => d > 0) // remove the nulls/zero values | |
avg = Math.round(data.reduce((a, b) => a + b) / data.length) // calc the average | |
Highcharts.charts[chartNum].yAxis[0].addPlotLine({ // draw the plotline | |
color: avg > 2000 ? '#FF00FF' : 'green', | |
dashStyle: 'longdashdot', | |
value: avg, | |
width: '2', | |
zIndex: 2 // To not get stuck below the regular plot lines | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment