0

私のアプリケーションには、以下に示すコード スニペットがあります。私が達成しようとしているのはこれです。チェックボックスがクリックされるたびに、棒グラフが更新されます。

私のエラーコンソールで私は得ています:

「エラー: TypeError: 値が定義されていません ソース ファイル: hit.js 行: 11017.

JSON を関数 (var json = ...) に直接割り当てようとしましたが、正常に動作しますが、ファイルから JSON をロードしても動作しません。私は何を間違っていますか?

    $(':checkbox').click(function () {
   init();
     
   function init()
   {
       var request = new XMLHttpRequest( );
       request.open("GET", "GetGenes.php", false);
       request.send(null);
       var json = request.response;
       console.log(request.response);
    var barChart = new $jit.BarChart({
          //id of the visualization container
          injectInto: 'infovis',
          //whether to add animations
          animate: true,
          //horizontal or vertical barcharts
          orientation: 'horizontal',
          //bars separation
          barsOffset: 0.5,
          //visualization offset
          Margin: {
            top: 5,
            left: 5,
            right: 5,
            bottom: 5
          },
          //labels offset position
          labelOffset:5,
          //bars style
          type:'stacked',
          //whether to show the aggregation of the values
          showAggregates:true,
          //whether to show the labels for the bars
          showLabels:true,
          //label styles
          Label: {
            type: 'HTML', //Native or HTML
            size: 9,
            family: 'Arial',
            color: 'black'
          },
          //tooltip options
          Tips: {
            enable: true,
            onShow: function(tip, elem) {
              tip.innerHTML = "<b>" + elem.name + "</b>: " + elem.value;
            }
          }
        });
        
         barChart.loadJSON(json);
   }
     
      
   
})

Genes.php には以下が含まれます。

echo "{'label': ['label 1', 'label 2', 'label 3', 'label 4'],'values': [{'label': 'date A','values': [20, 40, 15, 5]}, {'label': 'date B','values': [30, 10, 45, 10]}, {'label': 'date E','values': [38, 20, 35, 17]}, {'label': 'date F','values': [58, 10, 35, 32]}, {'label''date D','values': [55, 60, 34, 38]}, {'label': 'date C','values': [26, 40, 25, 40]}]};";
4

1 に答える 1

1

返された JSON にエラーがあります:

「ラベル」「日付 D」

そこに行方不明のコロンがあります。それが何かを解決するかどうかはわかりません。

于 2013-01-15T23:51:17.573 に答える