Flot:如何保持x和y轴相同的比例? [英] Flot: How to keep x and y axes the same scale?

查看:71
本文介绍了Flot:如何保持x和y轴相同的比例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在标准笛卡尔平面上绘制,因此x轴上的1个单位的长度与y轴上的1个单位的长度相同.我还使用导航插件进行缩放和平移.无论如何,我可以有这个约束吗?在Flot api中找不到与此相关的任何内容.

I want to plot on a standard Cartesian plane, so 1 unit on x axis has the same length as 1 unit on y axis. I also use the navigate plugin to zoom and pan. Is there anyway I can have this constraint? can't find anything about this in Flot api.

谢谢

推荐答案

我必须做类似的事情,这是第一次测试:

I had to do something similar and this was the first test: fiddle
The main point is that you set the max values for the axis in the same ratio as the width and height of your placeholder div:

options.xaxes[0].max = options.yaxes[0].max * $('#ph').width() / $('#ph').height();
$.plot($('#ph'), data, options);

这篇关于Flot:如何保持x和y轴相同的比例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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