Created
September 22, 2018 19:59
-
-
Save Punkoivan/1c9d76f002e860985dad80f55ea4787e to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<body> | |
// Load jQuery | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
// Load google charts loader | |
<script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'></script> | |
// Chart script, function build. values - array. | |
<script type='text/javascript'> | |
function build(values) { | |
console.log(values); | |
google.charts.load('current', {'packages':['annotatedtimeline']}); | |
google.charts.setOnLoadCallback(drawHashrate); | |
// passing values to draw function | |
function drawHashrate(values) { | |
var data = new google.visualization.DataTable(); | |
data.addColumn('date', 'Date'); | |
data.addColumn('number', 'Hashrate'); | |
var tmp = [values] | |
data.addRows([tmp]); | |
var chart = new google.visualization.AnnotationChart(document.getElementById('hashrateChart')); | |
chart.draw(data, {displayAnnotations: true, displayExactValues: true, dateFormat: 'HH:mm MMMM dd, yyyy'}); | |
} | |
drawHashrate(); | |
} | |
</script> | |
<h2>JavaScript Functions</h2> | |
// CLick button and execute function build, parameters -> into values (line 10) | |
<button onclick = "build([[new Date('2011-06-12'), 5], [new Date('2011-06-13'), 10]])"> | |
do smth | |
</button> | |
<p id="demo"></p> | |
<div id="hashrateChart"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment