I imagine you want to pass dates in highcharts and update your graph. if this is the example here:
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
series: [{
name : "mantequila",
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
$('#button').click(function() {
//validamos las fechass
var fecha_inicio = $('#inicio').val();
var fecha_fin = $('#fin').val();
$.ajax({
url: "https://jsonplaceholder.typicode.com/posts/",
method: "GET",
data: { fecha_inicio: fecha_inicio, fecha_fin: fecha_fin }
}).done(function(data) {
/* en mi caso esta en duro pero si recibes los valores deberian ser todos
as series por tanto deberia ser algo como
chart.serie = data.serie*/
chart.series[0].setData([129.2, 144.0, 176.0, 135.6,
148.5, 216.4, 194.1, 95.6,
54.4, 29.9, 71.5, 106.4] );
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
fecha inicio<input type="text" id="inicio" name="inicio"/>
fecha fin <input type="text" id="fin" name="fin"/>
<button id="button">Agregar Fecha</button>
$('#button').click(function() {
//validamos las fechass
var fecha_inicio = $('#inicio').val();
var fecha_fin = $('#fin').val();
$.ajax({
url: "https://jsonplaceholder.typicode.com/posts/",
method: "GET",
data: { fecha_inicio: fecha_inicio, fecha_fin: fecha_fin }
}).done(function(data) {
/* en mi caso esta en duro pero si recibes los valores deberian ser todos
as series por tanto deberia ser algo como
chart.serie = data.serie*/
chart.series[0].setData([129.2, 144.0, 176.0, 135.6,
148.5, 216.4, 194.1, 95.6,
54.4, 29.9, 71.5, 106.4] );
});
});
});
link
if you want to refresh in wordpres through your code is the following (I have not tried it just by logic):
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<input type="date" name="fechaini" style="width: 50%; display: inline-block;"><input type="date" name="fechafin" style="width: 50%; display: inline-block;">
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto;"></div>
<?php
$fecha_inicio = isset($_GET['fecha_inicio']) ? $_GET['fecha_inicio'] : '2017-05-28'
$fecha_fin = isset($_GET['fecha_fin']) ? $_GET['fecha_fin'] : '2017-06-01'
?>
<script>
[insert_php]
$fecha_inicio = isset($_GET['fecha_inicio']) ? $_GET['fecha_inicio'] : '2017-05-28'
$fecha_fin = isset($_GET['fecha_fin']) ? $_GET['fecha_fin'] : '2017-06-01'
global $wpdb;
$arregloDatos = [];
//parametro1
$arregloDatos[] = $wpdb->query( "SELECT * FROM nombre_de_tabla WHERE nombre_campo LIKE '%parametro1%'AND fecha_created BETWEEN '$fecha_inicio' AND '$fecha_fin'" );
//parametro2
$arregloDatos[] = $wpdb->query( "SELECT * FROM nombre_de_tabla WHERE nombre_campo LIKE '%parametro2%'AND fecha_created BETWEEN '$fecha_inicio' AND '$fecha_fin'" );
//parametro3
$arregloDatos[] = $wpdb->query( "SELECT * FROM nombre_de_tabla WHERE nombre_campo LIKE '%parametro3%'AND fecha_created BETWEEN '$fecha_inicio' AND '$fecha_fin'" );
//parametro4
$arregloDatos[] = $wpdb->query( "SELECT * FROM nombre_de_tabla WHERE nombre_campo LIKE '%parametro4%'AND fecha_created BETWEEN '$fecha_inicio' AND '$fecha_fin'");
//parametro5
$arregloDatos[]= $wpdb->query( "SELECT * FROM nombre_de_tabla WHERE nombre_campo LIKE '%parametro5%' AND fecha_created BETWEEN '$fecha_inicio' AND '$fecha_fin'" );
//arreglo a cadena separados por comas
$totalGrafico = implode(",", $arregloDatos);
[/insert_php]
$(function () {
$('#container').highcharts({
title: {
text: 'Titulo',
x: -20 //center
},
subtitle: {
text: 'Subtitulo',
x: -20
},
xAxis: {
categories: ['parametro1', 'parametro2', 'parametro3', 'parametro4', 'parametro5']
},
yAxis: {
title: {
text: 'Cantidad'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: ''
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
name: 'nombre_serie',
data: [
[insert_php]
echo $totalGrafico;
[/insert_php]
]
}]
});
});
</script>
<form method="GET" action="miURL">
fecha inicio<input type="text" id="fecha_inicio" name="fecha_inicio"/>
fecha fin <input type="text" id="fecha_fin" name="fecha_fin"/>
<input type="submit">cambiar fecha</button>
</form>