Skip to content

Instantly share code, notes, and snippets.

@oakley808
Created February 5, 2018 05:22
Show Gist options
  • Save oakley808/bacb360bc22b891248980be9846e3c66 to your computer and use it in GitHub Desktop.
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.)
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