Last active
January 24, 2017 12:08
-
-
Save nielslange/73ce0b96a8705081d54a2e628d84c3cb to your computer and use it in GitHub Desktop.
Create dynamic chart based on original nm and upgraded nm
This file contains 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
<?php | |
//* Load Google charts library | |
add_action( 'wp_enqueue_scripts', 'wp_enqueue_chiptuning_scripts' ); | |
function wp_enqueue_chiptuning_scripts( ) { | |
wp_enqueue_script( 'google-charts-script', 'https://www.gstatic.com/charts/loader.js' ); | |
} | |
//* Replace Genesis loop | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
add_action( 'genesis_loop', 'smntcs_genesis_do_loop' ); | |
function smntcs_genesis_do_loop() { | |
... | |
... | |
?> | |
<script type="text/javascript"> | |
google.charts.load('current', {'packages':['corechart']}); | |
google.charts.setOnLoadCallback(drawChart); | |
function drawChart() { | |
var data = google.visualization.arrayToDataTable([ | |
['', '', ''], | |
['', 0, 0], | |
['', <?php echo (get_field('original_nm') * 0.6); ?>, <?php echo (get_field('upgrade_nm') * 0.6); ?>], | |
['', <?php echo (get_field('original_nm') * 0.75); ?>, <?php echo (get_field('upgrade_nm') * 0.8); ?>], | |
['', <?php echo (get_field('original_nm') * 0.85); ?>, <?php echo (get_field('upgrade_nm') * 0.9); ?>], | |
['', <?php the_field('original_nm'); ?>, <?php the_field('upgrade_nm'); ?>], | |
['', <?php echo (get_field('original_nm') * 0.8); ?>, <?php echo (get_field('upgrade_nm') * 0.9); ?>], | |
['', <?php echo (get_field('original_nm') * 0.55); ?>, <?php echo (get_field('upgrade_nm') * 0.6); ?>], | |
['', <?php echo (get_field('original_nm') * 0.4); ?>, <?php echo (get_field('upgrade_nm') * 0.4); ?>], | |
]); | |
var options = { | |
title: 'Vermogensgrafiek naar chiptuning', | |
curveType: 'function', | |
legend: { position: 'none' } | |
}; | |
var chart = new google.visualization.LineChart(document.getElementById('curve_chart')); | |
chart.draw(data, options); | |
} | |
</script> | |
<?php | |
print('<div id="curve_chart" style="width: 100%; height: 300px;"></div>'); | |
... | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment