gpt4 book ai didi

javascript - 如何使用 jquery Highcharts 在饼图中显示值而不是百分比

转载 作者:IT王子 更新时间:2023-10-29 03:09:13 25 4
gpt4 key购买 nike

对于我的一个项目,我正在使用由 jQuery Highcharts 制作的饼图。喜欢做的是显示我插入的值而不是出身。示例:图表显示 firefox - 43.269...% 而我喜欢显示 Firefox -45 次点击的值。谁能帮我这个。提前致谢。

图表代码

<!-- 1. Add these JavaScript inclusions in the head of your page -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="../js/highcharts.js"></script>

<!-- 1a) Optional: add a theme file -->
<!--
<script type="text/javascript" src="../js/themes/gray.js"></script>
-->

<!-- 1b) Optional: the exporting module -->
<script type="text/javascript" src="../js/modules/exporting.js"></script>


<!-- 2. Add the JavaScript to initialize the chart on document ready -->
<script type="text/javascript">

var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'browser_cart',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Browser market shares at a specific website, 2010'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' clicks';
}
}
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
['Firefox', 45],
['IE', 26],
['Chrome', 12],
['Safari', 8],
['Opera', 6],
['Others', 7]
]
}]
});
});

</script>

</head>
<body>

<!-- 3. Add the container -->
<div id="browser_cart" style="width: 800px; height: 400px; margin: 0 auto"></div>


</body>

最佳答案

已修复,只是在行下方进行了更改

  format: '<b>{point.name}</b>: {point.percentage:.1f} %',

  format: '<b>{point.name}</b>: {point.y:.1f} Rs.',

关于javascript - 如何使用 jquery Highcharts 在饼图中显示值而不是百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7952727/

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