Javascript Flot 库将 y 轴设置为最小 0 和最大 24

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4690413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 13:38:49  来源:igfitidea点击:

Flot library setting up y axis to min 0 and max 24

javascriptjqueryflot

提问by Prady

How can i set up my y axis to be in the range of 0 to 24

如何将 y 轴设置在 0 到 24 的范围内

Here is the code i have.

这是我的代码。

  j$.plot(j$("#placeholder"),[d1],{
        xaxis: 
        { mode: "time", 
            min: (new Date("2010/11/01")).getTime(),
            max: (new Date("2011/02/01")).getTime()
            }
 },
  {yaxis: { min:0, max:24 } };
  };

xaxis seemed to work but when i added y axis it doesnt work.

xaxis 似乎有效,但是当我添加 y 轴时它不起作用。

Apart from this d1 holds the string which is sent from salesforce

除了这个 d1 保存从 salesforce 发送的字符串

for example d1 holds

例如 d1 持有

[1294041600000,14.00],[1294041600000,14.50],[1294041600000,15.00],[1293955200000,12.00]

I am not able to view the graph, currently i am having the y axis showing only the range -1 to 1, i am assuming this could be the reason why i am not seeing the line.

我无法查看图表,目前我的 y 轴仅显示 -1 到 1 的范围,我假设这可能是我没有看到这条线的原因。

thanks

谢谢

Prady

普拉迪

回答by Prady

The y axis problem was solved. Here is the code

y 轴问题已解决。这是代码

j$.plot(j$("#placeholder"), [d1], {
    xaxis: 
    {
      mode: "time", 
      min: (new Date("2010/11/01")).getTime(),
      max: (new Date("2011/02/01")).getTime()
    },

    yaxis:
    {
        min:0, max: 24,  tickSize: 5 
    }
});