highchartsグラフィックレポート


パッケージされたhighchartsレポート
ここでdataResidenceAveragePriceとdataPropertyAveragePriceは、highchartsレポートに必要なデータであり、文字列形式でフォーマットされています.
例:

  
  
  
  
  1. "1992-12-12,50;1993-12-12,100;1994-11-11,80" 

containerId div id


  
  
  
  
  1. function DrawLineScatter(dataResidenceAveragePrice, dataPropertyAveragePrice,containerId) 
  2.  
  3.  
  4.     var chartResidenceAveragePrice = new Array(); 
  5.     var chartPropertyAveragePrice = new Array(); 
  6.      
  7.     var tmpResidenceAveragePrices = dataResidenceAveragePrice.split(';'); 
  8.     var tmpPropertyAveragePrices = dataPropertyAveragePrice.split(';'); 
  9.      
  10.     for(var i = 0; i < tmpResidenceAveragePrices.length - 1; i ++) 
  11.     {                
  12.         var tmpResidenceAveragePrice = tmpResidenceAveragePrices[i].split(','); 
  13.          
  14.         var info = new Array(); 
  15.         if(i==0){ 
  16.             this.weekDay=getWeekDay(tmpResidenceAveragePrice[0]); 
  17.         } 
  18.         info.push(getDate(tmpResidenceAveragePrice[0])); 
  19.         info.push(parseFloat(tmpResidenceAveragePrice[1])); 
  20.          
  21.         chartResidenceAveragePrice.push(info); 
  22.     } 
  23.  
  24.      
  25.  
  26.     for(var i = 0; i < tmpPropertyAveragePrices.length - 1; i ++) 
  27.     {                
  28.         var tmpPropertyAveragePrice = tmpPropertyAveragePrices[i].split(','); 
  29.          
  30.         var info = new Array(); 
  31.         info.push(getDate(tmpPropertyAveragePrice[0])); 
  32.         info.push(parseFloat(tmpPropertyAveragePrice[1])); 
  33.          
  34.         chartPropertyAveragePrice.push(info); 
  35.     } 
  36.  
  37.      
  38.  
  39.     var chart; 
  40.      
  41.     chart = new Highcharts.Chart({ 
  42.         chart: { 
  43.             renderTo: containerId 
  44.          
  45.         }, 
  46.         xAxis: {         
  47.              labels:{  
  48.                     step:chartResidenceAveragePrice.length/2 
  49.                 } , 
  50.              
  51.             type: 'datetime'
  52.  
  53.             dateTimeLabelFormats: { 
  54.  
  55.                 day: '%e of %b'   
  56.  
  57.             }, 
  58.              
  59.             //startOnTick: true, 
  60.             endOnTick: true
  61.             tickInterval:24 *7* 3600 * 1000, 
  62.             startOfWeek: this.weekDay, 
  63.             showLastLabel: true
  64.              
  65.              
  66.         }, 
  67.         yAxis: { 
  68.             min: 0, 
  69.             title: { 
  70.                 text: ' ( )' //
  71.             }, 
  72.             tickPixelInterval:30, 
  73.             startOnTick: false 
  74.         }, 
  75.         title: { 
  76.             text: '' 
  77.         },                   
  78.         series: [{ 
  79.             type: 'line'
  80.             name: ' ( )'
  81.             data: chartResidenceAveragePrice,    
  82.             pointStart: chartResidenceAveragePrice[0][0], 
  83.             pointInterval: 24 *7* 3600 * 1000 ,// seven day 
  84.               
  85.             marker: { 
  86.                 enabled: true 
  87.             }, 
  88.             states: { 
  89.                 hover: { 
  90.                     lineWidth: 0 
  91.                 } 
  92.             }, 
  93.             enableMouseTracking: true 
  94.         } 
  95.         , { 
  96.             type: 'scatter'
  97.             name: ' ( )'
  98.             data: chartPropertyAveragePrice,     
  99.             marker: { 
  100.                 radius: 10 
  101.             } 
  102.         }], 
  103.         exporting: { 
  104.                 enabled: false 
  105.             }    
  106.     }); 
  107.  
  108.  
  109. function getWeekDay(strDate){ 
  110.      var tmpDate = new Array(); 
  111.     tmpDate = strDate.split('-'); 
  112.      
  113.     var year = tmpDate[0]; 
  114.     var month = parseInt(tmpDate[1], 10) - 1; 
  115.  
  116.     var day = tmpDate[2]; 
  117.     
  118.      
  119.     return new Date(year,month,day).getDay(); 
  120.  
  121.  
  122.  
  123. function getDate(strDate) 
  124. {     
  125.     var tmpDate = new Array(); 
  126.     tmpDate = strDate.split('-'); 
  127.      
  128.     var year = tmpDate[0]; 
  129.     var month = parseInt(tmpDate[1], 10) - 1; 
  130.     var day = tmpDate[2]; 
  131.      
  132.     return Date.UTC(year, month, day);