简体   繁体   English

在jQtouch网站上使用Flot图表时出现问题

[英]Problem using Flot charts on a jQtouch web site

Hiiii Hiiii

I have a jQtouch site in dev and i would like to use a chart on it, to me Flot looks like the best way to do this (prettiest!) 我在开发人员中有一个jQtouch网站,我想在上面使用图表,对我来说Flot似乎是最好的方法(最漂亮!)

However if i implement flot on the site i get the following error: 但是,如果我在网站上实现了float,则会出现以下错误:

Invalid dimensions for plot, width = 0, height = 0 绘图尺寸无效,宽度= 0,高度= 0

If i comment out the style sheet ../jqtouch/jqtouch.min.css the flot chart works just fine. 如果我注释掉样式表../jqtouch/jqtouch.min.css,浮点图就很好。

This i think has something to do with the fact that you cannot use flot inside a div that has display:none 我认为这与以下事实有关:您不能在具有display:none的div内使用flot

From the Flot readme 从Flot自述文件

Blockquote Make sure that the placeholder isn't within something with a display:none CSS property - in that case, Flot has trouble measuring label dimensions which results in garbled looks and might have trouble measuring the placeholder dimensions which is fatal (it'll throw an exception). Blockquote确保占位符不在显示的内容之内:无CSS属性-在这种情况下,Flot无法测量标签尺寸,从而导致外观混乱,并且可能无法测量占位符,这是致命的(它将抛出例外)。

Does anyone know if i can work around this/fix this so flot and jQtouch work together? 有谁知道我是否可以解决这个问题/解决这个问题,使flot和jQtouch可以一起工作?

Thanks 谢谢

Hairby 海比

I have managed to use http://highcharts.com/ and jQtouch together ... however I don't have an example right off the bat to show you. 我已经成功地同时使用了http://highcharts.com/和jQtouch ... ...但是我没有一个例子可以立即向您展示。

Take a look a HighCharts tho, I switched to it from Flot and never looked back. 看一看HighCharts,我从Flot切换到它,再也没有回头。

You can use visibiity:hidden or position: absolute and have it off the page, other than that...no real options since it can't initialize in an empty area. 您可以使用visibiity:hiddenposition: absolute并将其显示在页面上, visibiity:hidden ...没有实际选项,因为它无法在空白区域中初始化。

Alternatively, if it's hidden by the stylesheet, just override the style inline: 另外,如果样式表隐藏了它,则只需重写内联样式即可:

<div id="myDiv" style="width:400px;height:300px;"></div> 

$.plot($("#myDiv"), [ .... ]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM