3

我有一个图形/绘图区域,如下所示:

在此处输入图像描述

如您所见,网格线不是等距的。

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

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"]

             }
            }
          };

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

谢谢。

4

1 回答 1

1

Finally, achieved it.

I had a logarithmic scale so I followed the following

Step 1

Range: 55-880

Initial Steps: 55,110,220,440,880

Step 2

Calculate log of Initial Steps

Step 3

Calculate the differences between the log values -e.g- value_of_log(110) - value_of_log(55)

Step 4

Using Brute Force/Hit'n'Trial, insert values between the Initial Steps so that the differences between the log values remain same.

PS: I have attached the screenshots as sample.

Sample Table Sample Table

Output

Output

Hope This Helps !

于 2013-06-14T07:03:17.600 回答