2016-05-16 17 views
-7

に配列JSONコードにjavascript配列ん:どのように私はループループに私が欲しいJSONコード

$(function() { 
      var i = tabdate.length; 
    $('#daily').highcharts({ 
     chart: { 
       type: 'area' 
      }, 
      title: { 
       text: 'Statistiques journalières' 
      }, 
      subtitle: { 
       text: '' 
      }, 
     xAxis: { 
      type: 'datetime', 
      dateTimeLabelFormats: { // don't display the dummy year 
       month: '%e. %b', 
       year: '%b' 
      }, 
      title: { 
       text: 'Date' 
      } 
     }, 
     yAxis: { 
      title: { 
       text: 'Snow depth (m)' 
      }, 
      min: 0 
     }, 
     tooltip: { 
      headerFormat: '<b>{series.name}</b><br>', 
      pointFormat: '{point.x:%e. %b}: {point.y:.2f} m' 
     }, 

     plotOptions: { 
      spline: { 
       marker: { 
        enabled: true 
       } 
      } 
     }, 

     series: [{ 
      name: 'Winter 2013-2014', 
      data: [ 
       HERE 
      ] 
     }] 
    }); 
}); 

iは、このJSONコードにループに私の2つのjavascript配列をしたいが、私は知りませんどうやってするの。 2つのJavaScript配列をこのJSONコードにループしたいのですが、どうやってそれを行うのか分かりません。 2つのJavaScript配列をこのJSONコードにループしたいのですが、どうやってそれを行うのか分かりません。ありがとう。

+3

可能な複製(http://stackoverflow.com/questions/2001449/is-it-valid-to-define-functions-in-json-結果) –

+0

トピックを変更しました:p –

+0

2つの配列のデータで 'series'値を設定します。あれは正しいですか?入力配列はどのように見えますか?結果はどのように見えますか? – apsillers

答えて

-1

オブジェクトを作成する前に配列を作成し、その変数を使用します。

$(function() { 
    var i = tabdate.length; 
    var seriesData = []; 
    while (i > 0) { 
     seriesData.push([tabdate[i], tabnumber[i]]); 
    } 
    $('#daily').highcharts({ 
     chart: { 
       type: 'area' 
      }, 
      title: { 
       text: 'Statistiques journalières' 
      }, 
      subtitle: { 
       text: '' 
      }, 
     xAxis: { 
      type: 'datetime', 
      dateTimeLabelFormats: { // don't display the dummy year 
       month: '%e. %b', 
       year: '%b' 
      }, 
      title: { 
       text: 'Date' 
      } 
     }, 
     yAxis: { 
      title: { 
       text: 'Snow depth (m)' 
      }, 
      min: 0 
     }, 
     tooltip: { 
      headerFormat: '<b>{series.name}</b><br>', 
      pointFormat: '{point.x:%e. %b}: {point.y:.2f} m' 
     }, 

     plotOptions: { 
      spline: { 
       marker: { 
        enabled: true 
       } 
      } 
     }, 

     series: [{ 
      name: 'Winter 2013-2014', 
      data: seriesData 
     }] 
    }); 
}); 
[それが有効なJSONの結果で関数を定義することですか?]の
+0

thaaaaaaaaaaaanks!私はJSONコードですか?私はそれをあなたのおかげで使ったことはありません。 :) –

関連する問題