I am using HighCharts.
$(function ()
{
var chart;
$(document).ready(function ()
{
$.getJSON("json/PowerCurve.php", function (json)
{
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'xy'
},
title: {
text: 'Power Curve'
},
subtitle: {
text: 'Source: .wsd SCADA File'
},
xAxis: {
title: {
enabled: true,
text: 'wind speed [m/s]'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true,
min: 0
},
yAxis: {
title: { text: 'Power [kW]' },
min: 0
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
backgroundColor: '#FFFFFF',
borderWidth: 1
},
plotOptions: {
scatter: {
marker: {
radius: 1,
states: {
hover: {
enabled: false,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x} m/s, {point.y} kW'
}
}
},
series: [{
type: 'scatter',
name: 'WEC Power Curve',
color: 'rgba(46, 138, 138, 1)',
data: json[0]
}, {
type: 'line',
lineWidth: 1,
dashStyle: 'solid',
name: 'Power Curve',
color: 'rgba(195, 59, 69, 1)',
data: json[1]
}],
credits: { enabled: false }
});
This is my php file:
<?php
$con = mysql_connect("localhost","r","admin");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("scada", $con);
$query1 = mysql_query("SELECT avgwind, avgpower FROM tblwsd ORDER BY avgwind, avgpower ASC;");
$query2 = mysql_query("SELECT wind, `E-82` FROM tblpowercurve ORDER BY wind, `E-82` ASC;");
$serie1 = array();
$serie2 = array();
while($r = mysql_fetch_array($query1)) {
$avgwind = $r['avgwind'];
$avgpower = $r['avgpower'];
$serie1[] = array($avgwind, $avgpower);
}
while($r = mysql_fetch_array($query2)) {
$avgwind = $r['wind'];
$avgpower = $r['E-82'];
$serie2[] = array($avgwind, $avgpower);
}
$result = array();
array_push($result,$category);
echo json_encode(array($serie1, $serie2), JSON_NUMERIC_CHECK);
mysql_close($con);
?>
This is working as expected. I want to call the json file with some user inputs to use on the query. How can I do this?
like:
$.getJSON("json/PowerCurve.php?USERINPUT?USERINPUT", function (json)