gpt4 book ai didi

Javascript Pie Ch

转载 作者:行者123 更新时间:2023-11-28 17:04:41 24 4
gpt4 key购买 nike

我正在尝试从这里自定义一个饼图: https://canvasjs.com/jquery-charts/pie-chart-index-data-label-inside/

我使用的代码如下,经过我的编辑:

<script type="text/javascript">
window.onload = function() {

var options = {
exportEnabled: true,
animationEnabled: true,
title:{
text: "Operational Excellence"
},
data: [{
type: "pie",
showInLegend: false,
indexLabel: "{name}",
indexLabelPlacement: "inside",
dataPoints: [
{ y: 16.66666666666667, name: "Innovation" },
{ y: 16.66666666666667, name: "Leadership <br> Behaviours" },
{ y: 16.66666666666667, name: "Continuous Improvement" },
{ y: 16.66666666666667, name: "Employee Engagement" },
{ y: 16.66666666666667, name: "Exceed Customer Expectations"},
{ y: 16.66666666666667, name: "High Reliability" }
]
}]
};
$("#chartContainer").CanvasJSChart(options);

}
</script>

<div id="chartContainer" style="height: 100%; width: 100%;"></div>
<script type="text/javascript" src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script>

我想让它看起来像这样: https://static1.squarespace.com/static/56683787841abadb3a833983/t/5aad434c88251b56303ee2b4/1521304417200/chart.jpg?format=1000w

我如何在数据点中插入一个 html 中断“< b r >”,周围是否有一个图表库可以像上图那样做?

感谢大家的帮助。

最佳答案

HTML 标签在 indexLabels 中不受支持截至目前。但是你可以使用 indexLabelMaxWidth实现相同。请检查下面的代码。

var options = {
exportEnabled: true,
animationEnabled: true,
title:{
text: "Operational Excellence"
},
data: [{
type: "pie",
showInLegend: false,
indexLabel: "{name}",
indexLabelMaxWidth: 100,
indexLabelPlacement: "inside",
dataPoints: [
{ y: 16.66666666666667, name: "Innovation" },
{ y: 16.66666666666667, name: "Leadership Behaviours" },
{ y: 16.66666666666667, name: "Continuous Improvement" },
{ y: 16.66666666666667, name: "Employee Engagement" },
{ y: 16.66666666666667, name: "Exceed Customer Expectations"},
{ y: 16.66666666666667, name: "High Reliability" }
]
}]
};

$("#chartContainer").CanvasJSChart(options);
<script type="text/javascript" src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>  
<script type="text/javascript" src="https://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script>
<div id="chartContainer" style="height: 360px; width: 100%;"></div>

关于Javascript Pie Ch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50437534/

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