2016-05-11 3 views
0

DataLoaderプラグインを使用してamchartsのDataProviderとしてオブジェクトにアクセスしようとしていますが、表示されません。ここに私のJSON出力は次のとおりです。JSONのデータフィールドとして、オブジェクトをamcharts内のデータローダーでロードする方法

{ 
    "ReportName":"This is the Report Name", 
    "Column-1":"This is the Report Name", 
    "Column-2":"This is the Report Name", 
    "Data":[ 
     {"Category":"Guntur","Column_1":"20.30","Column_2":"22.34"}, 
     {"Category":"Chittor","Column_1":"20.30","Column_2":"22.34"} 
    ]} 

これはAmchartのための私のスクリプトです:私は、JSONの出力を取得するためのURLを与えているURLタグで

AmCharts.makeChart("chartdiv", 
      { 
       "type": "serial", 
       "categoryField": "Category", 
       "columnWidth": 0.72, 
       "angle": 15, 
       "depth3D": 10, 
       "plotAreaFillAlphas": 0.01, 
       "startDuration": 1, 
       "fontFamily": "Lato", 
       "dataLoader": { 
        "url": "chartInformation", 
        "format": "json" 
        }, 
       "export": { 
        "enabled": true 
       }, 
       "categoryAxis": { 
        "autoRotateAngle": 0, 
        "gridPosition": "start", 
        "boldLabels": true, 
        "labelRotation": 25.2 
       }, 
       "chartScrollbar": { 
        "enabled": true 
       }, 
       "trendLines": [], 
       "graphs": [ 
        { 
         "balloonText": "[[category]] <br> [[title]] : [[value]]", 
         "fillAlphas": 1, 
         "id": "AmGraph-1", 
         "title": "Target", 
         "type": "column", 
         "valueField": "Column_1" 
        }, 
        { 
         "balloonText": "[[category]] <br> [[title]] : [[value]]", 
         "fillAlphas": 1, 
         "id": "AmGraph-2", 
         "title": "Achieved", 
         "type": "column", 
         "valueField": "Column_2" 
        } 
       ], 
       "guides": [], 
       "valueAxes": [ 
        { 
         "id": "ValueAxis-1", 
         "title": "Cost in Lakhs" 
        } 
       ], 
       "allLabels": [], 
       "balloon": { 
        "horizontalPadding": 12 
       }, 
       "legend": { 
        "enabled": true, 
        "backgroundAlpha": 0.01, 
        "rollOverGraphAlpha": 0, 
        "useGraphSettings": true 
       }, 
       "titles": [ 
        { 
         "id": "Title-1", 
         "size": 15, 
         "text": "Opening of PMJDY Accounts" 
        } 
       ] 
      } 
     ); 

。 グラフデータにデータオブジェクトを使用するにはどうすればよいですか?

ReportNameの他のデータを使用したいので、jsonのその他のデータが必要になります。

+0

「chartInformation」とは何ですか?それはあなたのURLパスですか? –

+0

urlの出力はJSON Stringです.iはトップに表示されます –

+0

"data"のように記述すると "url"の代わりに "chartInformation": "chartInformation"、 –

答えて

0

jsonデータを読み込んでデータ部分を書き戻すdataLoader postProcessをコーディングする必要があります。また、レポートのタイトル値の設定など、必要に応じてレポート名、列1と2の値に役立ちます。 https://www.amcharts.com/tutorials/using-data-loader-plugin/

"dataLoader": { 
        "url": "chartInformation", 
        "format": "json" 
        postProcess: function(data, options) { 
         // your code goes here to produce correct data etc 
         return data; 
        } 
        }, 
関連する問題