gpt4 book ai didi

php - Highcharts 饼图切片错误

转载 作者:行者123 更新时间:2023-11-29 03:07:43 24 4
gpt4 key购买 nike

非常感谢您阅读本文,如果我的英语不是很好,我深表歉意。

好吧,我正在尝试制作 Highcharts 饼图,但标签没有出现,只有数字。我一直在寻找,但找不到答案,而且我是新手。

这是我的 data_2.php 文件:

<?php 

$con = mysql_connect("localhost","root","");

if (!$con) { die('Could not connect: ' . mysql_error()); }

mysql_select_db("pymesonline", $con);

$result = mysql_query("SELECT descripcion_p, sum(cantidad_vendida) FROM venta_producto GROUP BY descripcion_p");

while($row = mysql_fetch_array($result)) {
echo $row['descripcion_p'] . "\t" . $row['sum(cantidad_vendida)']. "\n"; }
mysql_close($con);

?>

这是我的脚本:

var a = jQuery.noConflict();
a(document).ready(function(){

var chart;
var options = {
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},

title: {
text: 'Productos Mas Vendidos',
x: -20 //center
},

subtitle: {
text: 'Historico',
x: -20
},


series: [{
type: 'pie',
name: 'Cantidad Vendida',

}]

}

jQuery.get('clases/data_2.php', null, function(tsv) {
var lines = [];
traffic = [];
try {
// split the data return into lines and parse them
tsv = tsv.split(/\n/g);
jQuery.each(tsv, function(i, line) {
line = line.split(/\t/);
date = Date.parse(line[0]);
traffic.push([
date,
parseInt(line[1].replace(',', ''), 10)
]);
});
} catch (e) { }
options.series[0].data = traffic;
chart = new Highcharts.Chart(options);
});
});

结果是这样的,我不知道哪里出了问题,一切正常,除了标签。我非常感谢您的帮助,非常感谢。

This is the Result

最佳答案

也许您需要添加一系列数据名称:

        options.series[0].data = traffic;
options.series[1].data = traffic1;
chart = new Highcharts.Chart(options);

并将一系列名称放入选项数组中:

    var options = {

series: [{
name: 'Saldo'
},{
name: 'Saldo1'
}]

关于php - Highcharts 饼图切片错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12886370/

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