English 中文(简体)
jQuery Flot - 缩放导致绘图缩小, 轴标签消失
原标题:jQuery flot - Zoom causes plot to shrink, axis labels to disappear
  • 时间:2012-05-24 01:07:08
  •  标签:
  • jquery
  • flot

我对 jQuery Flot 实施了某些缩放功能, 但效果不妙 。 缩放通过捕捉 Flot s “ plots selective” 事件来实施, 并使用“ 范围” 参数重新绘制, 以修改 xaxis 和 yexis 最大值和 分钟值 。

当最初绘制时, 此图确实显示正确, 并且我可以拖动来做出 x- y 选择 。 当绘图被重新绘制时, 屏幕缩进时, 屏幕上轴网格的实际大小, 尽管已经绘制了适当的数据范围 。 此外, 每次我放大- replot 时, 轴标签就会从视图中消失, 尽管我仍然可以在检查器中看到它们, 并且这个图图的左下角上方有一些十字架, 看上去像是轴标签已经移动到上面, 并且部分( 简单) 可见。 我有一些其他代码, 以不同的数据重新绘制此图, 同时也将轴标签从视图中删除 。 尽管此图的大小并没有缩小( 缩放时会这样做 ), 并且再次绘制适当的数据 。 我提到这两个问题可能有着共同的起源 。

我想也许我可以在重新铺设之前 以某种方式 摧毁阴谋或清理画布 来解决这些问题, 但我还没有找到任何指导 如何做到这一点。

以下是一些相关的代码片断。 首个列表列出了最初绘制图的代码, 并连接到“ 选中的” 事件 :

            o.midGraph = $.plot($("#small-graph-mid"), testData, graphOptions);
                $("#small-graph-mid").unbind("plotselected");
                $("#small-graph-mid").bind("plotselected", function (event, ranges) {
                    graphOptions = o.midGraph.getOptions();
                    testData = o.midGraph.getData();
                    o.midGraph = $.plot($("#small-graph-mid"), testData,
                            self._graphZoomOptions(graphOptions, ranges));
                });

这是设定新范围轴范围的函数 :

    _graphZoomOptions: function(options, ranges) {
        return $.extend(true, {}, options, {
            xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to },
            yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
        });
    },

我是否在正确的轨道上 认为我需要 某种方式摧毁/清除/重设 阴谋/空洞?

问题回答

你在用杰克里1.7.2吗?

如果是这样的话,请查看 < a href=" "http://code.google.com/p/flot/issues/detail? id=643#c4" >这一线索 ,特别是评论4中所包含的固定导航插件。

它解决了我与导航插件的问题 经过几个小时的乱搞。

在此 s 我如何将 Y 轴设置为一定范围 。 所有 Y 轴都会设置在相同的范围 。 在“ 每个” 循环中的 4 个语句中, 2个可能没有必要, 我只是不记得哪个语句 。

$.each(yaxes, function(_, _yaxis){
    _yaxis.min = _min;
    _yaxis.max = _max;
    _yaxis.options.min=_min;
    _yaxis.options.max=_max;
});

setupGrid();
draw(); 

您不需要销毁图表并重新绘制它。设置Grid和绘图函数会为您处理此部分 。

我找到这个问题, 通过不使用 plot.getOptions () 来解决它。 它没有看到原因, 而是使用在启动 plot 工作时我创建的原始选项对象 。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签