gpt4 book ai didi

javascript - 在图表标签中显示计算的百分比

转载 作者:行者123 更新时间:2023-11-30 11:24:35 26 4
gpt4 key购买 nike

下面的代码呈现带有标签和适当值的 charist 图表我想将计算的百分比附加到每个标签即

  • 一个 (5.55%)
  • 两个 (16.66%)
  • 三个 (27.77%)
  • 四 (50.00%)

c_labels = ["one", "two", "three", "four"];
c_series = [10, 30, 50, 90];
options = {}

new Chartist.Pie('.ct-chart', {
labels: c_labels,
series: c_series,
}, options);
<script src="https://cdn.jsdelivr.net/chartist.js/latest/chartist.min.js"></script>
<link href="https://cdn.jsdelivr.net/chartist.js/latest/chartist.min.css" rel="stylesheet" />

<div class="ct-chart ct-perfect-fourth"></div>

最佳答案

您的代码有很多错误。它需要如下所示正确

var c_labels = ["one", "two", "three", "four"];
var c_series = [5.55, 16.66, 27.77, 50];

var options = {
width: 300,
height: 200
};


new Chartist.Bar('.ct-chart', {
labels: c_labels,
series: [c_series]
}, options);
<script src="https://cdn.jsdelivr.net/chartist.js/latest/chartist.min.js"></script>
<link href="https://cdn.jsdelivr.net/chartist.js/latest/chartist.min.css" rel="stylesheet" />

<div class="ct-chart ct-perfect-fourth"></div>

关于javascript - 在图表标签中显示计算的百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48496732/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com