0
$.plot(elem, data, {
//
                        //
                        series : {
                            pie : {
                                show : true,
                                highlight : {
                                    opacity : 0.2
                                }
                            }
                        },
                        grid : {
                            hoverable : true,
                            clickable : true
                        },
                        colors : [ "#245779", "#85c441", "#e88b2f", "#bb43f2",
                                "#3073a0", "#9C2323", "#183b52", "#8cc7e0",
                                "#64b4d5", "#3ca0ca", "#2d83a6", "#22637e",
                                "#174356", "#0c242e" ]
                    // colors: [ "#b4dbeb", "#8cc7e0", "#64b4d5", "#3ca0ca",
                    // "#2d83a6", "#22637e", "#174356", "#0c242e" ]
                    });
                    // Create a tooltip on our chart
                    elem.qtip({
                        prerender : true,
                        content : 'Loading...', // Use a loading message
                        // primarily
                        position : {
                            viewport : $(window), // Keep it visible within
                            // the window if possible
                            target : 'mouse', // Position it in relation to
                            // the mouse
                            adjust : {
                                x : 7
                            }
                        // ...but adjust it a bit so it doesn't overlap it.
                        },
                        show : true, // We'll show it programatically, so no
                        // show event is needed
                        style : {
                            classes : 'ui-tooltip-shadow ui-tooltip-tipsy',
                            tip : false
                        // Remove the default tip.
                        }
                    });

                    // Bind the plot hover
                    elem
                            .on(
                                    'plothover',
                                    function(event, pos, obj) {

                                        // Grab the API reference
                                        var self = $(this), api = $(this)
                                                .qtip(), previousPoint, content,

                                        // Setup a visually pleasing rounding
                                        // function
                                        round = function(x) {
                                            return Math.round(x * 1000) / 1000;
                                        };

                                        // If we weren't passed the item object,
                                        // hide the tooltip and remove cached
                                        // point data
                                        if (!obj) {
                                            api.cache.point = false;
                                            return api.hide(event);
                                        }

                                        // Proceed only if the data point has
                                        // changed
                                        previousPoint = api.cache.point;
                                        if (previousPoint !== obj.seriesIndex) {
                                            percent = parseFloat(
                                                    obj.series.percent)
                                                    .toFixed(2);
                                            // Update the cached point data
                                            api.cache.point = obj.seriesIndex;
                                            // Setup new content
                                            content = obj.series.label + ' ( '
                                                    + percent + '% )';
                                            alert(content);
                                            // Update the tooltip content
                                            api.set('content.text', content);
                                            // Make sure we don't get problems
                                            // with animations
                                            // api.elements.tooltip.stop(1, 1);
                                            // Show the tooltip, passing the
                                            // coordinates
                                            api.show(pos);
                                        }
                                    });

                }
            });

以上是来自 gebo admin Charts 的带有 j 查询的函数

现在我想要的是在饼图的工具提示中显示数据值而不是百分比..我已经看了很多..但找不到任何东西..有人可以指导我吗?

以下来自上述函数的代码设置百分比,但我只想使用数据..而不是它的百分比......

(previousPoint !== obj.seriesIndex) {
                                                percent = parseFloat(
                                                        obj.series.percent)
                                                        .toFixed(2);
                                                // Update the cached point data
                                                api.cache.point = obj.seriesIndex;
                                                // Setup new content
                                                content = obj.series.label + ' ( '
                                                        + percent + '% )';
                                                alert(content);
                                                // Update the tooltip content
                                                api.set('content.text', content);
4

1 回答 1

0

好的,就这样……经过太多谷歌搜索,我成功了……

if (previousPoint !== obj.seriesIndex) {
                                            percent = parseFloat(
                                                    obj.series.percent)
                                                    .toFixed(2);
                                            // Update the cached point data
                                            api.cache.point = obj.seriesIndex;
                                            // Setup new content
                                            content = obj.series.label + ' ('
                                            + obj.series.data[0][1] + ')';

                                            // Update the tooltip content
                                            api.set('content.text', content);
                                            // Make sure we don't get problems
                                            // with animations
                                            // api.elements.tooltip.stop(1, 1);
                                            // Show the tooltip, passing the
                                            // coordinates
                                            api.show(pos);
                                        }

content = obj.series.label + ' ('
                                            + obj.series.data[0][1] + ')';

obj.series.data[0][1] 给了我数据点的值而不是百分比

于 2013-03-26T05:47:43.793 回答