2

使用简易饼图,我试图用 JSON 中的值更改属性数据百分比的值,但是使用我通常在 jQuery (3.5.1) 中执行的方式,在这种情况下不起作用,我不知道为什么.

我试图设置数据百分比的 DIV 是:

<div class="chart easy-pie-chart-1" id="ConversionCostPercentage" data-percent="">
  <span class="percent1"></span>
</div>

我尝试使用以下值设置的 jQuery:

$('#ConversionCostPercentage').attr('data-percent', thejson.ConversionCostPercentage);

$('#ConversionCostPercentage').data('percent', thejson.ConversionCostPercentage);

目前执行 console.log(thejson.ConversionCostPercentage) 返回 55 .. 有人知道吗?

4

1 回答 1

1

在@RoryMacCrossan 的一点推动下,我被允许朝着正确的方向解决它。我去了 Easy Pie Chart GitHub 站点并查看了文档,发现了 3 个小的 jQuery 示例(https://github.com/rendro /easy-pie-chart#jquery-1)导致使用以下内容,修复了它:

$('.chart').data('easyPieChart').update(thejson.ConversionCostPercentage); 
于 2021-06-16T21:01:44.800 回答