Flot:默认情况下放大至最右端 [英] Flot: Zoom to Far Right by Default

查看:67
本文介绍了Flot:默认情况下放大至最右端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您有一个浮动图,该浮动图的宽度为500像素,并且在x轴上有100个刻度.默认情况下,那显然很拥挤. 导航"插件可以解决这种情况.例如,如果您想一次将其限制为仅10个刻度,则可以执行以下操作:

Let's say you have a flot graph that's 500 pixels wide and it has 100 ticks on the x axis. That will obviously be very crowded by default. The "navigate" plugin helps this situation. For example, if you want to limit it to only 10 ticks at once, you can do this:

$.plot(...).zoom({'amount': total_ticks / 10});

但是,我不确定如何制作图形,以便在首次绘制图形时默认显示 last 十个(最右边的十个),而不仅仅是从中间随机抽取十个.另外,尽管我给出的示例假设有100个刻度,但实际上我不会事先知道该数字,因此,如果是100个刻度,则默认情况下我希望看到91到100的刻度.如果它是108个刻度,那么我想默认看到99到108的刻度.我该怎么办?

However, I'm not sure how to make it so that when the graph is first drawn, it is showing the last ten (the ten on the far right) by default, not just a random set of ten from the middle. Also, although the example I gave assumes there are 100 ticks, I won't actually know the number beforehand, so if it's 100 ticks then I want to see ticks 91 through 100 by default. If it's 108 ticks then I want to see ticks 99 through 108 by default. How can I do this?

推荐答案

在初始缩放时,只需将center选项设置为图表的宽度即可:

On your initial zoom, just set the center option to the width of your chart:

$.plot($('#graph_with_zoom'), [data], plot_options).zoom({
    'amount': total_ticks / 5,
    'center': { left: 400, top: 0 }
});

更新了小提琴此处.

这篇关于Flot:默认情况下放大至最右端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆