2016-11-05 4 views
0

現在、横棒グラフの幅を作成できません。現在の問題は、obj.sightingCountbuildGraph関数の幅として使用できるように、私の ""と ""をどのように配置すべきか分かりません。グラフのJavascript/Jqueryの幅

CSS:

div.bar { 
     display: inline-block; 
     text-align: right; 
     padding-right: 5px; 
     background-color: blue;    
     } 
    div.year { 
     display: inline-block; 
    } 

jQueryの/ JavaScriptの

$.ajax({ 
     url: "api/UFOSightings", 
     method: "GET", 
     timeout: 10000,    
     success: buildGraph, 
     error: myError 
    }); 


    function myError(data) { 
    } 

    function buildGraph(data) { 
     $.each(data, function (index, obj) { 
      $('#graph').append('<div><div class="year">' + obj.sightingYear + '</div><div class="bar" style= width: "obj.sightingCount%;" >' + obj.sightingCount + '</div></div>'); 
     })} 

答えて

0

私はこれがあなたのために

function buildGraph(data) { 
    $.each(data, function (index, obj) { 
     $('#graph').append('<div><div class="year">' + obj.sightingYear + '</div><div class="bar" style="width:'+ obj.sightingCount + '%;" >' + obj.sightingCount + '</div></div>'); 
    }); 
} 
+0

を働くかもしれないと思うがどうもありがとうございました:) – SpatZan

関連する問題