(jqplot)如何在对数比例图中显示次要网格?

时间:2022-09-15 10:49:00

I have my jqplot with log scale axis which is look like this:

我有我的jqplot与log scale轴,如下所示:

(jqplot)如何在对数比例图中显示次要网格?

And here is my x and y axis setting for my jqplot:

这是我的jqplot的x和y轴设置:

            axes : {
            xaxis : {
                renderer : $j.jqplot.LogAxisRenderer,
                ticks : [0.1, 1, 10, 100],
            },
            yaxis : {
                renderer : $j.jqplot.LogAxisRenderer,           
                ticks : [0.1, 1, 10, 100],
            },
        }

But I would like to show the minor grids which is looks exactly like this:

但我想展示看起来像这样的小网格:

(jqplot)如何在对数比例图中显示次要网格?

How could I do this?

我怎么能这样做?

2 个解决方案

#1


3  

max = 100;
min = 1;

// calculate the power of 10 of max value
var dcmMax = Math.floor(Math.log(max)/Math.log(10));

// calculate the power of 10 of min value
var dcmMin = Math.floor(Math.log(min)/Math.log(10));

var ticks = [];
var tick, f;

for (var i = dcmMin ; i <= dcmMax ; i++){

    tick = Math.floor(Math.log(i)/Math.log(10));

    if (i == dcmMin){
       ticks.push(tick.toFixed(1));
    }

    f = tick;

    for (var j = 0; j < 8; j++){
        tick = tick + f;
        ticks.push(myTick(tick.toFixed(1)));
    }

    if (i == dcmMax){
        ticks.push(tick.toFixed(1));
    }
}

function myTick(value){
return {value:value, showLabel:false, showMark:false};
}

this will create major ticks with 1.0 , 10.0, 100.0, 1000.0, and show only gridline without minor ticks since the respective value of showLabel and showMark is set to false

这将创建1.0,10.0,100.0,1000.0的主要刻度,并且仅显示网格线而没有次要刻度,因为showLabel和showMark的相应值设置为false

#2


1  

Any answer better than mine?

还有比我更好的答案吗?

    majorTicks = [      
                    1,
                    {value:2, showLabel:false, showMark:false},
                    {value:3, showLabel:false, showMark:false},
                    {value:4, showLabel:false, showMark:false},
                    {value:5, showLabel:false, showMark:false},
                    {value:6, showLabel:false, showMark:false},
                    {value:7, showLabel:false, showMark:false},
                    {value:8, showLabel:false, showMark:false},
                    {value:9, showLabel:false, showMark:false},
                    10,
                    {value:20, showLabel:false, showMark:false},
                    {value:30, showLabel:false, showMark:false},    
                    {value:40, showLabel:false, showMark:false},    
                    {value:50, showLabel:false, showMark:false},    
                    {value:60, showLabel:false, showMark:false},    
                    {value:70, showLabel:false, showMark:false},    
                    {value:80, showLabel:false, showMark:false},
                    {value:90, showLabel:false, showMark:false},    
                    100
                ];

#1


3  

max = 100;
min = 1;

// calculate the power of 10 of max value
var dcmMax = Math.floor(Math.log(max)/Math.log(10));

// calculate the power of 10 of min value
var dcmMin = Math.floor(Math.log(min)/Math.log(10));

var ticks = [];
var tick, f;

for (var i = dcmMin ; i <= dcmMax ; i++){

    tick = Math.floor(Math.log(i)/Math.log(10));

    if (i == dcmMin){
       ticks.push(tick.toFixed(1));
    }

    f = tick;

    for (var j = 0; j < 8; j++){
        tick = tick + f;
        ticks.push(myTick(tick.toFixed(1)));
    }

    if (i == dcmMax){
        ticks.push(tick.toFixed(1));
    }
}

function myTick(value){
return {value:value, showLabel:false, showMark:false};
}

this will create major ticks with 1.0 , 10.0, 100.0, 1000.0, and show only gridline without minor ticks since the respective value of showLabel and showMark is set to false

这将创建1.0,10.0,100.0,1000.0的主要刻度,并且仅显示网格线而没有次要刻度,因为showLabel和showMark的相应值设置为false

#2


1  

Any answer better than mine?

还有比我更好的答案吗?

    majorTicks = [      
                    1,
                    {value:2, showLabel:false, showMark:false},
                    {value:3, showLabel:false, showMark:false},
                    {value:4, showLabel:false, showMark:false},
                    {value:5, showLabel:false, showMark:false},
                    {value:6, showLabel:false, showMark:false},
                    {value:7, showLabel:false, showMark:false},
                    {value:8, showLabel:false, showMark:false},
                    {value:9, showLabel:false, showMark:false},
                    10,
                    {value:20, showLabel:false, showMark:false},
                    {value:30, showLabel:false, showMark:false},    
                    {value:40, showLabel:false, showMark:false},    
                    {value:50, showLabel:false, showMark:false},    
                    {value:60, showLabel:false, showMark:false},    
                    {value:70, showLabel:false, showMark:false},    
                    {value:80, showLabel:false, showMark:false},
                    {value:90, showLabel:false, showMark:false},    
                    100
                ];