Highcharts 实现数据库的帕累托图显示的问题。

skynux 发布于 2012/12/21 09:39
阅读 900
收藏 0

求教高手:

做了一个网页的数据看板,纯HTML格式,实现从MS SQL数据库提取数据显示到Highcharts,2级显示,参考例子column-drilldown。问X和Y轴的数据如何从数据库获得。

数据库连接代码如下:

===========

var objdbConn = new ActiveXObject("ADODB.Connection");
var strdsn = "DSN=TEST;UID=***;PWD=XXX;DATABASE=Data";
objdbConn.Open(strdsn);

var objrsX = objdbConn.Execute("SELECT X FROM ***" ); // X轴坐标名称

var objrsY = objdbConn.Execute("SELECT Y FROM  ** " ); // Y轴显示数据

var objrsX_X = objdbConn.Execute("SELECT X FROM ***" ); // 下级X轴坐标名称

var objrsY_Y = objdbConn.Execute("SELECT Y FROM  ** " ); // 下级Y轴显示数据

===========

Highcharts部分参考子column-drilldown,但是X和Y怎么改成取得objrsX和objrsY的值啊?

 var colors = Highcharts.getOptions().colors,
           categories = ['MSIE', 'Firefox', 'Chrome', 'Safari', 'Opera'],    //如何改为从数据库获得的objrsX?
            name = 'Browser brands',
            data = [{
                    y: 55.11,      ////如何改为从数据库获得的objrsY

                    color: colors[0],
                    drilldown: {
                        name: 'MSIE versions',
                        categories: ['MSIE 6.0', 'MSIE 7.0', 'MSIE 8.0', 'MSIE 9.0'],  ////如何改为从数据库获得的objrsX_X
                        data: [10.85, 7.35, 33.06, 2.81],  //如何改为从数据库获得的objrsY_Y
                        color: colors[0]
                    }
                }, {
                    y: 21.63,    ////如何改为从数据库获得的objrsY?
                    color: colors[1],
                    drilldown: {
                        name: 'Firefox versions',
                        categories: ['Firefox 2.0', 'Firefox 3.0', 'Firefox 3.5', 'Firefox 3.6', 'Firefox 4.0'],
                        data: [0.20, 0.83, 1.58, 13.12, 5.43],
                        color: colors[1]
                    }
                }, {
                    y: 11.94,
                    color: colors[2],
                    drilldown: {
                        name: 'Chrome versions',
                        categories: ['Chrome 5.0', 'Chrome 6.0', 'Chrome 7.0', 'Chrome 8.0', 'Chrome 9.0',
                            'Chrome 10.0', 'Chrome 11.0', 'Chrome 12.0'],
                        data: [0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22],
                        color: colors[2]
                    }
                }, {
                    y: 7.15,
                    color: colors[3],
                    drilldown: {
                        name: 'Safari versions',
                        categories: ['Safari 5.0', 'Safari 4.0', 'Safari Win 5.0', 'Safari 4.1', 'Safari/Maxthon',
                            'Safari 3.1', 'Safari 4.1'],
                        data: [4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14],
                        color: colors[3]
                    }
                }, {
                    y: 2.14,
                    color: colors[4],
                    drilldown: {
                        name: 'Opera versions',
                        categories: ['Opera 9.x', 'Opera 10.x', 'Opera 11.x'],
                        data: [ 0.12, 0.37, 1.65],
                        color: colors[4]
                    }
                }];

 ==============

谢谢。

加载中
返回顶部
顶部