here i want to generate a graph using highchrats library.my graph is spline with column chart (combo chart).but my graph not generate with my code.so please check my code where is i am wrong.i think i am wrong in jason code..but i have a little bit knowledge in json .so it creates problem for me .how to call json code .and generate a graph ,,i want my graph will be like this .[link] http://jsfiddle.net/sunman/FR7md/1/ but it is not shows like this shows me blank.i had tried last 4 days.so
This is my index.php .
$(function () {
var chart;
$(document).ready(function() {
$('#container').highcharts({
chart: {
zoomType: 'xy'
},
title: {
text: 'Project faclityv Rating'
},
subtitle: {
text: 'testing'
},
xAxis: [{
categories: []
}],
yAxis: [{ // Primary yAxis
labels: {
// format: '{value} Rs.',
style: {
color: Highcharts.getOptions().colors[1]
}
},
title: {
text: 'Bsp Cost',
style: {
color: Highcharts.getOptions().colors[1]
}
}
}, { // Secondary yAxis
title: {
text: 'facility rating',
style: {
color: Highcharts.getOptions().colors[0]
}
},
labels: {
//format: '{value} out of 100',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}],
tooltip: {
shared: true
},
legend: {
layout: 'vertical',
align: 'left',
x: 120,
verticalAlign: 'top',
y: 100,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
series: [{
name: 'Facility Rating',
type: 'column',
yAxis: 1,
data: [],
tooltip: {
valueSuffix: ' out of 100'
}
}, {
name: 'Bsp Cost',
type: 'spline',
data: [],
tooltip: {
valueSuffix: 'Rs.'
}
}]
});
$.getJSON("data.php", function(json) {
options.xAxis.categories = json[0]['data'];
options.series[0] = json[1];
options.series[1] = json[2];
chart = new Highcharts.Chart(options);
});
});
});
This is my data.php.where i wrote my mysql query . i want in line chart shows the bsp cost that comes from 2nd query.and in column chart shows facilities total .with respective project.
<?php
include "connection.php";
$query1 = mysql_query("SELECT projects_detail.Project_name ,facility_rating.facilities_total
FROM projects_detail LEFT OUTER JOIN facility_rating
ON projects_detail.project_id= facility_rating.project_id
ORDER BY facility_rating.facilities_total ASC LIMIT 0,15");
$category = array();
$category['name'] = 'Project';
//$series1 = array();
//$series1['name'] = 'Facilities Rating';
while($row1 = mysql_fetch_array($query1)) {
$category['data'][] = $row1['Project_name'];
// $series1['data'][] = $row1['facilities_total'];
}
$query2 = mysql_query("SELECT projects_detail.Project_name,facility_rating.facilities_total,cost.bsp
FROM projects_detail LEFT OUTER JOIN facility_rating
ON projects_detail.project_id= rfacility_rating.project_id
LEFT OUTER JOIN cost ON facility_rating.project_id=cost.project_id
ORDER BY facility_rating.facilities_total ASC LIMIT 0,15");
//$category = array();
//$category['name'] = 'Project';
$series1 = array();
$series1['name'] = 'facility rating';
$series2 = array();
$series2['name'] = 'BSP VALUES';
while($row2 = mysql_fetch_array($query2)) {
//$category['data'][] = $row2['Project_name'];
$series1['data'][] = $row2['facilities_total'];
$series2['data'][] = $row2['bsp'];
}
$result = array();
array_push($result,$category);
//array_push($result,$series1);
array_push($result,$series1);
array_push($result,$series2);
print json_encode($result, JSON_NUMERIC_CHECK);
//print json_encode($result2, JSON_NUMERIC_CHECK);
?>