Flot:对数刻度轴的等距网格线?

时间:2013-06-10 06:00:21

标签: flot

我有一个图表/情节区域,如下所示:

enter image description here

正如您所看到的那样,网格线不是等距的。

以下是绘制刻度线和网格线的代码。由于比例是对数的,我发现以下应该是一种方便的转换方法。

function setUpflot(){
            // setup plot
             myTestArray = getRandomData();

             var options = {
                // series  : { shadowSize: 0, splines: {show:true,lineWidth:1}},
                 series  : { },
                 xaxis   : { tickLength:0,  show: false },
                 yaxis   :{

            //position: "left",
            ticks: [[55,""],[68.75,""],[82.5,""],[96.25,""],[110,"110"],

                   [136.25,""],[165,""],[192.5,""],[220,"220"],[275,""],[330,""],

                   [385,""],[440,"440"],[550,""],[660,""],[770,""],[880,""]],


            transform:function(v){return Math.log(v*1.44);}, 
            tickColor:"rgba(148,129,151,0.5)",
            min: minGraphY, max:maxGraphY,show: true
                            },


        y2axis   :{
                            //position: "right",


                            ticks: [[55,""],[68.75,""],[82.5,""],[96.25,""],[110,"A2"],

                            [136.25,""],[165,""],[192.5,""],[220,"A3"],[275,""],[330,""],

                            [385,""],[440,"A4"],[550,""],[660,""],[770,""],[880,""]],

             alignTicksWithAxis: true,


            transform:function(v){return Math.log(v*1.44);}, 


            tickColor:"rgba(148,129,151,0.5)",


            min: minGraphY,


            max:maxGraphY,


            show: true,


            tickLength: 0
        },

                grid    : { 
                borderWidth:0,          
                backgroundColor: 
                                       {
                    colors: ["#5d0d3f","#5d0d3f","#5d0d3f",

                              "#6e0326","#724922","#724922",

                              "#2a5631","#724922","#724922","#6e0326",

                              "#5d0d3f","#5d0d3f","#5d0d3f"]

             }
            }
          };

我需要网格线等距离。我将如何实现这一目标?

日Thnx。

1 个答案:

答案 0 :(得分:1)

最后,实现了它。

我有一个对数刻度,所以我遵循以下

第1步

范围:55-880

初步步骤:55,110,220,440,880

第2步

计算初始步骤的日志

第3步

计算日志值之间的差异-e.g- value_of_log(110) - value_of_log(55)

第4步

使用Brute Force / Hit'n'Trial,在初始步骤之间插入值,以便日志值之间的差异保持不变。

PS:我已将截图附加为示例。

样本表 Sample Table

<强>输出

Output

希望这有帮助!