如何从高清图中的列和样条图表中提取php和mysql中的数据

时间:2014-04-24 10:02:13

标签: php mysql json highcharts

我尝试使用spline highchart创建列的组合图表。我希望这种类型的图表来自highcharts [link] http://jsfiddle.net/sunman/dwyNz/8/。但这里是我的问题是我想显示我的动态数据样条和柱形图来自data.php使用json进行数据检索。但我的图表不会像[link] http://jsfiddle.net/sunman/dwyNz/8/那样正确显示。

我希望这种类型的图表通过我的代码。在样条线上我想显示' bsp值'从query1和柱形图我想要设施评级。这是我的代码,我通过json提取数据: -

data.php

   $query1 = mysql_query("SELECT projects_detail.Project_name,superfac_rating.faci_total 
 FROM projects_detail LEFT OUTER JOIN superfac_rating 
 ON projects_detail.project_id= superfac_rating.project_id ");

   $category = array();
    $category['name'] = 'Project';


  while($row1 = mysql_fetch_array($query1)) {
   $category['data'][] = $row1['Project_name'];
  $series1['data'][] = $row1['faci_total'];
 }

    $query2 = mysql_query("SELECT projects_detail.Project_name,superfac_rating.faci_total 
    FROM projects_detail LEFT OUTER JOIN superfac_rating 
   ON projects_detail.project_id= superfac_rating.project_id
   LEFT OUTER JOIN cost ON gsuperfac_rating.project_id=cost.project_id  ");

  $series1 = array();
  $series1['name'] = 'Project Name';
  $series2 = array();
  $series2['name'] = 'BSP VALUES';

  while($row2 = mysql_fetch_array($query2)) {
   $series1['data'][] = $row2['faci_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);

我在这里设计图表:

       $(function () {
        var chart;
        $(document).ready(function() {
         $.getJSON("data.php", function(json) {
       $('#container').highcharts({
        chart: {
            zoomType: 'xy'
        },
        title: {
            text: 'Project facility 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: json
    });
      });
       });
        }); 

告诉我为什么我的json代码没有创建图表..

0 个答案:

没有答案