Javascript 当我使用justgage插件动态创建仪表时,值不显示

Javascript 当我使用justgage插件动态创建仪表时,值不显示,javascript,jquery,ajax,gauge,justgage,Javascript,Jquery,Ajax,Gauge,Justgage,我正在尝试动态添加仪表,实际上它可以工作,但不符合预期的行为,显示图形,但值为0,即使图形显示的不是0,我的仪表将在onclick事件中显示。div和仪表是在ajax请求中创建的 function getLocationsGauge(row, countryId) { var chartsDataTemp; var requestData = { countryId: $("#hCountryName" + countryId).val() }; $("div").removeClass

我正在尝试动态添加仪表,实际上它可以工作,但不符合预期的行为,显示图形,但值为0,即使图形显示的不是0,我的仪表将在onclick事件中显示。div和仪表是在ajax请求中创建的

function getLocationsGauge(row, countryId) {
var chartsDataTemp;
var requestData = {
    countryId: $("#hCountryName" + countryId).val()
};
$("div").removeClass("blurELearning");
$("#gg" + countryId).addClass("blurELearning");

$.ajax({
    type: 'GET',
    dataType: 'json',
    contentType: 'application/json',
    url: '../XXX/GetLocations',
    async: false,
    data: requestData,
    success: function (chartsdata) {
        chartsDataTemp = chartsdata;
        $(".location").remove();
        $("#divLocations").remove();
        var count = chartsdata.length / 6;
        $('#countryGraphs  section:eq(' + (row) + ')').after('<div id="divLocations" class="card card-info"><div class="card-header"><strong class="header-block">' + $("#hCountryName" + countryId).val() + '</strong></div></div>');
        for (var i = 0; i <= count; i++) {
            $('#divLocations').append('<section id="location' + i + '" class="section location"><div id="rowLocation' + i + '" class="row"></div></section>');
            for (var j = i * 6; j < (i + 1) * 6; j++) {
                $('#rowLocation' + i).append('<div class="col-md-2"><div id= "ggLocation' + (j + 1) + '" ></div ></div >');
            }
        }

        for (var i = 0; i < chartsdata.length; i++) {

            var limit = Number(chartsdata[i].total) * 0.8;
            var total = Number(chartsdata[i].total);
            var approved = Number(chartsdata[i].approved);
            var name = chartsdata[i].location;
            var percentage = approved * 100 / total;
            percentage = parseFloat(Math.round(percentage * 100) / 100).toFixed(2)
            var x = "ggLocation" + (i + 1);
            objectsLocation[i] = new JustGage({
                id: x,
                value: approved,
                min: 0,
                max: total,
                gaugeWidthScale: 1,
                counter: true,
                hideInnerShadow: true,
                title: name + ' ' + percentage + '%',
                label: "approved",
                levelColors: ["#a9d70b", "#ffd6b6", "#fe9e50"],
                levelColorsGradient: true,
                pointer: true,
                pointerOptions: {
                    toplength: 1,
                    bottomlength: -40,
                    bottomwidth: 6,
                    color: '#8e8e93'
                }
            });

        }


    },
    complete: function () {

    },
    error: function () {
        alert("Error loading data for location! Please try again.");
    }
});}
函数getLocationsGauge(行,国家ID){ var ChartsDateMP; var请求数据={ countryId:$(“#hCountryName”+countryId).val() }; $(“div”).removeClass(“模糊学习”); $(“#gg”+countryId).addClass(“BluelLearning”); $.ajax({ 键入:“GET”, 数据类型:“json”, contentType:'应用程序/json', url:“../XXX/GetLocations”, async:false, 数据:请求数据, 成功:功能(chartsdata){ ChartsDateMP=chartsdata; $(“.location”).remove(); $(“#divLocations”).remove(); var计数=chartsdata.length/6; $(“#countryGraphs部分:eq(+(行)+”)。在(“”++$(“#hCountryName”+countryId).val()+””)之后;
对于(var i=0;i),经过大量努力,我决定直接用javascript修改html代码。 在for中创建对象(JustGage)后,我访问了包含文本的span对象并修改了值

var list = document.getElementById(x);   
var list2 = list.childNodes[0];
list2.childNodes[6].childNodes[0].innerHTML = approved;