本文介绍了离线3D互动饼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制一个3d交互式饼图。首先,我使用Google图表,但不幸的是,这无法离线使用。我使用了jpgraph,jscharts和rgraph中的图表,但没有达到我想要的效果。我想要一个必须免费的图表,可以离线使用,并且外观与Google图表大致相同。有什么建议吗?
预先感谢!

I want to constract a 3d interactive pie chart. Firstly I use google charts but unfortunately this doesn't work offline. I used charts from jpgraph, jscharts and rgraph but doesn't have the effect that I want. I want a graph which must be free, work offline and has approximately the same appearance with google graph. Any advice?Thanks in advance!

重要的是我想使用数据库中的结果。我写了这段代码,但是不起作用:

Important I want to use results from my db. I write this code but dont work:

data: [{
            name: 'Present',
            y: <?php 
              while( $row2 = mysql_fetch_assoc($res2)){

                echo $row2["COUNT(*)"];



                }
        }, {
            name: 'absentees',
            y: <?php 
              while( $row1 = mysql_fetch_assoc($res1)){

                echo $row1["COUNT(*)"];



                }

我有这些查询:

SELECT COUNT(*) 
FROM staff s, work w, absence a 
WHERE s.id=a.id_staff 
AND s.id_work=w.id 
AND w.name='sales manager' 
AND a.name='disease'

SELECT COUNT(*) 
    FROM staff s, work w, absence a 
    WHERE s.id=a.id_staff 
    AND s.id_work=w.id 
    AND w.name='sales manager'
    AND a.name='vacation'

我尝试了这个,但是无效

I try this but doesnt work

    series: [{
        type: 'pie',
        name: 'Absent',
        data: [
            ['Absent Illness',  <?php





                   while( $row1 = mysql_fetch_assoc($res1)){
                     while( $row2 = mysql_fetch_assoc($res2)){
                    $row['COUNT(*)']=$row2['COUNT(*)'] - $row1['COUNT(*)'];
                    echo $row["COUNT(*)"];


                    }
                    }
                    ?>],
            ['Absent Vacation', 
            <?php

                   while( $row1 = mysql_fetch_assoc($res1)){


                    echo $row1["COUNT(*)"];


                    }
                    ?>]



        ]
    }]
});                                         


推荐答案

让我指导如何在饼图上显示mysql结果。

函数functionname(){
$ .ajax({
url:'POST API LINK',
type:'GET',
dataType:'json',
成功:function(data){
var chart = new CanvasJS.Chart( chartContainer,{
title:{
文字:一个合适的标题
},
animationEnabled:true,
zoomEnabled:false,
data:[{
type: pie,
dataPoints:[{{
y:data.active,
indexLabel:活动部件= + data.active
},{
y:data.Inactive,
indexLabel: 无效的部分= + data.Inactive
},
]
}]
});
chart.render();
},
错误:function(){
警报(很抱歉!饼形图中的内容出了错);
}
});
}

Let me guide to display mysql results onto the pie chart. function functionname() { $.ajax({ url : 'POST API LINK', type : 'GET', dataType : 'json', success : function(data) { var chart = new CanvasJS.Chart("chartContainer", { title : { text : "A suitable title" }, animationEnabled : true, zoomEnabled : false, data : [ { type : "pie", dataPoints : [ { y : data.active, indexLabel : "Active part=" + data.active }, { y : data.Inactive, indexLabel : "Inactive part=" + data.Inactive }, ] } ] }); chart.render(); }, error : function() { alert('sorry!Somthing went wrong in Pie chart'); } }); }

这是显示MySQL结果的方式。

在这里,在数据中,我正在从数据库中获取活动值和非活动值。

This is how you display MySQL results.
Here In data,I am getting active and inactive value from my DB.

对于UI,请检查此。

如果您有任何疑问,请告诉我。

For the UI, Please check this fiddle link.
Kindly let me know if you have any queries.

这篇关于离线3D互动饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 00:55