2012-09-18 3 views
0

데이터베이스의 데이터를 다른 파일에 에코했습니다. 이제 데이터를 가져옵니다. 나는 JQuery와 및 highchart 새로운 오전 .. PLZ 도움이 전달 내 데이터 형식은 다음과 같습니다highcharts-php/mysql 데이터 가져 오기

[ 
{"name":"a","data":0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]}, 
{"name":"b","data":[34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]} 
] 

highchart 내 코드는 다음과 같습니다

var chartOptions = { 
    chart: { 
     renderTo: 'container', 
     zoomType: 'x', 
     defaultSeriesType: 'line',   
     backgroundColor: null, 
     plotBackgroundColor: null, 
     borderRadius:20, 
     plotShadow: false, 
     events: { 
      load: function() { 
       // event.exporting.buttons.infoButton.symbolX=5; 
       // event.exporting.buttons.infoButton.symbolY=2; 
       // info_img=0; 
        // this.renderer.rect(5, 5, 60, 25, 15).attr({ fill: issue_col[1], zIndex: 0 }).add(); 
        } 
     }, 
     style: { 
      zIndex: 1 
       }, 
     marginRight:30 

    }, 
    title: { 
     text: 'hello', 
     style: { 
      fontFamily: 'Arial', 
      fontWeight: 'bold', 
      fontSize: '12px', 
      textShadow: 'none' 
       } 
    }, 
    xAxis: { 
     type:'datetime', 
     title: { 
     text: null 
       } 
    }, 
    yAxis: { 
     title: { 
     text: 'nothing is coming', 
      style: { 
      fontFamily: 'Arial', 
      fontWeight: 'bold', 
      fontSize: '12px', 
      textShadow: 'none' 
       } 
      }, 
     min: 0.0, 



    }, 
    credits: { 
     enabled: true, 
     position: { 
      align: 'center', 
      x: 10, 
      verticalAlign: 'bottom', 
      y: -3 
     }, 
     href: "http://www.interscapetech.com", 
     style: { 
      cursor: 'pointer', 
      color: '#909090', 
      fontSize: '9px' 
     }, 
     text: "(c)1997- Interscape Technologies Inc. All rights reserved." 
    }, 
    /*labels:{ 
     items: [{ 
      html: "TM", 
      style: { 
       fontSize:'8px', 
       left: '330px', 
       top: '140px' 
      } 
     }], 
     style: { 
      color: 'grey' 
      } 
    },*/ 
    lang:{ 
      downloadButtonTitle:'Download Chart', 
      printButtonTitle :'Print Chart', 
      infoButtonTitle:'Chart Information', 
      switchButtonTitle:'Click to Enlarge'   
    //  switchButtonTitle:'Switch to Bar Chart' 
     }, 

    navigation:{ 
     buttonOptions:{ 
      align:'right', 
      verticalAlign:'middle', 
      height:15, 
      symbolFill: '#4572A7', 
      hoverSymbolFill: '#768F3E', 
      hoverBorderColor:'#92A8CD', 
      borderColor:'#3D96AE', 
      backgroundColor:'white', 
      borderRadius:5, 
      borderWidth:2, 
      width:20, 
      symbolX:10, 
      symbolY:8, 
      symbolSize:10 
     } 
    }, 
    subtitle: { 
     text: '', 
     align:'left', 
     style: { 
      fontFamily: 'Arial', 
      fontWeight: 'bold', 
      fontSize: '12px', 
      textShadow: 'none', 
      color: 'white' 
       }, 
     x:3, //-165 if center 
     y:12 
    }, 
    plotOptions: { 
     line: { 
      lineWidth: 1, 
      marker: { 
       enabled: false, 
       states: { 
        hover: { 
        enabled: true, 
        radius: 5 
         } 
         } 

        }, 
      shadow: false, 
      states: { 
       hover: { 
        lineWidth: 1     
         } 
        }, 
      zindex:1 
      }, 
     series:[{ 
       zindex:1 
      }] 
    } 
    , 
    tooltip: { 
     formatter: function() { 
      var ctime= Highcharts.dateFormat('%m/%d/%Y %H:%M:%S',this.x); 
      var s = '<b>'+ ctime +'</b>'; 
      $.each(this.points, function(i, point) { 
       var result=Math.round(point.y*10)/10; 
       s += '<br/>'+ point.series.name +': '+result; 
      }); 
      return s; 
     }, 
     shared: true, 
     backgroundColor: '#FCFFC5' 
    }, 
    legend: { 
     itemStyle: { 
      fontFamily: 'Arial', 
      fontSize: '12px', 
      textShadow: 'none' 
       }, 
     enabled: true 
//  symbolPadding: 10 
    }, 
    series: [] 
    }; 

$(document).ready(function() 
    { 

     var url='highchars_test2.php'; 
alert('helo'); 

    $.getJSON(url, function(seriesData){ 

    $(seriesData).each(function(i, pdata){ 
    console.log(); 
       if(i==(seriesData.length-1) || i==(seriesData.length-2)) 
       {} 
       else 
       { 
        alert(pdata['data']); 
        chartOptions.series.push(pdata); 
       } 
      }); 
       chart = new Highcharts.Chart(chartOptions); 
    }); 
    }); 

차트를 만들 수 없습니다 .. PLZ 도움 ..

+0

그것은'var에 URL = 'highchars_test2.php'해야하지가
검사 작업,'대신 'var url = 'highchars_test2.php;'? 작은 따옴표가 누락 되었습니까? – shibly

+0

@shibly : 예 .. 똑같은 :-) .. 나는 또한 그걸로 .. 차트를 얻지 못했습니다. – mikelee

+0

[당신의 줄'{ "name": "a", "data": is it 실수 ? –

답변

1

시리즈 a와 비슷하게 데이터 배열 앞에 여는 대괄호가 없습니다. 데이터가 (브래킷의 누락을 여는)가 제대로 포맷되지 않은 일련의

+0

데이터 편집을 시도했지만 여전히 작동하지 않았습니다. 나는 if 루프를 바꿨다. .. 이제는 작동한다 .. Torsteing을 많이 고맙다. – mikelee