2012-07-24 5 views
3

먼저 대답에 감사드립니다.JqPlot 1.0 날짜 축과 범례가있는 꺾은 선형 차트를 만드는 방법

여기 내 문제입니다. 나는 전설을 보여줄 필요가있는 JqPlot을 가진 선형 차트를 가지고있다. 그러나 시리즈 이름을 어떻게 바꿀 지 모른다. 어떻게해야합니까?

여기 내 코드입니다. 내가 정말로 원하는 무엇

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<script type="text/javascript" src="jquery.min.js"></script> 
<script type="text/javascript" src="jquery.jqplot.min.js"></script> 
<script type="text/javascript" src="plugins/jqplot.dateAxisRenderer.min.js"></script> 
<link rel="stylesheet" type="text/css" href="jquery.jqplot.css" /> 

<script type="text/javascript" language="javascript"> 
$(document).ready(function(){ 
    var line1=[['2008-06-30',4], ['2008-7-14',6.5], ['2008-7-28',5.7], ['2008-8-11',9],  ['2008-8-25',8.2]]; 
    var line2=[['2008-06-30',8], ['2008-7-14',5], ['2008-7-28',7], ['2008-8-11',2],  ['2008-8-25',2]]; 
    var plot2 = $.jqplot('conteneur', [line1,line2], { 
     title:'Customized Date Axis', 
     seriesDefaults: { 
      rendererOptions: { 
       ////// 
       // Turn on line smoothing. By default, a constrained cubic spline 
       // interpolation algorithm is used which will not overshoot or 
       // undershoot any data points. 
       ////// 
       smooth: true 
      } 
     }, 
      legend:{ show: true } , 
     axes:{ 
     xaxis:{ 
      renderer:$.jqplot.DateAxisRenderer, 
      tickOptions:{formatString:'%b %#d, %#I %p'}, 
      min:'June 16, 2008', 
       tickInterval:'1 month' 
     } 
     }, 
     series:[{lineWidth:4, markerOptions:{style:'square'}}] 
    }); 
}); 
</script> 

</head> 
<body> 

<div id="conteneur"></div> 

</body> 
</html> 

는 전설에서, 자신의 시리즈 이름 (예 : "클리블랜드"와 "토론토")에 의해 호출하는 "시리즈 1"과 "2 시리즈"입니다. 하지만 코드에 어디에 넣어야합니까?

감사합니다.

답변

5

당신은 추가해야합니다 :

series: [ 
       { label: 'Toronto' }, 
       { label: 'New York' } 
     ] 

이것은 전체 코드입니다 :

<script type="text/javascript" language="javascript"> 
$(document).ready(function() { 
    var line1 = [['2008-06-30', 4], ['2008-7-14', 6.5], ['2008-7-28', 5.7], ['2008-8-11', 9], ['2008-8-25', 8.2]]; 
    var line2 = [['2008-06-30', 8], ['2008-7-14', 5], ['2008-7-28', 7], ['2008-8-11', 2], ['2008-8-25', 2]]; 
    var plot2 = $.jqplot('conteneur', [line1, line2], { 
     title: 'Customized Date Axis', 
     seriesDefaults: { 
      rendererOptions: { 
       ////// 
       // Turn on line smoothing. By default, a constrained cubic spline 
       // interpolation algorithm is used which will not overshoot or 
       // undershoot any data points. 
       ////// 
       smooth: true 
      } 
     }, 
     legend: { show: true }, 
     axes: { 
      xaxis: { 
       renderer: $.jqplot.DateAxisRenderer, 
       tickOptions: { formatString: '%b %#d, %#I %p' }, 
       min: 'June 16, 2008', 
       tickInterval: '1 month' 
      } 
     }, 
     series: [{ lineWidth: 4, 
      markerOptions: { style: 'square' } 

     }], 
     series: [ 
       { label: 'Toronto' }, 
       { label: 'New York' } 
     ], 
    }); 
}); 

+0

감사합니다! 그것이 내가 생각했던 거죠! – m4dd

+0

도와 드리겠습니다. 이 대답을 수락하는 것을 잊지 마십시오. –

관련 문제